src/Pure/ML/ml_compiler.ML
author wenzelm
Sat Jun 06 21:11:23 2009 +0200 (2009-06-06 ago)
changeset 31477 ae1a00e1a2f6
parent 31428 3b32a57b044b
child 38874 4a4d34d2f97b
permissions -rw-r--r--
added exn_message (formerly in toplevel.ML);
eval/code: proper Isar runtime support;
tuned signature;
wenzelm@31333
     1
(*  Title:      Pure/ML/ml_compiler.ML
wenzelm@31333
     2
    Author:     Makarius
wenzelm@31333
     3
wenzelm@31333
     4
Runtime compilation -- generic version.
wenzelm@31333
     5
*)
wenzelm@31333
     6
wenzelm@31333
     7
signature ML_COMPILER =
wenzelm@31333
     8
sig
wenzelm@31477
     9
  val exn_position: exn -> Position.T
wenzelm@31477
    10
  val exn_message: exn -> string
wenzelm@31333
    11
  val eval: bool -> Position.T -> ML_Lex.token list -> unit
wenzelm@31333
    12
end
wenzelm@31333
    13
wenzelm@31333
    14
structure ML_Compiler: ML_COMPILER =
wenzelm@31333
    15
struct
wenzelm@31333
    16
wenzelm@31477
    17
fun exn_position _ = Position.none;
wenzelm@31477
    18
val exn_message = Runtime.exn_message exn_position;
wenzelm@31428
    19
wenzelm@31333
    20
fun eval verbose pos toks =
wenzelm@31333
    21
  let
wenzelm@31333
    22
    val line = the_default 1 (Position.line_of pos);
wenzelm@31333
    23
    val file = the_default "ML" (Position.file_of pos);
wenzelm@31333
    24
    val text = ML_Lex.flatten toks;
wenzelm@31333
    25
  in Secure.use_text ML_Env.local_context (line, file) verbose text end;
wenzelm@31333
    26
wenzelm@31333
    27
end;
wenzelm@31333
    28