src/Tools/Code/code_runtime.ML
changeset 56069 451d5b73f8cf
parent 55757 9fc71814b8c1
child 56205 ceb8a93460b7
equal deleted inserted replaced
56068:f74d0a4d8ae3 56069:451d5b73f8cf
   255     val body = "Isabelle." ^ the (AList.lookup (op =) consts_map const);
   255     val body = "Isabelle." ^ the (AList.lookup (op =) consts_map const);
   256   in (ml_code, body) end;
   256   in (ml_code, body) end;
   257 
   257 
   258 in
   258 in
   259 
   259 
   260 fun ml_code_antiq context raw_const =
   260 fun ml_code_antiq raw_const ctxt =
   261   let
   261   let
   262     val ctxt = Context.the_proof context;
       
   263     val thy = Proof_Context.theory_of ctxt;
   262     val thy = Proof_Context.theory_of ctxt;
   264 
       
   265     val const = Code.check_const thy raw_const;
   263     val const = Code.check_const thy raw_const;
   266     val is_first = is_first_occ ctxt;
   264     val is_first = is_first_occ ctxt;
   267     val ctxt' = register_const const ctxt;
   265   in (print_code is_first const, register_const const ctxt) end;
   268   in (Context.Proof ctxt', print_code is_first const) end;
       
   269 
   266 
   270 end; (*local*)
   267 end; (*local*)
   271 
   268 
   272 
   269 
   273 (* reflection support *)
   270 (* reflection support *)
   354 val code_reflect_cmd = gen_code_reflect Code_Target.read_tyco Code.read_const;
   351 val code_reflect_cmd = gen_code_reflect Code_Target.read_tyco Code.read_const;
   355 
   352 
   356 
   353 
   357 (** Isar setup **)
   354 (** Isar setup **)
   358 
   355 
   359 val _ = Theory.setup
   356 val _ =
   360   (ML_Context.add_antiq @{binding code}
   357   Theory.setup (ML_Context.antiquotation @{binding code} Args.term (fn _ => ml_code_antiq));
   361     (Scan.depend (fn context => Scan.pass context Args.term >> ml_code_antiq context)));
       
   362 
   358 
   363 local
   359 local
   364 
   360 
   365 val parse_datatype =
   361 val parse_datatype =
   366   Parse.name --| @{keyword "="} --
   362   Parse.name --| @{keyword "="} --