summaryrefslogtreecommitdiffstats
path: root/struct.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix failure of struct.c to compile as C++.Kaz Kylheku2015-09-041-16/+9
| | | | | | | * struct.c (struct_type_ops, struct_inst_ops): Use static_forward and static_macros to handle the forward declarations. Also, cobj_ops_init macro now used for both instead of raw initializer.
* Slot cache fix: zero is a valid slot index.Kaz Kylheku2015-09-021-2/+2
| | | | | | | struct.c (cacheline_lookup): return -1 when the id is not found in the cacheline, rather than zero. (lookup_slot): Test return value of cacheline_lookup according to the above change.
* Fix incorrect finalization of struct-type.Kaz Kylheku2015-09-021-14/+20
| | | | | | | | | | | | | | | | | | | | | | The issue is that we can't call remhash in the cobj destroy handler, because we are in the middle of gc. The fix is to register a proper finalization hook. This is the first use of finalize from within TXR. * gc.c (gc_finalize): static becomes extern. * gc.h (gc_finalize): Declared. * struct.c (struct_type_finalize_f): New static variable. (struct_init): GC-protect new static variable, and initialize it to point to new struct_type_finalize function. (struct_type_finalize): New function: performs the remhash calls previously done in struct_type_free. (make_struct_type): Register a finalizer hook for every new structure type, which will call struct_type_finalize. (struct_type_free): Static function removed. (struct_type_ops): Use generic cobj_destroy_free_op since all that is left to do is to free the handle.
* equal comparison and hashing for structs.Kaz Kylheku2015-09-011-2/+36
| | | | | * struct.c (struct_inst_equal, struct_inst_hash): New functions. (struct_inst_ops): Wire new functions into operations table.
* struct: 4-way set associative slot caches.Kaz Kylheku2015-08-301-10/+54
| | | | | | | | | | | * lib.h (SLOT_CACHE_SIZE): Adjust value from 32 to 8. (slot_cache_entry_t): New struct typedef. (slot_cache_line_t): Typedef updated: a cache line consists of cache line entry structs rather than cnums. * struct.c (cacheline_lookup, cacheline_insert): New static functions. (lookup_slot): Use cacheline_lookup and cacheline_insert.
* Introducing structs.Kaz Kylheku2015-09-021-0/+450
* args.c (args_cat_zap): New function. * args.h: (args_cat_zap): Declared. * eval.c (struct_lit_s): New symbol variable. (eval_init): Initialize struct_lit_s. * eval.h (struct_lit_s): Declared. * gc.c (finalize): If a symbol has a struct slot hash attached to it, we must free it when the symbol is reclaimed. * lib.c (make_sym): Initialize symbol's slot_cache pointer to null. (copy): Copy structure objects. (init): Call struct_init to initialize struct module. * lib.h (SLOT_CACHE_SIZE): New preprocessor symbol (slot_cache_line_t, slot_cache_t): New typedefs. (struct sym): New member, slot_cache. * lisplib.c (struct_set_entries, struct_instantiate): New static functions. (liplib_init): Register new functions in dl_table. parser.y (HASH_S): New terminal symbol. (struct): New grammar rule. (n_expr): Derive struct. (yybadtoken): Map HASH_S to #S string. parser.l (grammar): Recognize #S and return HASH_S token. share/txr/stdlib/place.tl (slot): New defplace. share/txr/stdlib/struct.tl: New file. struct.c: New file. struct.h: New file. * Makefile (OBJS): Adding struct.o.