src/Tools/Code/code_runtime.ML
changeset 56920 d651b944c67e
parent 56618 874bdedb2313
child 56969 7491932da574
equal deleted inserted replaced
56919:6389a8c1268a 56920:d651b944c67e
   110   let
   110   let
   111     val _ = reject_vars ctxt t;
   111     val _ = reject_vars ctxt t;
   112     val _ = if ! trace
   112     val _ = if ! trace
   113       then tracing ("Evaluation of term " ^ quote (Syntax.string_of_term ctxt t))
   113       then tracing ("Evaluation of term " ^ quote (Syntax.string_of_term ctxt t))
   114       else ()
   114       else ()
   115     fun evaluator program ((_, vs_ty), t) deps =
   115     fun evaluator program _ vs_ty_t deps =
   116       evaluation cookie ctxt (obtain_evaluator ctxt some_target program deps) (vs_ty, t) args;
   116       evaluation cookie ctxt (obtain_evaluator ctxt some_target program deps) vs_ty_t args;
   117   in Code_Thingol.dynamic_value ctxt (Exn.map_result o postproc) evaluator t end;
   117   in Code_Thingol.dynamic_value ctxt (Exn.map_result o postproc) evaluator t end;
   118 
   118 
   119 fun dynamic_value_strict cookie ctxt some_target postproc t args =
   119 fun dynamic_value_strict cookie ctxt some_target postproc t args =
   120   Exn.release (dynamic_value_exn cookie ctxt some_target postproc t args);
   120   Exn.release (dynamic_value_exn cookie ctxt some_target postproc t args);
   121 
   121 
   124 
   124 
   125 fun static_evaluator cookie ctxt some_target program consts' =
   125 fun static_evaluator cookie ctxt some_target program consts' =
   126   let
   126   let
   127     val evaluator = obtain_evaluator ctxt some_target program (map Constant consts');
   127     val evaluator = obtain_evaluator ctxt some_target program (map Constant consts');
   128     val evaluation' = evaluation cookie ctxt evaluator;
   128     val evaluation' = evaluation cookie ctxt evaluator;
   129   in fn _ => fn ((_, vs_ty), t) => fn _ => evaluation' (vs_ty, t) [] end;
   129   in fn _ => fn _ => fn vs_ty_t => fn _ => evaluation' vs_ty_t [] end;
   130 
   130 
   131 fun static_value_exn cookie ctxt some_target postproc consts =
   131 fun static_value_exn cookie ctxt some_target postproc consts =
   132   let
   132   let
   133     val evaluator = Code_Thingol.static_value ctxt (Exn.map_result o postproc) consts
   133     val evaluator = Code_Thingol.static_value ctxt (Exn.map_result o postproc) consts
   134       (static_evaluator cookie ctxt some_target);
   134       (static_evaluator cookie ctxt some_target);
   173 
   173 
   174 val (_, raw_check_holds_oracle) = Context.>>> (Context.map_theory_result
   174 val (_, raw_check_holds_oracle) = Context.>>> (Context.map_theory_result
   175   (Thm.add_oracle (@{binding holds_by_evaluation},
   175   (Thm.add_oracle (@{binding holds_by_evaluation},
   176   fn (ctxt, evaluator, vs_t, ct) => check_holds ctxt evaluator vs_t ct)));
   176   fn (ctxt, evaluator, vs_t, ct) => check_holds ctxt evaluator vs_t ct)));
   177 
   177 
   178 fun check_holds_oracle ctxt evaluator ((_, vs_ty), t) deps ct =
   178 fun check_holds_oracle ctxt evaluator vs_ty_t ct =
   179   raw_check_holds_oracle (ctxt, evaluator, (vs_ty, t), ct);
   179   raw_check_holds_oracle (ctxt, evaluator, vs_ty_t, ct);
   180 
   180 
   181 in
   181 in
   182 
   182 
   183 fun dynamic_holds_conv ctxt = Code_Thingol.dynamic_conv ctxt
   183 fun dynamic_holds_conv ctxt = Code_Thingol.dynamic_conv ctxt
   184   (fn program => fn vs_t => fn deps =>
   184   (fn program => fn _ => fn vs_t => fn deps =>
   185     check_holds_oracle ctxt (obtain_evaluator ctxt NONE program deps) vs_t deps)
   185     check_holds_oracle ctxt (obtain_evaluator ctxt NONE program deps) vs_t)
   186       o reject_vars ctxt;
   186       o reject_vars ctxt;
   187 
   187 
   188 fun static_holds_conv ctxt consts =
   188 fun static_holds_conv ctxt consts =
   189   Code_Thingol.static_conv ctxt consts (fn program => fn consts' =>
   189   Code_Thingol.static_conv ctxt consts (fn program => fn consts' =>
   190     let
   190     let
   191       val evaluator' = obtain_evaluator ctxt NONE program (map Constant consts')
   191       val evaluator' = obtain_evaluator ctxt NONE program (map Constant consts')
   192     in
   192     in
   193       fn ctxt' => fn vs_t => fn deps => check_holds_oracle ctxt' evaluator' vs_t deps o reject_vars ctxt'
   193       fn ctxt' => fn _ => fn vs_t => fn _ => check_holds_oracle ctxt' evaluator' vs_t o reject_vars ctxt'
   194     end);
   194     end);
   195 
   195 
   196 (* o reject_vars ctxt'*)
   196 (* o reject_vars ctxt'*)
   197 
   197 
   198 end; (*local*)
   198 end; (*local*)