src/Pure/Tools/codegen_package.ML
changeset 22846 fb79144af9a3
parent 22845 5f9138bcb3d7
child 23089 9669110656b9
equal deleted inserted replaced
22845:5f9138bcb3d7 22846:fb79144af9a3
    49 fun merge_abstypes ((typs1, consts1) : abstypes, (typs2, consts2) : abstypes) =
    49 fun merge_abstypes ((typs1, consts1) : abstypes, (typs2, consts2) : abstypes) =
    50   (Symtab.merge (Type.eq_type Vartab.empty) (typs1, typs2),
    50   (Symtab.merge (Type.eq_type Vartab.empty) (typs1, typs2),
    51     Consttab.merge CodegenConsts.eq_const (consts1, consts2));
    51     Consttab.merge CodegenConsts.eq_const (consts1, consts2));
    52 
    52 
    53 structure CodegenPackageData = TheoryDataFun
    53 structure CodegenPackageData = TheoryDataFun
    54 (struct
    54 (
    55   val name = "Pure/codegen_package_setup";
       
    56   type T = appgens * abstypes;
    55   type T = appgens * abstypes;
    57   val empty = (Symtab.empty, (Symtab.empty, Consttab.empty));
    56   val empty = (Symtab.empty, (Symtab.empty, Consttab.empty));
    58   val copy = I;
    57   val copy = I;
    59   val extend = I;
    58   val extend = I;
    60   fun merge _ ((appgens1, abstypes1), (appgens2, abstypes2)) =
    59   fun merge _ ((appgens1, abstypes1), (appgens2, abstypes2)) =
    61     (merge_appgens (appgens1, appgens2), merge_abstypes (abstypes1, abstypes2));
    60     (merge_appgens (appgens1, appgens2), merge_abstypes (abstypes1, abstypes2));
    62   fun print _ _ = ();
    61 );
    63 end);
    62 
    64 
    63 structure Funcgr = CodegenFuncgrRetrieval
    65 structure Funcgr = CodegenFuncgrRetrieval (
    64 (
    66   val name = "Pure/codegen_package_thms";
    65   val name = "Pure/codegen_package_thms";
    67   fun rewrites thy = [];
    66   fun rewrites thy = [];
    68 );
    67 );
    69 
    68 
    70 fun code_depgr thy [] = Funcgr.make thy []
    69 fun code_depgr thy [] = Funcgr.make thy []
    92       end;
    91       end;
    93     val prgr = CodegenFuncgr.Constgraph.fold ((fn x => fn xs => xs @ [x]) o mk_entry) gr [];
    92     val prgr = CodegenFuncgr.Constgraph.fold ((fn x => fn xs => xs @ [x]) o mk_entry) gr [];
    94   in Present.display_graph prgr end;
    93   in Present.display_graph prgr end;
    95 
    94 
    96 structure Code = CodeDataFun
    95 structure Code = CodeDataFun
    97 (struct
    96 (
    98   val name = "Pure/codegen_package_code";
    97   val name = "Pure/codegen_package_code";
    99   type T = CodegenThingol.code;
    98   type T = CodegenThingol.code;
   100   val empty = CodegenThingol.empty_code;
    99   val empty = CodegenThingol.empty_code;
   101   fun merge _ = CodegenThingol.merge_code;
   100   fun merge _ = CodegenThingol.merge_code;
   102   fun purge _ NONE _ = CodegenThingol.empty_code
   101   fun purge _ NONE _ = CodegenThingol.empty_code
   108           val dels = (Graph.all_preds code
   107           val dels = (Graph.all_preds code
   109               o map (CodegenNames.const thy)
   108               o map (CodegenNames.const thy)
   110               o filter (member CodegenConsts.eq_const cs_exisiting)
   109               o filter (member CodegenConsts.eq_const cs_exisiting)
   111             ) cs;
   110             ) cs;
   112         in Graph.del_nodes dels code end;
   111         in Graph.del_nodes dels code end;
   113 end);
   112 );
   114 
   113 
   115 val _ = Context.add_setup (CodegenPackageData.init #> Funcgr.init #> Code.init);
   114 val _ = Context.add_setup (Funcgr.init #> Code.init);
   116 
   115 
   117 
   116 
   118 (* preparing defining equations *)
   117 (* preparing defining equations *)
   119 
   118 
   120 fun prep_eqs thy (thms as thm :: _) =
   119 fun prep_eqs thy (thms as thm :: _) =