equal
deleted
inserted
replaced
291 |
291 |
292 (* driver for PolyML *) |
292 (* driver for PolyML *) |
293 |
293 |
294 val polymlN = "PolyML" |
294 val polymlN = "PolyML" |
295 |
295 |
296 fun evaluate_in_polyml (_: Proof.context) (code_files, value_name) dir = |
296 fun evaluate_in_polyml ctxt (code_files, value_name) dir = |
297 let |
297 let |
298 val compiler = polymlN |
298 val code = #2 (the_single code_files); |
299 val code_path = Path.append dir (Path.basic "generated.sml") |
299 val code_path = Path.append dir (Path.basic "generated.sml") |
300 val driver_path = Path.append dir (Path.basic "driver.sml") |
300 val driver_path = Path.append dir (Path.basic "driver.sml") |
301 val out_path = Path.append dir (Path.basic "out") |
301 val out_path = Path.append dir (Path.basic "out") |
302 val string = ML_Syntax.print_string |
302 val string = ML_Syntax.print_string |
303 val driver = \<^verbatim>\<open> |
303 val driver = \<^verbatim>\<open> |
314 val out = BinIO.openOut \<close> ^ string (Path.implode (Path.expand out_path)) ^ \<^verbatim>\<open> |
314 val out = BinIO.openOut \<close> ^ string (Path.implode (Path.expand out_path)) ^ \<^verbatim>\<open> |
315 val _ = BinIO.output (out, Byte.stringToBytes result_text) |
315 val _ = BinIO.output (out, Byte.stringToBytes result_text) |
316 val _ = BinIO.closeOut out |
316 val _ = BinIO.closeOut out |
317 in () end; |
317 in () end; |
318 \<close> |
318 \<close> |
319 val cmd = |
319 in |
320 "\"$POLYML_EXE\" --use " ^ File.bash_platform_path code_path ^ |
320 if Config.get ctxt debug |
321 " --use " ^ File.bash_platform_path driver_path ^ |
321 then (File.write code_path code; File.write driver_path driver) |
322 " --eval " ^ Bash.string "main ()" |
322 else (); |
323 in |
323 |
324 List.app (File.write code_path o snd) code_files; |
324 ML_Context.eval |
325 File.write driver_path driver; |
325 {environment = ML_Env.SML, redirect = false, verbose = false, debug = NONE, |
326 evaluate compiler cmd; |
326 writeln = writeln, warning = warning} |
|
327 Position.none |
|
328 (ML_Lex.read_text (code, Path.position code_path) @ |
|
329 ML_Lex.read_text (driver, Path.position driver_path) @ |
|
330 ML_Lex.read "main ()"); |
|
331 |
327 File.read out_path |
332 File.read out_path |
328 end |
333 end |
329 |
334 |
330 |
335 |
331 (* driver for mlton *) |
336 (* driver for mlton *) |