4 Runtime compilation and evaluation -- generic version. |
4 Runtime compilation and evaluation -- generic version. |
5 *) |
5 *) |
6 |
6 |
7 signature ML_COMPILER = |
7 signature ML_COMPILER = |
8 sig |
8 sig |
9 type flags = {SML: bool, verbose: bool} |
9 type flags = {SML: bool, redirect: bool, verbose: bool} |
|
10 val flags: flags |
|
11 val verbose: bool -> flags -> flags |
10 val eval: flags -> Position.T -> ML_Lex.token list -> unit |
12 val eval: flags -> Position.T -> ML_Lex.token list -> unit |
11 end |
13 end |
12 |
14 |
13 structure ML_Compiler: ML_COMPILER = |
15 structure ML_Compiler: ML_COMPILER = |
14 struct |
16 struct |
15 |
17 |
16 type flags = {SML: bool, verbose: bool}; |
18 type flags = {SML: bool, redirect: bool, verbose: bool}; |
|
19 val flags = {SML = false, redirect = false, verbose = false}; |
|
20 fun verbose v (flags: flags) = {SML = #SML flags, redirect = #redirect flags, verbose = v}; |
17 |
21 |
18 fun eval {SML, verbose} pos toks = |
22 fun eval (flags: flags) pos toks = |
19 let |
23 let |
20 val _ = if SML then error ("Standard ML is unsupported on " ^ ML_System.name) else (); |
24 val _ = if #SML flags then error ("Standard ML is unsupported on " ^ ML_System.name) else (); |
21 val line = the_default 1 (Position.line_of pos); |
25 val line = the_default 1 (Position.line_of pos); |
22 val file = the_default "ML" (Position.file_of pos); |
26 val file = the_default "ML" (Position.file_of pos); |
23 val text = ML_Lex.flatten toks; |
27 val text = ML_Lex.flatten toks; |
24 in Secure.use_text ML_Env.local_context (line, file) verbose text end; |
28 in Secure.use_text ML_Env.local_context (line, file) (#verbose flags) text end; |
25 |
29 |
26 end; |
30 end; |
27 |
31 |