82 val group_stmts: Proof.context -> program |
82 val group_stmts: Proof.context -> program |
83 -> ((Code_Symbol.T * stmt) list * (Code_Symbol.T * stmt) list |
83 -> ((Code_Symbol.T * stmt) list * (Code_Symbol.T * stmt) list |
84 * ((Code_Symbol.T * stmt) list * (Code_Symbol.T * stmt) list)) list |
84 * ((Code_Symbol.T * stmt) list * (Code_Symbol.T * stmt) list)) list |
85 |
85 |
86 val read_const_exprs: Proof.context -> string list -> string list |
86 val read_const_exprs: Proof.context -> string list -> string list |
87 val consts_program: theory -> string list -> program |
87 val consts_program: Proof.context -> string list -> program |
88 val dynamic_conv: Proof.context -> (program |
88 val dynamic_conv: Proof.context -> (program |
89 -> typscheme * iterm -> Code_Symbol.T list -> conv) |
89 -> typscheme * iterm -> Code_Symbol.T list -> conv) |
90 -> conv |
90 -> conv |
91 val dynamic_value: Proof.context -> ((term -> term) -> 'a -> 'a) -> (program |
91 val dynamic_value: Proof.context -> ((term -> term) -> 'a -> 'a) -> (program |
92 -> term -> typscheme * iterm -> Code_Symbol.T list -> 'a) |
92 -> term -> typscheme * iterm -> Code_Symbol.T list -> 'a) |
774 ( |
774 ( |
775 type T = program; |
775 type T = program; |
776 val empty = Code_Symbol.Graph.empty; |
776 val empty = Code_Symbol.Graph.empty; |
777 ); |
777 ); |
778 |
778 |
779 fun invoke_generation ignore_cache thy (algebra, eqngr) generate thing = |
779 fun invoke_generation ignore_cache ctxt (algebra, eqngr) generate thing = |
780 Program.change_yield (if ignore_cache then NONE else SOME thy) |
780 Program.change_yield |
|
781 (if ignore_cache then NONE else SOME (Proof_Context.theory_of ctxt)) |
781 (fn program => ([], program) |
782 (fn program => ([], program) |
782 |> generate (Proof_Context.init_global thy) algebra eqngr thing |
783 |> generate ctxt algebra eqngr thing |
783 |-> (fn thing => fn (_, program) => (thing, program))); |
784 |-> (fn thing => fn (_, program) => (thing, program))); |
784 |
785 |
785 |
786 |
786 (* program generation *) |
787 (* program generation *) |
787 |
788 |
788 fun consts_program_internal thy permissive consts = |
789 fun consts_program_internal ctxt permissive consts = |
789 let |
790 let |
790 fun generate_consts ctxt algebra eqngr = |
791 fun generate_consts ctxt algebra eqngr = |
791 fold_map (ensure_const ctxt algebra eqngr permissive); |
792 fold_map (ensure_const ctxt algebra eqngr permissive); |
792 in |
793 in |
793 invoke_generation permissive thy |
794 invoke_generation permissive ctxt |
794 (Code_Preproc.obtain false (Proof_Context.init_global thy) consts []) |
795 (Code_Preproc.obtain false ctxt consts []) |
795 generate_consts consts |
796 generate_consts consts |
796 |> snd |
797 |> snd |
797 end; |
798 end; |
798 |
799 |
799 fun consts_program_permissive thy = consts_program_internal thy true; |
800 fun consts_program_permissive thy = consts_program_internal thy true; |
840 end; |
841 end; |
841 |
842 |
842 fun dynamic_evaluation eval ctxt algebra eqngr t = |
843 fun dynamic_evaluation eval ctxt algebra eqngr t = |
843 let |
844 let |
844 val ((program, (vs_ty_t', deps)), _) = |
845 val ((program, (vs_ty_t', deps)), _) = |
845 invoke_generation false (Proof_Context.theory_of ctxt) |
846 invoke_generation false ctxt |
846 (algebra, eqngr) ensure_value t; |
847 (algebra, eqngr) ensure_value t; |
847 in eval program t vs_ty_t' deps end; |
848 in eval program t vs_ty_t' deps end; |
848 |
849 |
849 fun dynamic_conv ctxt conv = |
850 fun dynamic_conv ctxt conv = |
850 Code_Preproc.dynamic_conv ctxt |
851 Code_Preproc.dynamic_conv ctxt |
857 fun static_evaluation ctxt consts algebra eqngr static_eval = |
858 fun static_evaluation ctxt consts algebra eqngr static_eval = |
858 let |
859 let |
859 fun generate_consts ctxt algebra eqngr = |
860 fun generate_consts ctxt algebra eqngr = |
860 fold_map (ensure_const ctxt algebra eqngr false); |
861 fold_map (ensure_const ctxt algebra eqngr false); |
861 val (deps, program) = |
862 val (deps, program) = |
862 invoke_generation true (Proof_Context.theory_of ctxt) |
863 invoke_generation true ctxt |
863 (algebra, eqngr) generate_consts consts; |
864 (algebra, eqngr) generate_consts consts; |
864 in static_eval { program = program, deps = deps } end; |
865 in static_eval { program = program, deps = deps } end; |
865 |
866 |
866 fun static_evaluation_thingol ctxt consts algebra eqngr static_eval = |
867 fun static_evaluation_thingol ctxt consts algebra eqngr static_eval = |
867 let |
868 let |
917 |
918 |
918 fun read_const_exprs_all ctxt = op @ o read_const_exprs_internal ctxt; |
919 fun read_const_exprs_all ctxt = op @ o read_const_exprs_internal ctxt; |
919 |
920 |
920 fun read_const_exprs ctxt const_exprs = |
921 fun read_const_exprs ctxt const_exprs = |
921 let |
922 let |
922 val (consts, consts_permissive) = read_const_exprs_internal ctxt const_exprs; |
923 val (consts, consts_permissive) = |
|
924 read_const_exprs_internal ctxt const_exprs; |
923 val consts' = implemented_deps |
925 val consts' = implemented_deps |
924 (consts_program_permissive (Proof_Context.theory_of ctxt) consts_permissive); |
926 (consts_program_permissive ctxt consts_permissive); |
925 in union (op =) consts' consts end; |
927 in union (op =) consts' consts end; |
926 |
928 |
927 |
929 |
928 (** diagnostic commands **) |
930 (** diagnostic commands **) |
929 |
931 |