moved Library.decode_permissive_utf8 to Isabelle_System;
moved Library.with_tmp_file to Isabelle_System;
added Isabelle_System.read_file/write_file;
added Isabelle_System.system_out, with propagation of thread interrupts and process shutdown (global CTRL-C);
/* Title: Pure/library.scala
Author: Makarius
Basic library.
*/
package isabelle
import java.lang.System
object Library
{
/* reverse CharSequence */
class Reverse(text: CharSequence, start: Int, end: Int) extends CharSequence
{
require(0 <= start && start <= end && end <= text.length)
def this(text: CharSequence) = this(text, 0, text.length)
def length: Int = end - start
def charAt(i: Int): Char = text.charAt(end - i - 1)
def subSequence(i: Int, j: Int): CharSequence =
if (0 <= i && i <= j && j <= length) new Reverse(text, end - j, end - i)
else throw new IndexOutOfBoundsException
override def toString: String =
{
val buf = new StringBuilder(length)
for (i <- 0 until length)
buf.append(charAt(i))
buf.toString
}
}
/* timing */
def timeit[A](e: => A) =
{
val start = System.currentTimeMillis()
val result = Exn.capture(e)
val stop = System.currentTimeMillis()
System.err.println((stop - start) + "ms elapsed time")
Exn.release(result)
}
}