author | wenzelm |
Mon, 31 Mar 2008 23:08:55 +0200 | |
changeset 26504 | 6e87c0a60104 |
parent 26474 | 94735cff132c |
child 26884 | 67c54c53da28 |
permissions | -rw-r--r-- |
4403 | 1 |
(* Title: Pure/ML-Systems/smlnj.ML |
2 |
ID: $Id$ |
|
3 |
||
5708 | 4 |
Compatibility file for Standard ML of New Jersey 110 or later. |
4403 | 5 |
*) |
6 |
||
24599
7b0ecf9a9055
use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents:
24329
diff
changeset
|
7 |
use "ML-Systems/proper_int.ML"; |
7b0ecf9a9055
use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents:
24329
diff
changeset
|
8 |
use "ML-Systems/overloading_smlnj.ML"; |
23965
f93e509659c1
ML-Systems/exn.ML, ML-Systems/multithreading_dummy.ML;
wenzelm
parents:
23921
diff
changeset
|
9 |
use "ML-Systems/exn.ML"; |
25732 | 10 |
use "ML-Systems/universal.ML"; |
24688
a5754ca5c510
replaced interrupt_timeout by TimeLimit.timeLimit (available on SML/NJ and Poly/ML 5.1);
wenzelm
parents:
24599
diff
changeset
|
11 |
use "ML-Systems/multithreading.ML"; |
26220 | 12 |
use "ML-Systems/system_shell.ML"; |
23921
947152add153
added compatibility file for ML systems without multithreading;
wenzelm
parents:
23826
diff
changeset
|
13 |
|
16542 | 14 |
|
15 |
(*low-level pointer equality*) |
|
16502 | 16 |
|
21298
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
17 |
CM.autoload "$smlnj/init/init.cmi"; |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
18 |
val pointer_eq = InlineT.ptreql; |
16528 | 19 |
|
16502 | 20 |
|
4403 | 21 |
(* restore old-style character / string functions *) |
22 |
||
24145 | 23 |
val ord = mk_int o SML90.ord; |
24 |
val chr = SML90.chr o dest_int; |
|
10725 | 25 |
val explode = SML90.explode; |
26 |
val implode = SML90.implode; |
|
4403 | 27 |
|
28 |
||
29 |
(* New Jersey ML parameters *) |
|
30 |
||
31 |
val _ = |
|
21298
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
32 |
(Control.Print.printLength := 1000; |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
33 |
Control.Print.printDepth := 350; |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
34 |
Control.Print.stringDepth := 250; |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
35 |
Control.Print.signatures := 2; |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
36 |
Control.MC.matchRedundantError := false); |
4403 | 37 |
|
38 |
||
39 |
(* Poly/ML emulation *) |
|
40 |
||
24599
7b0ecf9a9055
use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents:
24329
diff
changeset
|
41 |
val exit = exit o dest_int; |
4403 | 42 |
fun quit () = exit 0; |
43 |
||
44 |
(*limit the printing depth -- divided by 2 for comparibility with Poly/ML*) |
|
24329 | 45 |
local |
24599
7b0ecf9a9055
use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents:
24329
diff
changeset
|
46 |
val depth = ref (10: int); |
24329 | 47 |
in |
48 |
fun get_print_depth () = ! depth; |
|
49 |
fun print_depth n = |
|
50 |
(depth := n; |
|
51 |
Control.Print.printDepth := dest_int n div 2; |
|
52 |
Control.Print.printLength := dest_int n); |
|
53 |
end; |
|
4403 | 54 |
|
26474 | 55 |
|
5816 | 56 |
(* compiler-independent timing functions *) |
4403 | 57 |
|
21298
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
58 |
fun start_timing () = |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
59 |
let val CPUtimer = Timer.startCPUTimer(); |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
60 |
val time = Timer.checkCPUTimer(CPUtimer) |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
61 |
in (CPUtimer,time) end; |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
62 |
|
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
63 |
fun end_timing (CPUtimer, {sys,usr}) = |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
64 |
let open Time (*...for Time.toString, Time.+ and Time.- *) |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
65 |
val {sys=sys2,usr=usr2} = Timer.checkCPUTimer(CPUtimer) |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
66 |
in "User " ^ toString (usr2-usr) ^ |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
67 |
" All "^ toString (sys2-sys + usr2-usr) ^ |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
68 |
" secs" |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
69 |
handle Time => "" |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
70 |
end; |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
71 |
|
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
72 |
fun check_timer timer = |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
73 |
let |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
74 |
val {sys, usr} = Timer.checkCPUTimer timer; |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
75 |
val gc = Timer.checkGCTime timer; (* FIXME already included in usr? *) |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
76 |
in (sys, usr, gc) end; |
4403 | 77 |
|
78 |
||
16660 | 79 |
(*prompts*) |
4977 | 80 |
fun ml_prompts p1 p2 = |
21298
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
81 |
(Control.primaryPrompt := p1; Control.secondaryPrompt := p2); |
4977 | 82 |
|
17511 | 83 |
(*dummy implementation*) |
16681 | 84 |
fun profile (n: int) f x = f x; |
85 |
||
17511 | 86 |
(*dummy implementation*) |
16681 | 87 |
fun exception_trace f = f (); |
4977 | 88 |
|
18384 | 89 |
(*dummy implementation*) |
90 |
fun print x = x; |
|
16681 | 91 |
|
23770 | 92 |
(*dummy implementation*) |
93 |
fun makestring x = "dummy string for SML New Jersey"; |
|
94 |
||
21298
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
95 |
|
24290 | 96 |
(* toplevel pretty printing (see also Pure/pure_setup.ML) *) |
4403 | 97 |
|
21298
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
98 |
fun make_pp path pprint = |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
99 |
let |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
100 |
open PrettyPrint; |
4403 | 101 |
|
21298
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
102 |
fun pp pps obj = |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
103 |
pprint obj |
24145 | 104 |
(string pps, openHOVBox pps o Rel o dest_int, |
105 |
fn wd => break pps {nsp=dest_int wd, offset=0}, fn () => newline pps, |
|
21298
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
106 |
fn () => closeBox pps); |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
107 |
in (path, pp) end; |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
108 |
|
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
109 |
fun install_pp (path, pp) = CompilerPPTable.install_pp path pp; |
4403 | 110 |
|
111 |
||
112 |
(* ML command execution *) |
|
113 |
||
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26220
diff
changeset
|
114 |
fun use_text (tune: string -> string) (line: int, name) (print, err) verbose txt = |
5090 | 115 |
let |
21298
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
116 |
val ref out_orig = Control.Print.out; |
5090 | 117 |
|
118 |
val out_buffer = ref ([]: string list); |
|
119 |
val out = {say = (fn s => out_buffer := s :: ! out_buffer), flush = (fn () => ())}; |
|
10914 | 120 |
fun output () = |
7890 | 121 |
let val str = implode (rev (! out_buffer)) |
10914 | 122 |
in String.substring (str, 0, Int.max (0, size str - 1)) end; |
5090 | 123 |
in |
21298
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
124 |
Control.Print.out := out; |
24599
7b0ecf9a9055
use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents:
24329
diff
changeset
|
125 |
Backend.Interact.useStream (TextIO.openString (tune txt)) handle exn => |
22144 | 126 |
(Control.Print.out := out_orig; |
127 |
err ((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
|
128 |
Control.Print.out := out_orig; |
10914 | 129 |
if verbose then print (output ()) else () |
5090 | 130 |
end; |
4403 | 131 |
|
24599
7b0ecf9a9055
use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents:
24329
diff
changeset
|
132 |
fun use_file tune output verbose name = |
7b0ecf9a9055
use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents:
24329
diff
changeset
|
133 |
let |
7b0ecf9a9055
use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents:
24329
diff
changeset
|
134 |
val instream = TextIO.openIn name; |
26504 | 135 |
val txt = Exn.release (Exn.capture TextIO.inputAll instream before TextIO.closeIn instream); |
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26220
diff
changeset
|
136 |
in use_text tune (1, name) output verbose txt end; |
21770 | 137 |
|
26474 | 138 |
fun forget_structure name = |
139 |
use_text (fn x => x) (1, "ML") (TextIO.print, fn s => raise Fail s) false |
|
140 |
("structure " ^ name ^ " = struct end"); |
|
141 |
||
21770 | 142 |
|
4403 | 143 |
|
5816 | 144 |
(** interrupts **) |
145 |
||
12990 | 146 |
exception Interrupt; |
147 |
||
26084
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
148 |
local |
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
149 |
|
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
150 |
fun change_signal new_handler f x = |
5816 | 151 |
let |
26084
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
152 |
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
|
153 |
val result = Exn.capture (f old_handler) x; |
12990 | 154 |
val _ = Signals.setHandler (Signals.sigINT, old_handler); |
23965
f93e509659c1
ML-Systems/exn.ML, ML-Systems/multithreading_dummy.ML;
wenzelm
parents:
23921
diff
changeset
|
155 |
in Exn.release result end; |
5816 | 156 |
|
26084
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
157 |
in |
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
158 |
|
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
159 |
fun interruptible (f: 'a -> 'b) x = |
12990 | 160 |
let |
26084
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
161 |
val result = ref (Exn.Exn Interrupt: 'b Exn.result); |
12990 | 162 |
val old_handler = Signals.inqHandler Signals.sigINT; |
5816 | 163 |
in |
12990 | 164 |
SMLofNJ.Cont.callcc (fn cont => |
26084
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
165 |
(Signals.setHandler (Signals.sigINT, Signals.HANDLER (fn _ => cont)); |
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
166 |
result := Exn.capture f x)); |
12990 | 167 |
Signals.setHandler (Signals.sigINT, old_handler); |
26084
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
168 |
Exn.release (! result) |
12990 | 169 |
end; |
5816 | 170 |
|
26084
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
171 |
fun uninterruptible f = |
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
172 |
change_signal Signals.IGNORE |
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
173 |
(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
|
174 |
|
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
175 |
end; |
a7475459c740
replaced ignore/raise_interrupt by more flexible (un)interruptible combinators;
wenzelm
parents:
25732
diff
changeset
|
176 |
|
21298
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
177 |
|
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
178 |
(* basis library fixes *) |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
179 |
|
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
180 |
structure TextIO = |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
181 |
struct |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
182 |
open TextIO; |
23139
aa899bce7c3b
TextIO.inputLine: use present SML B library version;
wenzelm
parents:
22144
diff
changeset
|
183 |
fun inputLine is = TextIO.inputLine is |
21298
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
184 |
handle IO.Io _ => raise Interrupt; |
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
185 |
end; |
17511 | 186 |
|
18790
418131f631fc
interrupt_timeout now raises Interrupt instead of SML90.Interrupt
webertj
parents:
18760
diff
changeset
|
187 |
|
16542 | 188 |
(** Signal handling: emulation of the Poly/ML Signal structure. Note that types |
15702
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
189 |
Posix.Signal.signal and Signals.signal differ **) |
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
190 |
|
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
191 |
structure IsaSignal = |
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
192 |
struct |
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
193 |
|
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
194 |
datatype sig_handle = SIG_DFL | SIG_IGN | SIG_HANDLE of Signals.signal -> unit; |
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
195 |
|
16542 | 196 |
(*From the SML/NJ documentation: "HANDLER(f) installs a handler for a |
197 |
signal. When signal is delivered to the process, the execution state |
|
198 |
of the current thread will be bundled up as a continuation k, then |
|
199 |
f(signal,n,k) will be called. The number n is the number of times |
|
200 |
signal has been signalled since the last time f was invoked for it."*) |
|
15702
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
201 |
|
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
202 |
fun toAction SIG_DFL = Signals.DEFAULT |
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
203 |
| toAction SIG_IGN = Signals.IGNORE |
16542 | 204 |
| toAction (SIG_HANDLE iu) = |
15702
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
205 |
Signals.HANDLER (fn (signo,_,cont) => (iu signo; cont)); |
16542 | 206 |
|
15702
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
207 |
(*The types are correct, but I'm not sure about the semantics!*) |
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
208 |
fun fromAction Signals.DEFAULT = SIG_DFL |
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
209 |
| fromAction Signals.IGNORE = SIG_IGN |
16542 | 210 |
| fromAction (Signals.HANDLER f) = |
15702
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
211 |
SIG_HANDLE (fn signo => SMLofNJ.Cont.callcc (fn k => (f (signo,0,k); ()))); |
16542 | 212 |
|
15702
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
213 |
(*Poly/ML version has type int * sig_handle -> sig_handle*) |
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
214 |
fun signal (signo, sh) = fromAction (Signals.setHandler (signo, toAction sh)); |
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
215 |
|
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
216 |
val usr1 = UnixSignals.sigUSR1 |
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
217 |
val usr2 = UnixSignals.sigUSR2 |
17763 | 218 |
val alrm = UnixSignals.sigALRM |
219 |
val chld = UnixSignals.sigCHLD |
|
220 |
val cont = UnixSignals.sigCONT |
|
221 |
val int = UnixSignals.sigINT |
|
222 |
val quit = UnixSignals.sigQUIT |
|
223 |
val term = UnixSignals.sigTERM |
|
15702
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
224 |
|
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
14981
diff
changeset
|
225 |
end; |
5816 | 226 |
|
227 |
||
4403 | 228 |
(** OS related **) |
229 |
||
23826
463903573934
moved cd/pwd to ML compatibility layer (simplifies bootstrapping with Alice);
wenzelm
parents:
23770
diff
changeset
|
230 |
(* current directory *) |
463903573934
moved cd/pwd to ML compatibility layer (simplifies bootstrapping with Alice);
wenzelm
parents:
23770
diff
changeset
|
231 |
|
463903573934
moved cd/pwd to ML compatibility layer (simplifies bootstrapping with Alice);
wenzelm
parents:
23770
diff
changeset
|
232 |
val cd = OS.FileSys.chDir; |
463903573934
moved cd/pwd to ML compatibility layer (simplifies bootstrapping with Alice);
wenzelm
parents:
23770
diff
changeset
|
233 |
val pwd = OS.FileSys.getDir; |
463903573934
moved cd/pwd to ML compatibility layer (simplifies bootstrapping with Alice);
wenzelm
parents:
23770
diff
changeset
|
234 |
|
463903573934
moved cd/pwd to ML compatibility layer (simplifies bootstrapping with Alice);
wenzelm
parents:
23770
diff
changeset
|
235 |
|
4403 | 236 |
(* system command execution *) |
237 |
||
26220 | 238 |
val system_out = (fn (output, rc) => (output, mk_int rc)) o system_out; |
7855 | 239 |
|
4403 | 240 |
|
17824 | 241 |
(*Convert a process ID to a decimal string (chiefly for tracing)*) |
21298
6d2306b2376d
tuned names of start_timing,/end_timing/check_timer;
wenzelm
parents:
18790
diff
changeset
|
242 |
fun string_of_pid pid = |
26220 | 243 |
Word.fmt StringCvt.DEC (Word.fromLargeWord (Posix.Process.pidToWord pid)); |
17824 | 244 |
|
245 |
||
4403 | 246 |
(* getenv *) |
247 |
||
248 |
fun getenv var = |
|
249 |
(case OS.Process.getEnv var of |
|
250 |
NONE => "" |
|
251 |
| SOME txt => txt); |