290 fun map_instance f = map_names |
290 fun map_instance f = map_names |
291 (fn (class, classrel, tyco, inst) => (class, classrel, tyco, f inst)); |
291 (fn (class, classrel, tyco, inst) => (class, classrel, tyco, f inst)); |
292 end; (*local*) |
292 end; (*local*) |
293 |
293 |
294 structure CodeName = TheoryDataFun |
294 structure CodeName = TheoryDataFun |
295 (struct |
295 ( |
296 val name = "Pure/codegen_names"; |
|
297 type T = names ref; |
296 type T = names ref; |
298 val empty = ref empty_names; |
297 val empty = ref empty_names; |
299 fun copy (ref names) = ref names; |
298 fun copy (ref names) = ref names; |
300 val extend = copy; |
299 val extend = copy; |
301 fun merge _ (ref names1, ref names2) = ref (merge_names (names1, names2)); |
300 fun merge _ (ref names1, ref names2) = ref (merge_names (names1, names2)); |
302 fun print _ _ = (); |
301 ); |
303 end); |
|
304 |
302 |
305 structure ConstName = CodeDataFun |
303 structure ConstName = CodeDataFun |
306 (struct |
304 ( |
307 val name = "Pure/codegen_names"; |
305 val name = "Pure/codegen_names"; |
308 type T = const Consttab.table * (string * string option) Symtab.table; |
306 type T = const Consttab.table * (string * string option) Symtab.table; |
309 val empty = (Consttab.empty, Symtab.empty); |
307 val empty = (Consttab.empty, Symtab.empty); |
310 fun merge _ ((const1, constrev1), (const2, constrev2)) = |
308 fun merge _ ((const1, constrev1), (const2, constrev2)) = |
311 (Consttab.merge eq_string (const1, const2), |
309 (Consttab.merge eq_string (const1, const2), |
312 Symtab.merge CodegenConsts.eq_const (constrev1, constrev2)); |
310 Symtab.merge CodegenConsts.eq_const (constrev1, constrev2)); |
313 fun purge _ NONE _ = empty |
311 fun purge _ NONE _ = empty |
314 | purge _ (SOME cs) (const, constrev) = (fold Consttab.delete_safe cs const, |
312 | purge _ (SOME cs) (const, constrev) = (fold Consttab.delete_safe cs const, |
315 fold Symtab.delete (map_filter (Consttab.lookup const) cs) constrev); |
313 fold Symtab.delete (map_filter (Consttab.lookup const) cs) constrev); |
316 end); |
314 ); |
317 |
315 |
318 val _ = Context.add_setup (CodeName.init #> ConstName.init); |
316 val _ = Context.add_setup (CodeName.init #> ConstName.init); |
319 |
317 |
320 |
318 |
321 (* forward lookup with cache update *) |
319 (* forward lookup with cache update *) |