src/Tools/Code/code_runtime.ML
changeset 42359 6ca5407863ed
parent 41944 b97091ae583a
child 42361 23f352990944
equal deleted inserted replaced
42358:b47d41d9f4b5 42359:6ca5407863ed
   186 
   186 
   187 (** instrumentalization **)
   187 (** instrumentalization **)
   188 
   188 
   189 fun evaluation_code thy module_name tycos consts =
   189 fun evaluation_code thy module_name tycos consts =
   190   let
   190   let
       
   191     val ctxt = ProofContext.init_global thy;
   191     val (consts', (naming, program)) = Code_Thingol.consts_program thy false consts;
   192     val (consts', (naming, program)) = Code_Thingol.consts_program thy false consts;
   192     val tycos' = map (the o Code_Thingol.lookup_tyco naming) tycos;
   193     val tycos' = map (the o Code_Thingol.lookup_tyco naming) tycos;
   193     val (ml_code, target_names) = Code_Target.produce_code_for thy
   194     val (ml_code, target_names) =
   194       target NONE module_name [] naming program (consts' @ tycos');
   195       Code_Target.produce_code_for thy
       
   196         target NONE module_name [] naming program (consts' @ tycos');
   195     val (consts'', tycos'') = chop (length consts') target_names;
   197     val (consts'', tycos'') = chop (length consts') target_names;
   196     val consts_map = map2 (fn const => fn NONE =>
   198     val consts_map = map2 (fn const =>
   197         error ("Constant " ^ (quote o Code.string_of_const thy) const
   199       fn NONE =>
   198           ^ "\nhas a user-defined serialization")
   200           error ("Constant " ^ (quote o Code.string_of_const thy) const ^
   199       | SOME const'' => (const, const'')) consts consts''
   201             "\nhas a user-defined serialization")
   200     val tycos_map = map2 (fn tyco => fn NONE =>
   202        | SOME const'' => (const, const'')) consts consts''
   201         error ("Type " ^ (quote o Sign.extern_type thy) tyco
   203     val tycos_map = map2 (fn tyco =>
   202           ^ "\nhas a user-defined serialization")
   204       fn NONE =>
   203       | SOME tyco'' => (tyco, tyco'')) tycos tycos'';
   205           error ("Type " ^ quote (ProofContext.extern_type ctxt tyco) ^
       
   206             "\nhas a user-defined serialization")
       
   207         | SOME tyco'' => (tyco, tyco'')) tycos tycos'';
   204   in (ml_code, (tycos_map, consts_map)) end;
   208   in (ml_code, (tycos_map, consts_map)) end;
   205 
   209 
   206 
   210 
   207 (* by antiquotation *)
   211 (* by antiquotation *)
   208 
   212