src/Pure/ML-Systems/smlnj.ML
author wenzelm
Sat, 06 Feb 2010 22:01:48 +0100
changeset 35014 a725ff6ead26
parent 35010 d6e492cea6e4
child 36162 0bd034a80a9a
permissions -rw-r--r--
explicit representation of single-assignment variables;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/ML-Systems/smlnj.ML
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
     2
5708
fb09ab6a447f dropped support for SML/NJ 109.x;
wenzelm
parents: 5090
diff changeset
     3
Compatibility file for Standard ML of New Jersey 110 or later.
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
     4
*)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
     5
28443
de653f1ad78b more robust treatment of Interrupt (cf. exn.ML);
wenzelm
parents: 28284
diff changeset
     6
exception Interrupt;
31427
5a07cc86675d reraise exceptions to preserve original position (ML system specific);
wenzelm
parents: 31321
diff changeset
     7
fun reraise exn = raise exn;
28443
de653f1ad78b more robust treatment of Interrupt (cf. exn.ML);
wenzelm
parents: 28284
diff changeset
     8
24599
7b0ecf9a9055 use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents: 24329
diff changeset
     9
use "ML-Systems/proper_int.ML";
32776
1504f9c2d060 more uniform treatment of structure Unsynchronized in ML bootstrap phase;
wenzelm
parents: 32737
diff changeset
    10
use "ML-Systems/unsynchronized.ML";
24599
7b0ecf9a9055 use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents: 24329
diff changeset
    11
use "ML-Systems/overloading_smlnj.ML";
34136
3dcb46ae6185 added basic library -- Scala version;
wenzelm
parents: 33060
diff changeset
    12
use "General/exn.ML";
35014
a725ff6ead26 explicit representation of single-assignment variables;
wenzelm
parents: 35010
diff changeset
    13
use "ML-Systems/single_assignment.ML";
25732
308315ee2b6d added ML-Systems/universal.ML;
wenzelm
parents: 24688
diff changeset
    14
use "ML-Systems/universal.ML";
28151
61f9c918b410 explicit use of universal.ML and dummy_thread.ML;
wenzelm
parents: 26885
diff changeset
    15
use "ML-Systems/thread_dummy.ML";
24688
a5754ca5c510 replaced interrupt_timeout by TimeLimit.timeLimit (available on SML/NJ and Poly/ML 5.1);
wenzelm
parents: 24599
diff changeset
    16
use "ML-Systems/multithreading.ML";
31686
e54ae15335a1 more detailed start_timing/end_timing (in timing.ML);
wenzelm
parents: 31427
diff changeset
    17
use "ML-Systems/timing.ML";
35010
d6e492cea6e4 renamed system/system_out to bash/bash_output -- to emphasized that this is really GNU bash, not some undefined POSIX sh;
wenzelm
parents: 34136
diff changeset
    18
use "ML-Systems/bash.ML";
28268
ac8431ecd57e use_text/use_file now depend on explicit ML name space;
wenzelm
parents: 28151
diff changeset
    19
use "ML-Systems/ml_name_space.ML";
30619
0226c07352db added generic ML_Pretty interface;
wenzelm
parents: 30187
diff changeset
    20
use "ML-Systems/ml_pretty.ML";
30672
beaadd5af500 more systematic type use_context, with particular values ML_Parse.global_context and ML_Context.local_context;
wenzelm
parents: 30626
diff changeset
    21
use "ML-Systems/use_context.ML";
23921
947152add153 added compatibility file for ML systems without multithreading;
wenzelm
parents: 23826
diff changeset
    22
16542
1259088dc448 tuned pointer_eq;
wenzelm
parents: 16528
diff changeset
    23
1259088dc448 tuned pointer_eq;
wenzelm
parents: 16528
diff changeset
    24
(*low-level pointer equality*)
16502
5a56e59526a5 added pointer_eq;
wenzelm
parents: 16266
diff changeset
    25
21298
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
    26
CM.autoload "$smlnj/init/init.cmi";
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
    27
val pointer_eq = InlineT.ptreql;
16528
25a7459d4d4a pointer equality for sml/nj
paulson
parents: 16502
diff changeset
    28
16502
5a56e59526a5 added pointer_eq;
wenzelm
parents: 16266
diff changeset
    29
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    30
(* restore old-style character / string functions *)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    31
24145
c6402b61d44a preparations for proper type int;
wenzelm
parents: 23965
diff changeset
    32
val ord     = mk_int o SML90.ord;
c6402b61d44a preparations for proper type int;
wenzelm
parents: 23965
diff changeset
    33
val chr     = SML90.chr o dest_int;
10725
ea048ad15283 better definitions of SML90 features
paulson
parents: 7890
diff changeset
    34
val explode = SML90.explode;
ea048ad15283 better definitions of SML90 features
paulson
parents: 7890
diff changeset
    35
val implode = SML90.implode;
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    36
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    37
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    38
(* New Jersey ML parameters *)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    39
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    40
val _ =
21298
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
    41
 (Control.Print.printLength := 1000;
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
    42
  Control.Print.printDepth := 350;
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
    43
  Control.Print.stringDepth := 250;
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
    44
  Control.Print.signatures := 2;
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
    45
  Control.MC.matchRedundantError := false);
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    46
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    47
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    48
(* Poly/ML emulation *)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    49
24599
7b0ecf9a9055 use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents: 24329
diff changeset
    50
val exit = exit o dest_int;
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    51
fun quit () = exit 0;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    52
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    53
(*limit the printing depth -- divided by 2 for comparibility with Poly/ML*)
24329
f31594168d27 ML system provides get_print_depth;
wenzelm
parents: 24290
diff changeset
    54
local
24599
7b0ecf9a9055 use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents: 24329
diff changeset
    55
  val depth = ref (10: int);
24329
f31594168d27 ML system provides get_print_depth;
wenzelm
parents: 24290
diff changeset
    56
in
f31594168d27 ML system provides get_print_depth;
wenzelm
parents: 24290
diff changeset
    57
  fun get_print_depth () = ! depth;
f31594168d27 ML system provides get_print_depth;
wenzelm
parents: 24290
diff changeset
    58
  fun print_depth n =
f31594168d27 ML system provides get_print_depth;
wenzelm
parents: 24290
diff changeset
    59
   (depth := n;
f31594168d27 ML system provides get_print_depth;
wenzelm
parents: 24290
diff changeset
    60
    Control.Print.printDepth := dest_int n div 2;
f31594168d27 ML system provides get_print_depth;
wenzelm
parents: 24290
diff changeset
    61
    Control.Print.printLength := dest_int n);
f31594168d27 ML system provides get_print_depth;
wenzelm
parents: 24290
diff changeset
    62
end;
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    63
26474
94735cff132c added forget_structure;
wenzelm
parents: 26385
diff changeset
    64
16660
76613dff2c9a added profiler interface (dummy);
wenzelm
parents: 16542
diff changeset
    65
(*prompts*)
4977
6cec2c0ffdbf added ml_prompts;
wenzelm
parents: 4428
diff changeset
    66
fun ml_prompts p1 p2 =
21298
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
    67
  (Control.primaryPrompt := p1; Control.secondaryPrompt := p2);
4977
6cec2c0ffdbf added ml_prompts;
wenzelm
parents: 4428
diff changeset
    68
17511
wenzelm
parents: 16681
diff changeset
    69
(*dummy implementation*)
16681
d54dfd724b35 dummy exception_trace;
wenzelm
parents: 16660
diff changeset
    70
fun profile (n: int) f x = f x;
d54dfd724b35 dummy exception_trace;
wenzelm
parents: 16660
diff changeset
    71
17511
wenzelm
parents: 16681
diff changeset
    72
(*dummy implementation*)
16681
d54dfd724b35 dummy exception_trace;
wenzelm
parents: 16660
diff changeset
    73
fun exception_trace f = f ();
4977
6cec2c0ffdbf added ml_prompts;
wenzelm
parents: 4428
diff changeset
    74
21298
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
    75
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    76
(* ML command execution *)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    77
30672
beaadd5af500 more systematic type use_context, with particular values ML_Parse.global_context and ML_Context.local_context;
wenzelm
parents: 30626
diff changeset
    78
fun use_text ({tune_source, print, error, ...}: use_context) (line, name) verbose txt =
5090
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    79
  let
21298
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
    80
    val ref out_orig = Control.Print.out;
5090
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    81
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    82
    val out_buffer = ref ([]: string list);
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    83
    val out = {say = (fn s => out_buffer := s :: ! out_buffer), flush = (fn () => ())};
10914
aded4ba99b88 use_text etc.: proper output of error messages;
wenzelm
parents: 10725
diff changeset
    84
    fun output () =
7890
0aa16bc2abdb use_text: remove last char from output;
wenzelm
parents: 7855
diff changeset
    85
      let val str = implode (rev (! out_buffer))
10914
aded4ba99b88 use_text etc.: proper output of error messages;
wenzelm
parents: 10725
diff changeset
    86
      in String.substring (str, 0, Int.max (0, size str - 1)) end;
5090
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    87
  in
21298
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
    88
    Control.Print.out := out;
30672
beaadd5af500 more systematic type use_context, with particular values ML_Parse.global_context and ML_Context.local_context;
wenzelm
parents: 30626
diff changeset
    89
    Backend.Interact.useStream (TextIO.openString (tune_source txt)) handle exn =>
22144
c33450acd873 use_text: added name argument;
wenzelm
parents: 21770
diff changeset
    90
      (Control.Print.out := out_orig;
30672
beaadd5af500 more systematic type use_context, with particular values ML_Parse.global_context and ML_Context.local_context;
wenzelm
parents: 30626
diff changeset
    91
        error ((if name = "" then "" else "Error in " ^ name ^ "\n") ^ output ()); raise exn);
21298
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
    92
    Control.Print.out := out_orig;
10914
aded4ba99b88 use_text etc.: proper output of error messages;
wenzelm
parents: 10725
diff changeset
    93
    if verbose then print (output ()) else ()
5090
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    94
  end;
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    95
30672
beaadd5af500 more systematic type use_context, with particular values ML_Parse.global_context and ML_Context.local_context;
wenzelm
parents: 30626
diff changeset
    96
fun use_file context verbose name =
24599
7b0ecf9a9055 use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents: 24329
diff changeset
    97
  let
7b0ecf9a9055 use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents: 24329
diff changeset
    98
    val instream = TextIO.openIn name;
26504
6e87c0a60104 before close: Exn.capture/release;
wenzelm
parents: 26474
diff changeset
    99
    val txt = Exn.release (Exn.capture TextIO.inputAll instream before TextIO.closeIn instream);
30672
beaadd5af500 more systematic type use_context, with particular values ML_Parse.global_context and ML_Context.local_context;
wenzelm
parents: 30626
diff changeset
   100
  in use_text context (1, name) verbose txt end;
21770
ea6f846d8c4b added use_file;
wenzelm
parents: 21298
diff changeset
   101
30672
beaadd5af500 more systematic type use_context, with particular values ML_Parse.global_context and ML_Context.local_context;
wenzelm
parents: 30626
diff changeset
   102
fun forget_structure _ = ();
26474
94735cff132c added forget_structure;
wenzelm
parents: 26385
diff changeset
   103
21770
ea6f846d8c4b added use_file;
wenzelm
parents: 21298
diff changeset
   104
30626
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   105
(* toplevel pretty printing *)
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   106
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   107
fun ml_pprint pps =
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   108
  let
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   109
    fun str "" = ()
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   110
      | str s = PrettyPrint.string pps s;
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   111
    fun pprint (ML_Pretty.Block ((bg, en), prts, ind)) =
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   112
          (str bg; PrettyPrint.openHOVBox pps (PrettyPrint.Rel (dest_int ind));
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   113
            List.app pprint prts; PrettyPrint.closeBox pps; str en)
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   114
      | pprint (ML_Pretty.String (s, _)) = str s
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   115
      | pprint (ML_Pretty.Break (false, wd)) = PrettyPrint.break pps {nsp = dest_int wd, offset = 0}
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   116
      | pprint (ML_Pretty.Break (true, _)) = PrettyPrint.newline pps;
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   117
  in pprint end;
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   118
30672
beaadd5af500 more systematic type use_context, with particular values ML_Parse.global_context and ML_Context.local_context;
wenzelm
parents: 30626
diff changeset
   119
fun toplevel_pp context path pp =
beaadd5af500 more systematic type use_context, with particular values ML_Parse.global_context and ML_Context.local_context;
wenzelm
parents: 30626
diff changeset
   120
  use_text context (1, "pp") false
30626
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   121
    ("CompilerPPTable.install_pp [" ^ String.concatWith "," (map (fn s => "\"" ^ s ^ "\"")  path) ^
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   122
      "] (fn pps => ml_pprint pps o Pretty.to_ML o (" ^ pp ^ "))");
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   123
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   124
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   125
5816
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   126
(** interrupts **)
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   127
26084
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   128
local
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   129
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   130
fun change_signal new_handler f x =
5816
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   131
  let
26084
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   132
    val old_handler = Signals.setHandler (Signals.sigINT, new_handler);
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   133
    val result = Exn.capture (f old_handler) x;
12990
c11adf2b1c1e renamed mask_interrupt to ignore_interrupt;
wenzelm
parents: 12874
diff changeset
   134
    val _ = Signals.setHandler (Signals.sigINT, old_handler);
23965
f93e509659c1 ML-Systems/exn.ML, ML-Systems/multithreading_dummy.ML;
wenzelm
parents: 23921
diff changeset
   135
  in Exn.release result end;
5816
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   136
26084
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   137
in
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   138
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   139
fun interruptible (f: 'a -> 'b) x =
12990
c11adf2b1c1e renamed mask_interrupt to ignore_interrupt;
wenzelm
parents: 12874
diff changeset
   140
  let
26084
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   141
    val result = ref (Exn.Exn Interrupt: 'b Exn.result);
12990
c11adf2b1c1e renamed mask_interrupt to ignore_interrupt;
wenzelm
parents: 12874
diff changeset
   142
    val old_handler = Signals.inqHandler Signals.sigINT;
5816
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   143
  in
12990
c11adf2b1c1e renamed mask_interrupt to ignore_interrupt;
wenzelm
parents: 12874
diff changeset
   144
    SMLofNJ.Cont.callcc (fn cont =>
26084
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   145
      (Signals.setHandler (Signals.sigINT, Signals.HANDLER (fn _ => cont));
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   146
        result := Exn.capture f x));
12990
c11adf2b1c1e renamed mask_interrupt to ignore_interrupt;
wenzelm
parents: 12874
diff changeset
   147
    Signals.setHandler (Signals.sigINT, old_handler);
26084
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   148
    Exn.release (! result)
12990
c11adf2b1c1e renamed mask_interrupt to ignore_interrupt;
wenzelm
parents: 12874
diff changeset
   149
  end;
5816
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   150
26084
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   151
fun uninterruptible f =
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   152
  change_signal Signals.IGNORE
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   153
    (fn old_handler => f (fn g => change_signal old_handler (fn _ => g)));
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   154
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   155
end;
a7475459c740 replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents: 25732
diff changeset
   156
21298
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
   157
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
   158
(* basis library fixes *)
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
   159
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
   160
structure TextIO =
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
   161
struct
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
   162
  open TextIO;
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 22144
diff changeset
   163
  fun inputLine is = TextIO.inputLine is
21298
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
   164
    handle IO.Io _ => raise Interrupt;
6d2306b2376d tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents: 18790
diff changeset
   165
end;
17511
wenzelm
parents: 16681
diff changeset
   166
18790
418131f631fc interrupt_timeout now raises Interrupt instead of SML90.Interrupt
webertj
parents: 18760
diff changeset
   167
5816
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   168
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   169
(** OS related **)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   170
23826
463903573934 moved cd/pwd to ML compatibility layer (simplifies bootstrapping with Alice);
wenzelm
parents: 23770
diff changeset
   171
(* current directory *)
463903573934 moved cd/pwd to ML compatibility layer (simplifies bootstrapping with Alice);
wenzelm
parents: 23770
diff changeset
   172
463903573934 moved cd/pwd to ML compatibility layer (simplifies bootstrapping with Alice);
wenzelm
parents: 23770
diff changeset
   173
val cd = OS.FileSys.chDir;
463903573934 moved cd/pwd to ML compatibility layer (simplifies bootstrapping with Alice);
wenzelm
parents: 23770
diff changeset
   174
val pwd = OS.FileSys.getDir;
463903573934 moved cd/pwd to ML compatibility layer (simplifies bootstrapping with Alice);
wenzelm
parents: 23770
diff changeset
   175
463903573934 moved cd/pwd to ML compatibility layer (simplifies bootstrapping with Alice);
wenzelm
parents: 23770
diff changeset
   176
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   177
(* system command execution *)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   178
35010
d6e492cea6e4 renamed system/system_out to bash/bash_output -- to emphasized that this is really GNU bash, not some undefined POSIX sh;
wenzelm
parents: 34136
diff changeset
   179
val bash_output = (fn (output, rc) => (output, mk_int rc)) o bash_output;
7855
092a6435afad system;
wenzelm
parents: 6227
diff changeset
   180
28488
18fea7e88ea1 removed obsolete Posix/Signal compatibility wrappers;
wenzelm
parents: 28443
diff changeset
   181
fun process_id pid =
18fea7e88ea1 removed obsolete Posix/Signal compatibility wrappers;
wenzelm
parents: 28443
diff changeset
   182
  Word.fmt StringCvt.DEC (Word.fromLargeWord (Posix.Process.pidToWord (Posix.ProcEnv.getpid ())));
17824
36b2978d339a added string_of_pid;
wenzelm
parents: 17763
diff changeset
   183
36b2978d339a added string_of_pid;
wenzelm
parents: 17763
diff changeset
   184
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   185
(* getenv *)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   186
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   187
fun getenv var =
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   188
  (case OS.Process.getEnv var of
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   189
    NONE => ""
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   190
  | SOME txt => txt);