| author | hoelzl |
| Wed, 29 Apr 2009 20:19:50 +0200 | |
| changeset 31098 | 73dd67adf90a |
| parent 30672 | beaadd5af500 |
| permissions | -rw-r--r-- |
|
26382
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
1 |
(* Title: Pure/ML-Systems/polyml_old_compiler4.ML |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
2 |
|
|
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26382
diff
changeset
|
3 |
Runtime compilation -- for old PolyML.compiler (version 4.x). |
|
26382
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
4 |
*) |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
5 |
|
|
30672
beaadd5af500
more systematic type use_context, with particular values ML_Parse.global_context and ML_Context.local_context;
wenzelm
parents:
29564
diff
changeset
|
6 |
fun use_text ({tune_source, print, error, ...}: use_context) (line: int, name) verbose txt =
|
|
26382
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
7 |
let |
|
30672
beaadd5af500
more systematic type use_context, with particular values ML_Parse.global_context and ML_Context.local_context;
wenzelm
parents:
29564
diff
changeset
|
8 |
val in_buffer = ref (explode (tune_source txt)); |
|
26382
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
9 |
val out_buffer = ref ([]: string list); |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
10 |
fun output () = implode (rev (case ! out_buffer of "\n" :: cs => cs | cs => cs)); |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
11 |
|
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
12 |
fun get () = |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
13 |
(case ! in_buffer of |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
14 |
[] => "" |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
15 |
| c :: cs => (in_buffer := cs; c)); |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
16 |
fun put s = out_buffer := s :: ! out_buffer; |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
17 |
|
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
18 |
fun exec () = |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
19 |
(case ! in_buffer of |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
20 |
[] => () |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
21 |
| _ => (PolyML.compiler (get, put) (); exec ())); |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
22 |
in |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
23 |
exec () handle exn => |
|
30672
beaadd5af500
more systematic type use_context, with particular values ML_Parse.global_context and ML_Context.local_context;
wenzelm
parents:
29564
diff
changeset
|
24 |
(error ((if name = "" then "" else "Error in " ^ name ^ "\n") ^ output ()); raise exn); |
|
26382
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
25 |
if verbose then print (output ()) else () |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
26 |
end; |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
27 |
|
|
30672
beaadd5af500
more systematic type use_context, with particular values ML_Parse.global_context and ML_Context.local_context;
wenzelm
parents:
29564
diff
changeset
|
28 |
fun use_file context verbose name = |
|
26382
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
29 |
let |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
30 |
val instream = TextIO.openIn name; |
| 26504 | 31 |
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:
29564
diff
changeset
|
32 |
in use_text context (1, name) verbose txt end; |