src/Tools/Code/code_target.ML
changeset 34173 458ced35abb8
parent 34152 8e5b596d8c73
child 34248 6fb7dd3fd81a
equal deleted inserted replaced
34172:4301e9ea1c54 34173:458ced35abb8
   354     val names4 = transitivly_non_empty_funs thy naming program;
   354     val names4 = transitivly_non_empty_funs thy naming program;
   355     val cs5 = map_filter
   355     val cs5 = map_filter
   356       (fn (c, name) => if member (op =) names4 name then SOME c else NONE) (cs2 ~~ names3);
   356       (fn (c, name) => if member (op =) names4 name then SOME c else NONE) (cs2 ~~ names3);
   357   in fold (insert (op =)) cs5 cs1 end;
   357   in fold (insert (op =)) cs5 cs1 end;
   358 
   358 
   359 fun cached_program thy = 
       
   360   let
       
   361     val (naming, program) = Code_Thingol.cached_program thy;
       
   362   in (transitivly_non_empty_funs thy naming program, (naming, program)) end
       
   363 
       
   364 fun export_code thy cs seris =
   359 fun export_code thy cs seris =
   365   let
   360   let
   366     val (cs', (naming, program)) = if null cs then cached_program thy
   361     val (cs', (naming, program)) = Code_Thingol.consts_program thy cs;
   367       else Code_Thingol.consts_program thy cs;
       
   368     fun mk_seri_dest dest = case dest
   362     fun mk_seri_dest dest = case dest
   369      of NONE => compile
   363      of NONE => compile
   370       | SOME "-" => export
   364       | SOME "-" => export
   371       | SOME f => file (Path.explode f)
   365       | SOME f => file (Path.explode f)
   372     val _ = map (fn (((target, module), dest), args) =>
   366     val _ = map (fn (((target, module), dest), args) =>
   512 (** Isar setup **)
   506 (** Isar setup **)
   513 
   507 
   514 val (inK, module_nameK, fileK) = ("in", "module_name", "file");
   508 val (inK, module_nameK, fileK) = ("in", "module_name", "file");
   515 
   509 
   516 val code_exprP =
   510 val code_exprP =
   517   (Scan.repeat P.term_group
   511   (Scan.repeat1 P.term_group
   518   -- Scan.repeat (P.$$$ inK |-- P.name
   512   -- Scan.repeat (P.$$$ inK |-- P.name
   519      -- Scan.option (P.$$$ module_nameK |-- P.name)
   513      -- Scan.option (P.$$$ module_nameK |-- P.name)
   520      -- Scan.option (P.$$$ fileK |-- P.name)
   514      -- Scan.option (P.$$$ fileK |-- P.name)
   521      -- Scan.optional (P.$$$ "(" |-- Args.parse --| P.$$$ ")") []
   515      -- Scan.optional (P.$$$ "(" |-- Args.parse --| P.$$$ ")") []
   522   ) >> (fn (raw_cs, seris) => export_code_cmd raw_cs seris));
   516   ) >> (fn (raw_cs, seris) => export_code_cmd raw_cs seris));