added exn_message (formerly in toplevel.ML);
authorwenzelm
Sat, 06 Jun 2009 21:11:23 +0200
changeset 31477 ae1a00e1a2f6
parent 31476 c5d2899b6de9
child 31478 5e412e4c6546
added exn_message (formerly in toplevel.ML); eval/code: proper Isar runtime support; tuned signature;
src/Pure/ML/ml_compiler.ML
src/Pure/ML/ml_compiler_polyml-5.3.ML
--- a/src/Pure/ML/ml_compiler.ML	Sat Jun 06 21:11:22 2009 +0200
+++ b/src/Pure/ML/ml_compiler.ML	Sat Jun 06 21:11:23 2009 +0200
@@ -6,14 +6,16 @@
 
 signature ML_COMPILER =
 sig
-  val exception_position: exn -> Position.T
+  val exn_position: exn -> Position.T
+  val exn_message: exn -> string
   val eval: bool -> Position.T -> ML_Lex.token list -> unit
 end
 
 structure ML_Compiler: ML_COMPILER =
 struct
 
-fun exception_position _ = Position.none;
+fun exn_position _ = Position.none;
+val exn_message = Runtime.exn_message exn_position;
 
 fun eval verbose pos toks =
   let
--- a/src/Pure/ML/ml_compiler_polyml-5.3.ML	Sat Jun 06 21:11:22 2009 +0200
+++ b/src/Pure/ML/ml_compiler_polyml-5.3.ML	Sat Jun 06 21:11:23 2009 +0200
@@ -6,7 +6,8 @@
 
 signature ML_COMPILER =
 sig
-  val exception_position: exn -> Position.T
+  val exn_position: exn -> Position.T
+  val exn_message: exn -> string
   val eval: bool -> Position.T -> ML_Lex.token list -> unit
 end
 
@@ -31,11 +32,13 @@
     loc_props
   end |> Position.of_properties;
 
-fun exception_position exn =
+fun exn_position exn =
   (case PolyML.exceptionLocation exn of
     NONE => Position.none
   | SOME loc => position_of loc);
 
+val exn_message = Runtime.exn_message exn_position;
+
 
 (* parse trees *)
 
@@ -145,10 +148,13 @@
       end;
 
     fun result_fun (phase1, phase2) () =
-     (case phase1 of NONE => ()
-      | SOME parse_tree => report_parse_tree depth space parse_tree;
-      case phase2 of NONE => err "Static Errors"
-      | SOME code => apply_result (code ()));  (* FIXME cf. Toplevel.program *)
+     ((case phase1 of
+        NONE => ()
+      | SOME parse_tree => report_parse_tree depth space parse_tree);
+      (case phase2 of
+        NONE => err "Static Errors"
+      | SOME code =>
+          apply_result ((code |> Runtime.debugging |> Runtime.toplevel_error exn_message) ())));
 
 
     (* compiler invocation *)