Runtime compilation and evaluation for bootstrap. Initial ML file operations.
*)
signature ML_COMPILER0 = sig type polyml_location = PolyML.location type context =
{name_space: ML_Name_Space.T,
print_depth: int option,
here: int -> string -> string, print: string -> unit,
error: string -> unit} val make_context: ML_Name_Space.T -> context val ML: context -> {debug: bool, file: string, line: int, verbose: bool} -> string -> unit val ML_file: context -> {debug: bool, verbose: bool} -> string -> unit val debug_option: booloption -> bool val ML_file_operations: (booloption -> string -> unit) ->
{ML_file: string -> unit, ML_file_debug: string -> unit, ML_file_no_debug: string -> unit} end;
structure ML_Compiler0: ML_COMPILER0 = struct
type polyml_location = PolyML.location;
(* global options *)
val _ = PolyML.Compiler.reportUnreferencedIds := true; val _ = PolyML.Compiler.reportExhaustiveHandlers := true; val _ = PolyML.Compiler.printInAlphabeticalOrder := false; val _ = PolyML.Compiler.maxInlineSize := 80;
(* context *)
type context =
{name_space: ML_Name_Space.T,
print_depth: int option,
here: int -> string -> string, print: string -> unit,
error: string -> unit};
fun make_context name_space : context =
{name_space = name_space,
print_depth = NONE,
here = fn line => fn file => " (line " ^ Int.toString line ^ " of \"" ^ file ^ "\")", print = fn s => (TextIO.output (TextIO.stdOut, s ^ "\n"); TextIO.flushOut TextIO.stdOut),
error = fn s => error s};
(* ML file operations *)
local
fun drop_newline s = ifString.isSuffix "\n" s thenString.substring (s, 0, size s - 1) else s;
fun ml_input start_line name txt = let fun input line (#"\\" :: #"<" :: #"^" :: #"h" :: #"e" :: #"r" :: #"e" :: #">" :: cs) res = letval s = "(Position.line_file_only " ^ Int.toString line ^ " \"" ^ name ^ "\")" in input line cs (s :: res) end
| input line (#"@" :: #"{" :: #"m" :: #"a" :: #"k" :: #"e" :: #"_" ::
#"s" :: #"t" :: #"r" :: #"i" :: #"n" :: #"g" :: #"}" :: cs) res =
input line cs (ML_Pretty.make_string_fn :: res)
| input line (#"\\" :: #"<" :: cs) res = input line cs ("\092\092<" :: res)
| input line (#"\n" :: cs) res = input (line + 1) cs ("\n" :: res)
| input line (c :: cs) res = input line cs (str c :: res)
| input _ [] res = rev res; inString.concat (input start_line (String.explode txt) []) end;
in
fun ML {name_space, print_depth, here, print, error, ...} {line, file, verbose, debug} text = let val current_line = Unsynchronized.ref line; val in_buffer = Unsynchronized.ref (String.explode (ml_input line file text)); val out_buffer = Unsynchronized.ref ([]: stringlist); fun output () = drop_newline (implode (rev (! out_buffer)));
fun get () =
(case ! in_buffer of
[] => NONE
| c :: cs =>
(in_buffer := cs; if c = #"\n"then current_line := ! current_line + 1 else (); SOME c)); fun put s = out_buffer := s :: ! out_buffer; fun put_message {message = msg1, hard, location = {startLine = message_line, ...}, context} =
(put (if hard then"Error: "else"Warning: ");
PolyML.prettyPrint (put, 76) msg1;
(case context of NONE => () | SOME msg2 => PolyML.prettyPrint (put, 76) msg2);
put ("At" ^ here (FixedInt.toInt message_line) file ^ "\n"));
if Thread_Data.is_virtual then () else
ML_Compiler0.ML
(ML_Compiler0.make_context
(ML_Name_Space.global_values
[("prettyRepresentation", "ML_system_pretty"),
("addPrettyPrinter", "ML_system_pp"),
("addOverload", "ML_system_overload")]))
{debug = false, file = "", line = 0, verbose = false} "open PolyML RunCall";
ML_system_pp (fn depth => fn pretty => fn var => pretty (Synchronized.value var, depth));
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.26Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.