| author | wenzelm | 
| Sun, 04 Jan 2009 15:28:40 +0100 | |
| changeset 29345 | 5904873d8f11 | 
| parent 28268 | ac8431ecd57e | 
| child 29564 | f8b933a62151 | 
| permissions | -rw-r--r-- | 
| 26383 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 1 | (* Title: Pure/ML-Systems/polyml_old_compiler5.ML | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 2 | ID: $Id$ | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 3 | |
| 26385 
ae7564661e76
ML runtime compilation: pass position, tuned signature;
 wenzelm parents: 
26383diff
changeset | 4 | Runtime compilation -- for old PolyML.compilerEx (version 5.0, 5.1). | 
| 26383 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 5 | *) | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 6 | |
| 28268 
ac8431ecd57e
use_text/use_file now depend on explicit ML name space;
 wenzelm parents: 
26885diff
changeset | 7 | fun use_text (tune: string -> string) _ _ (line, name) (print, err) verbose txt = | 
| 26383 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 8 | let | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 9 | val in_buffer = ref (explode (tune txt)); | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 10 | val out_buffer = ref ([]: string list); | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 11 | fun output () = implode (rev (case ! out_buffer of "\n" :: cs => cs | cs => cs)); | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 12 | |
| 26385 
ae7564661e76
ML runtime compilation: pass position, tuned signature;
 wenzelm parents: 
26383diff
changeset | 13 | val current_line = ref line; | 
| 26383 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 14 | fun get () = | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 15 | (case ! in_buffer of | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 16 | [] => "" | 
| 26385 
ae7564661e76
ML runtime compilation: pass position, tuned signature;
 wenzelm parents: 
26383diff
changeset | 17 | | c :: cs => (in_buffer := cs; if c = "\n" then current_line := ! current_line + 1 else (); c)); | 
| 26383 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 18 | fun put s = out_buffer := s :: ! out_buffer; | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 19 | |
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 20 | fun exec () = | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 21 | (case ! in_buffer of | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 22 | [] => () | 
| 26385 
ae7564661e76
ML runtime compilation: pass position, tuned signature;
 wenzelm parents: 
26383diff
changeset | 23 | | _ => (PolyML.compilerEx (get, put, fn () => ! current_line, name) (); exec ())); | 
| 26383 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 24 | in | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 25 | exec () handle exn => (err (output ()); raise exn); | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 26 | if verbose then print (output ()) else () | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 27 | end; | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 28 | |
| 28268 
ac8431ecd57e
use_text/use_file now depend on explicit ML name space;
 wenzelm parents: 
26885diff
changeset | 29 | fun use_file tune str_of_pos name_space output verbose name = | 
| 26383 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 wenzelm parents: diff
changeset | 30 | let | 
| 
08da16c3f124
Runtime compilation -- for old version of PolyML.compilerEx (version 5.0, 5.1).
 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); | 
| 28268 
ac8431ecd57e
use_text/use_file now depend on explicit ML name space;
 wenzelm parents: 
26885diff
changeset | 33 | in use_text tune str_of_pos name_space (1, name) output verbose txt end; |