34 val export: serialization -> unit |
34 val export: serialization -> unit |
35 val file: Path.T -> serialization -> unit |
35 val file: Path.T -> serialization -> unit |
36 val string: string list -> serialization -> string |
36 val string: string list -> serialization -> string |
37 val code_of: theory -> string -> int option -> string |
37 val code_of: theory -> string -> int option -> string |
38 -> string list -> (Code_Thingol.naming -> string list) -> string |
38 -> string list -> (Code_Thingol.naming -> string list) -> string |
|
39 val external_check: theory -> string -> string |
|
40 -> (Path.T -> Path.T) -> (string -> Path.T -> string -> string) -> Path.T -> unit |
39 val set_default_code_width: int -> theory -> theory |
41 val set_default_code_width: int -> theory -> theory |
40 val shell_command: string (*theory name*) -> string (*export_code expr*) -> unit |
42 val shell_command: string (*theory name*) -> string (*export_code expr*) -> unit |
41 |
43 |
42 val allow_abort: string -> theory -> theory |
44 val allow_abort: string -> theory -> theory |
43 type tyco_syntax = Code_Printer.tyco_syntax |
45 type tyco_syntax = Code_Printer.tyco_syntax |
353 val names3 = transitivly_non_empty_funs thy naming program; |
355 val names3 = transitivly_non_empty_funs thy naming program; |
354 val cs3 = map_filter (fn (c, name) => |
356 val cs3 = map_filter (fn (c, name) => |
355 if member (op =) names3 name then SOME c else NONE) (cs2 ~~ names2); |
357 if member (op =) names3 name then SOME c else NONE) (cs2 ~~ names2); |
356 in union (op =) cs3 cs1 end; |
358 in union (op =) cs3 cs1 end; |
357 |
359 |
|
360 fun external_check thy target env_var make_destination make_command p = |
|
361 let |
|
362 val env_param = getenv env_var; |
|
363 fun ext_check env_param = |
|
364 let |
|
365 val module_name = "Code_Test"; |
|
366 val (cs, (naming, program)) = |
|
367 Code_Thingol.consts_program thy false (read_const_exprs thy ["*"]); |
|
368 val destination = make_destination p; |
|
369 val _ = file destination (serialize thy target (SOME 80) |
|
370 (SOME module_name) [] naming program cs); |
|
371 val cmd = make_command env_param destination module_name; |
|
372 in if bash ("cd " ^ File.shell_path p ^ " && " ^ cmd) <> 0 |
|
373 then error ("Code check failed for " ^ target ^ ": " ^ cmd) |
|
374 else () |
|
375 end; |
|
376 in if env_param = "" |
|
377 then warning (env_var ^ " not set; skipped code check for " ^ target) |
|
378 else ext_check env_param |
|
379 end; |
|
380 |
358 fun export_code thy cs seris = |
381 fun export_code thy cs seris = |
359 let |
382 let |
360 val (cs', (naming, program)) = Code_Thingol.consts_program thy false cs; |
383 val (cs', (naming, program)) = Code_Thingol.consts_program thy false cs; |
361 fun mk_seri_dest dest = case dest |
384 fun mk_seri_dest dest = case dest |
362 of NONE => compile |
385 of NONE => compile |