| author | wenzelm | 
| Sun, 04 Jan 2009 15:28:40 +0100 | |
| changeset 29345 | 5904873d8f11 | 
| parent 28268 | ac8431ecd57e | 
| child 29564 | f8b933a62151 | 
| 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: 
26382diff
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 | |
| 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: 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 | |
| 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 = | 
| 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); | 
| 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; |