| author | wenzelm |
| Mon, 16 Jun 2008 17:54:35 +0200 | |
| changeset 27225 | b316dde851f5 |
| parent 26885 | cfd5eb167706 |
| child 28268 | ac8431ecd57e |
| 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 |
ID: $Id$ |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
3 |
|
|
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26382
diff
changeset
|
4 |
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
|
5 |
*) |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
6 |
|
| 26884 | 7 |
fun use_text (tune: string -> string) _ (line: int, name) (print, err) verbose txt = |
|
26382
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
8 |
let |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
9 |
val in_buffer = ref (explode (tune txt)); |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
10 |
val out_buffer = ref ([]: string list); |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
11 |
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
|
12 |
|
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
13 |
fun get () = |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
14 |
(case ! in_buffer of |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
15 |
[] => "" |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
16 |
| c :: cs => (in_buffer := cs; c)); |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
17 |
fun put s = out_buffer := s :: ! out_buffer; |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
18 |
|
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
19 |
fun exec () = |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
20 |
(case ! in_buffer of |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
21 |
[] => () |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
22 |
| _ => (PolyML.compiler (get, put) (); exec ())); |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
23 |
in |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
24 |
exec () handle exn => |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
25 |
(err ((if name = "" then "" else "Error in " ^ name ^ "\n") ^ output ()); raise exn); |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
26 |
if verbose then print (output ()) else () |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
27 |
end; |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
28 |
|
| 26885 | 29 |
fun use_file tune str_of_pos output verbose name = |
|
26382
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
30 |
let |
|
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
31 |
val instream = TextIO.openIn name; |
| 26504 | 32 |
val txt = Exn.release (Exn.capture TextIO.inputAll instream before TextIO.closeIn instream); |
| 26885 | 33 |
in use_text tune str_of_pos (1, name) output verbose txt end; |
|
26382
16628f5c7e28
Runtime compilation -- for old version of PolyML.compiler (version 4.x).
wenzelm
parents:
diff
changeset
|
34 |