src/Tools/Code/code_preproc.ML
changeset 38674 cd9b59cb1b75
parent 38670 3c7db0192db9
child 38973 cedf2ac63d9c
equal deleted inserted replaced
38673:ae4c5d251257 38674:cd9b59cb1b75
    28     -> (code_algebra -> code_graph -> (string * sort) list -> term -> conv) -> conv
    28     -> (code_algebra -> code_graph -> (string * sort) list -> term -> conv) -> conv
    29   val dynamic_eval_value: theory -> ((term -> term) -> 'a -> 'a)
    29   val dynamic_eval_value: theory -> ((term -> term) -> 'a -> 'a)
    30     -> (code_algebra -> code_graph -> (string * sort) list -> term -> 'a) -> term -> 'a
    30     -> (code_algebra -> code_graph -> (string * sort) list -> term -> 'a) -> term -> 'a
    31   val static_eval_conv: theory -> string list
    31   val static_eval_conv: theory -> string list
    32     -> (code_algebra -> code_graph -> (string * sort) list -> term -> conv) -> conv
    32     -> (code_algebra -> code_graph -> (string * sort) list -> term -> conv) -> conv
    33   val pre_post_conv: theory -> conv -> conv
       
    34 
    33 
    35   val setup: theory -> theory
    34   val setup: theory -> theory
    36 end
    35 end
    37 
    36 
    38 structure Code_Preproc : CODE_PREPROC =
    37 structure Code_Preproc : CODE_PREPROC =
   455   in dynamic_eval thy I conclude_evaluation end;
   454   in dynamic_eval thy I conclude_evaluation end;
   456 
   455 
   457 fun dynamic_eval_value thy postproc evaluator = dynamic_eval thy (Thm.cterm_of thy)
   456 fun dynamic_eval_value thy postproc evaluator = dynamic_eval thy (Thm.cterm_of thy)
   458   (K o postproc (postprocess_term thy)) (K oooo evaluator);
   457   (K o postproc (postprocess_term thy)) (K oooo evaluator);
   459 
   458 
   460 fun pre_post_conv thy conv = (preprocess_conv thy) then_conv conv then_conv (postprocess_conv thy);
       
   461 
       
   462 fun static_eval_conv thy consts conv =
   459 fun static_eval_conv thy consts conv =
   463   let
   460   let
   464     val (algebra, eqngr) = obtain thy consts [];
   461     val (algebra, eqngr) = obtain thy consts [];
   465     fun conv' ct =
   462     fun conv' ct =
   466       let
   463       let
   467         val (vs, t) = dest_cterm ct;
   464         val (vs, t) = dest_cterm ct;
   468       in Conv.tap_thy (fn thy => pre_post_conv thy (conv algebra eqngr vs t)) ct end;
   465       in
       
   466         Conv.tap_thy (fn thy => (preprocess_conv thy)
       
   467           then_conv (conv algebra eqngr vs t) then_conv (postprocess_conv thy)) ct
       
   468       end;
   469   in conv' end;
   469   in conv' end;
   470 
   470 
   471 
   471 
   472 (** setup **)
   472 (** setup **)
   473 
   473