author | wenzelm |
Mon, 31 Mar 2008 23:08:55 +0200 | |
changeset 26504 | 6e87c0a60104 |
parent 26390 | 99d4cbb1f941 |
child 26625 | e0cc4169626e |
permissions | -rw-r--r-- |
2341 | 1 |
(* Title: Pure/ML-Systems/polyml.ML |
2 |
ID: $Id$ |
|
3 |
||
26379 | 4 |
Compatibility wrapper for Poly/ML (after 5.1). |
2341 | 5 |
*) |
6 |
||
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
26084
diff
changeset
|
7 |
use "ML-Systems/polyml_common.ML"; |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
26084
diff
changeset
|
8 |
use "ML-Systems/multithreading_polyml.ML"; |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
26084
diff
changeset
|
9 |
|
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
26084
diff
changeset
|
10 |
val pointer_eq = PolyML.pointerEq; |
23921
947152add153
added compatibility file for ML systems without multithreading;
wenzelm
parents:
23826
diff
changeset
|
11 |
|
25023 | 12 |
|
26390
99d4cbb1f941
moved multithreaded "profile" to multithreading_polyml.ML;
wenzelm
parents:
26385
diff
changeset
|
13 |
(* runtime compilation *) |
3588 | 14 |
|
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26379
diff
changeset
|
15 |
fun use_text (tune: string -> string) (line, name) (print, err) verbose txt = |
3588 | 16 |
let |
26379 | 17 |
val in_buffer = ref (String.explode (tune txt)); |
5090 | 18 |
val out_buffer = ref ([]: string list); |
21715 | 19 |
fun output () = implode (rev (case ! out_buffer of "\n" :: cs => cs | cs => cs)); |
5090 | 20 |
|
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26379
diff
changeset
|
21 |
val current_line = ref line; |
5038 | 22 |
fun get () = |
5090 | 23 |
(case ! in_buffer of |
26379 | 24 |
[] => NONE |
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26379
diff
changeset
|
25 |
| c :: cs => |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26379
diff
changeset
|
26 |
(in_buffer := cs; if c = #"\n" then current_line := ! current_line + 1 else (); SOME c)); |
5090 | 27 |
fun put s = out_buffer := s :: ! out_buffer; |
28 |
||
26379 | 29 |
val _ = |
30 |
(while not (List.null (! in_buffer)) do |
|
31 |
PolyML.compiler |
|
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26379
diff
changeset
|
32 |
{getChar = get, putString = put, lineNumber = fn () => ! current_line, fileName = name, |
26379 | 33 |
nameSpace = PolyML.globalNameSpace} ()) |
34 |
handle exn => (err (output ()); raise exn); |
|
5090 | 35 |
in |
10914 | 36 |
if verbose then print (output ()) else () |
5090 | 37 |
end; |
3588 | 38 |
|
24598 | 39 |
fun use_file tune output verbose name = |
40 |
let |
|
41 |
val instream = TextIO.openIn name; |
|
26504 | 42 |
val txt = Exn.release (Exn.capture TextIO.inputAll instream before TextIO.closeIn instream); |
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26379
diff
changeset
|
43 |
in use_text tune (1, name) output verbose txt end; |
26379 | 44 |