82 (merge_appgens (appgens1, appgens2), merge_abstypes (abstypes1, abstypes2)); |
82 (merge_appgens (appgens1, appgens2), merge_abstypes (abstypes1, abstypes2)); |
83 fun print _ _ = (); |
83 fun print _ _ = (); |
84 end); |
84 end); |
85 |
85 |
86 val _ = Context.add_setup (Code.init #> CodegenPackageData.init); |
86 val _ = Context.add_setup (Code.init #> CodegenPackageData.init); |
|
87 |
|
88 |
|
89 (* preparing function equations *) |
|
90 |
|
91 fun prep_eqs thy (thms as thm :: _) = |
|
92 let |
|
93 val ty = (Logic.unvarifyT o CodegenData.typ_func thy) thm; |
|
94 val thms' = if (null o Term.typ_tfrees) ty orelse (null o fst o strip_type) ty |
|
95 then thms |
|
96 else map (CodegenFuncgr.expand_eta thy 1) thms; |
|
97 in (ty, thms') end; |
87 |
98 |
88 |
99 |
89 (* extraction kernel *) |
100 (* extraction kernel *) |
90 |
101 |
91 fun check_strict (false, _) has_seri x = |
102 fun check_strict (false, _) has_seri x = |
266 |> ensure_def_class thy algbr funcgr strct ((the o AxClass.class_of_param thy) c) |
277 |> ensure_def_class thy algbr funcgr strct ((the o AxClass.class_of_param thy) c) |
267 |-> (fn _ => succeed CodegenThingol.Bot); |
278 |-> (fn _ => succeed CodegenThingol.Bot); |
268 fun defgen_fun trns = |
279 fun defgen_fun trns = |
269 case CodegenFuncgr.funcs funcgr |
280 case CodegenFuncgr.funcs funcgr |
270 (perhaps (Consttab.lookup ((snd o snd o CodegenPackageData.get) thy)) c_tys) |
281 (perhaps (Consttab.lookup ((snd o snd o CodegenPackageData.get) thy)) c_tys) |
271 of eq_thms as eq_thm :: _ => |
282 of thms as _ :: _ => |
272 let |
283 let |
|
284 val (ty, eq_thms) = prep_eqs thy thms; |
273 val timeap = if !timing then Output.timeap_msg ("time for " ^ c') |
285 val timeap = if !timing then Output.timeap_msg ("time for " ^ c') |
274 else I; |
286 else I; |
275 val msg = cat_lines ("generating code for theorems " :: map string_of_thm eq_thms); |
287 val msg = cat_lines ("generating code for theorems " :: map string_of_thm eq_thms); |
276 val ty = (Logic.unvarifyT o CodegenData.typ_func thy) eq_thm; |
|
277 val vs = (map dest_TFree o Consts.typargs consts) (c', ty); |
288 val vs = (map dest_TFree o Consts.typargs consts) (c', ty); |
278 val dest_eqthm = |
289 val dest_eqthm = |
279 apfst (snd o strip_comb) o Logic.dest_equals o Logic.unvarify o prop_of; |
290 apfst (snd o strip_comb) o Logic.dest_equals o Logic.unvarify o prop_of; |
280 fun exprgen_eq (args, rhs) trns = |
291 fun exprgen_eq (args, rhs) trns = |
281 trns |
292 trns |