src/Tools/Code/code_runtime.ML
changeset 44663 3bc39cfe27fe
parent 43619 3803869014aa
child 45268 a42624e9de09
equal deleted inserted replaced
44655:fe0365331566 44663:3bc39cfe27fe
    45 val this = "Code_Runtime";
    45 val this = "Code_Runtime";
    46 val s_truth = Long_Name.append this "truth";
    46 val s_truth = Long_Name.append this "truth";
    47 val s_Holds = Long_Name.append this "Holds";
    47 val s_Holds = Long_Name.append this "Holds";
    48 
    48 
    49 val target = "Eval";
    49 val target = "Eval";
       
    50 val structure_generated = "Generated_Code";
    50 
    51 
    51 datatype truth = Holds;
    52 datatype truth = Holds;
    52 
    53 
    53 val _ = Context.>> (Context.map_theory
    54 val _ = Context.>> (Context.map_theory
    54   (Code_Target.extend_target (target, (Code_ML.target_SML, K I))
    55   (Code_Target.extend_target (target, (Code_ML.target_SML, K I))
   225   let
   226   let
   226     val ((tycos, consts), _) = Code_Antiq_Data.get ctxt;
   227     val ((tycos, consts), _) = Code_Antiq_Data.get ctxt;
   227     val tycos' = fold (insert (op =)) new_tycos tycos;
   228     val tycos' = fold (insert (op =)) new_tycos tycos;
   228     val consts' = fold (insert (op =)) new_consts consts;
   229     val consts' = fold (insert (op =)) new_consts consts;
   229     val acc_code = Lazy.lazy (fn () =>
   230     val acc_code = Lazy.lazy (fn () =>
   230       evaluation_code (Proof_Context.theory_of ctxt) "Code" tycos' consts'
   231       evaluation_code (Proof_Context.theory_of ctxt) structure_generated tycos' consts'
   231       |> apsnd snd);
   232       |> apsnd snd);
   232   in Code_Antiq_Data.put ((tycos', consts'), (false, acc_code)) ctxt end;
   233   in Code_Antiq_Data.put ((tycos', consts'), (false, acc_code)) ctxt end;
   233 
   234 
   234 fun register_const const = register_code [] [const];
   235 fun register_const const = register_code [] [const];
   235 
   236 
   432   |> Code_Target.add_reserved target ml_name
   433   |> Code_Target.add_reserved target ml_name
   433   |> Specification.axiomatization [(b, SOME T, NoSyn)] []
   434   |> Specification.axiomatization [(b, SOME T, NoSyn)] []
   434   |-> (fn ([Const (const, _)], _) =>
   435   |-> (fn ([Const (const, _)], _) =>
   435      Code_Target.add_const_syntax target const
   436      Code_Target.add_const_syntax target const
   436        (SOME (Code_Printer.simple_const_syntax (0, (K o K o K o Code_Printer.str) ml_name)))
   437        (SOME (Code_Printer.simple_const_syntax (0, (K o K o K o Code_Printer.str) ml_name)))
   437   #> tap (fn thy => Code_Target.produce_code thy [const] target NONE "Code" []));
   438   #> tap (fn thy => Code_Target.produce_code thy [const] target NONE structure_generated []));
   438 
   439 
   439 fun process_file filepath (definienda, thy) =
   440 fun process_file filepath (definienda, thy) =
   440   let
   441   let
   441     val (ml_names, thy') = use_file filepath thy;
   442     val (ml_names, thy') = use_file filepath thy;
   442     val superfluous = subtract (fn ((name1, _), name2) => name1 = name2) definienda ml_names;
   443     val superfluous = subtract (fn ((name1, _), name2) => name1 = name2) definienda ml_names;