src/Pure/ML-Systems/smlnj.ML
changeset 14519 4ca3608fdf4f
parent 12990 c11adf2b1c1e
child 14520 af9d7fcf873e
equal deleted inserted replaced
14518:c3019a66180f 14519:4ca3608fdf4f
     7 *)
     7 *)
     8 
     8 
     9 (case #version_id (Compiler.version) of
     9 (case #version_id (Compiler.version) of
    10   [110, x] => if x >= 35 then use "ML-Systems/smlnj-compiler.ML" else ()
    10   [110, x] => if x >= 35 then use "ML-Systems/smlnj-compiler.ML" else ()
    11 | _ => ());
    11 | _ => ());
    12 
       
    13 
    12 
    14 (** ML system related **)
    13 (** ML system related **)
    15 
    14 
    16 (* restore old-style character / string functions *)
    15 (* restore old-style character / string functions *)
    17 
    16 
    41   Compiler.Control.Print.printLength := n);
    40   Compiler.Control.Print.printLength := n);
    42 
    41 
    43 
    42 
    44 (* compiler-independent timing functions *)
    43 (* compiler-independent timing functions *)
    45 
    44 
    46 (*Note start point for timing*)
    45 (case #version_id (Compiler.version) of
    47 fun startTiming() =
    46   [110, x] => if x >= 45
    48   let val CPUtimer = Timer.startCPUTimer();
    47 	      then use "ML-Systems/cpu-timer-basis.ML"
    49       val time = Timer.checkCPUTimer(CPUtimer)
    48 	      else use "ML-Systems/cpu-timer-gc.ML"
    50   in  (CPUtimer,time)  end;
    49 | _ => ());
    51 
       
    52 (*Finish timing and return string*)
       
    53 fun endTiming (CPUtimer, {gc,sys,usr}) =
       
    54   let open Time  (*...for Time.toString, Time.+ and Time.- *)
       
    55       val {gc=gc2,sys=sys2,usr=usr2} = Timer.checkCPUTimer(CPUtimer)
       
    56   in  "User " ^ toString (usr2-usr) ^
       
    57       "  GC " ^ toString (gc2-gc) ^
       
    58       "  All "^ toString (sys2-sys + usr2-usr + gc2-gc) ^
       
    59       " secs"
       
    60       handle Time => ""
       
    61   end;
       
    62 
    50 
    63 
    51 
    64 (* prompts *)
    52 (* prompts *)
    65 
    53 
    66 fun ml_prompts p1 p2 =
    54 fun ml_prompts p1 p2 =
    67   (Compiler.Control.primaryPrompt := p1; Compiler.Control.secondaryPrompt := p2);
    55   (Compiler.Control.primaryPrompt := p1; Compiler.Control.secondaryPrompt := p2);
    68 
    56 
    69 
    57 
       
    58 (case #version_id (Compiler.version) of
       
    59   [110, x] => if x >= 45
       
    60 	      then use "ML-Systems/smlnj-basis-compat.ML"
       
    61 	      else ()
       
    62 | _ => ());
       
    63 
    70 (* toplevel pretty printing (see also Pure/install_pp.ML) *)
    64 (* toplevel pretty printing (see also Pure/install_pp.ML) *)
    71 
    65 
    72 fun make_pp path pprint =
    66 (case #version_id (Compiler.version) of
    73   let
    67   [110, x] => if x >= 45
    74     open Compiler.PrettyPrint;
    68 	      then use "ML-Systems/smlnj-pp-new.ML"
    75 
    69 	      else use "ML-Systems/smlnj-pp-old.ML"
    76     fun pp pps obj =
    70 | _ => ());
    77       pprint obj
       
    78         (add_string pps, begin_block pps INCONSISTENT,
       
    79           fn wd => add_break pps (wd, 0), fn () => add_newline pps,
       
    80           fn () => end_block pps);
       
    81   in
       
    82     (path, pp)
       
    83   end;
       
    84 
    71 
    85 fun install_pp (path, pp) = Compiler.PPTable.install_pp path pp;
    72 fun install_pp (path, pp) = Compiler.PPTable.install_pp path pp;
    86 
    73 
    87 
    74 
    88 (* ML command execution *)
    75 (* ML command execution *)