Merge.
1 (* Title: Pure/ML-Systems/polyml.ML
3 Compatibility wrapper for experimental versions of Poly/ML after 5.2.1.
7 use "ML-Systems/polyml_common.ML";
8 use "ML-Systems/multithreading_polyml.ML";
10 val pointer_eq = PolyML.pointerEq;
12 fun share_common_data () = PolyML.shareCommonData PolyML.rootFunction;
15 (* toplevel pretty printers *)
18 fun make_pp path pprint = ();
19 fun install_pp _ = ();
22 (* runtime compilation *)
24 structure ML_NameSpace =
26 open PolyML.NameSpace;
27 val global = PolyML.globalNameSpace;
33 if String.isSuffix "\n" s then String.substring (s, 0, size s - 1)
38 fun use_text (tune: string -> string) str_of_pos
39 name_space (start_line, name) (print, err) verbose txt =
41 val current_line = ref start_line;
42 val in_buffer = ref (String.explode (tune txt));
43 val out_buffer = ref ([]: string list);
44 fun output () = drop_newline (implode (rev (! out_buffer)));
50 (in_buffer := cs; if c = #"\n" then current_line := ! current_line + 1 else (); SOME c));
51 fun put s = out_buffer := s :: ! out_buffer;
52 fun put_message {message, hard, location = {startLine = line, ...}, context} =
53 (put (if hard then "Error: " else "Warning: ");
54 PolyML.prettyPrint (put, 76) message;
55 put (str_of_pos line name ^ "\n"));
58 [PolyML.Compiler.CPOutStream put,
59 PolyML.Compiler.CPLineNo (fn () => ! current_line),
60 PolyML.Compiler.CPErrorMessageProc put_message,
61 PolyML.Compiler.CPNameSpace name_space,
62 PolyML.Compiler.CPPrintInAlphabeticalOrder false];
64 (while not (List.null (! in_buffer)) do
65 PolyML.compiler (get, parameters) ())
67 (put ("Exception- " ^ General.exnMessage exn ^ " raised");
68 err (output ()); raise exn);
69 in if verbose then print (output ()) else () end;
71 fun use_file tune str_of_pos name_space output verbose name =
73 val instream = TextIO.openIn name;
74 val txt = Exn.release (Exn.capture TextIO.inputAll instream before TextIO.closeIn instream);
75 in use_text tune str_of_pos name_space (1, name) output verbose txt end;