| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Struct objects can now define methods car, cdr and nullify.
With these, they can participate in operations on sequences.
* eval.h (car_s, cdr_s): Declared.
* lib.c (nullify_s): New symbol variable.
(car, cdr): Implement for struct objects via, respectively,
their car and cdr methods.
(tolist): Handle objects by mapping through identity.
(nullify): Implement for objects optionally: if an object
is a struct with a nullify method, use it, otherwise go
through default case of just returning the object.
(empty): Implement for objects that have nullify method.
(obj_init): Initialize nullify_s.
* struct.c (maybe_slot): New function.
* struct.h (maybe_slot): Declared.
* txr.1: Documented car, cdr and nullify method
convention.
|
|
|
|
|
|
|
|
|
| |
* struct.c (print_s): New symbol variable.
(struct_init): Initialize print_s.
(struct_inst_print): If pretty-printing, try to look
up object's print method and use it.
* txr.1: Documented pretty-printing via print method.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Curtail traversal of objects and strings.
* hash.c (struct hash): hash_fun member takes int *
parameter now.
(HASH_STR_LIMIT, HASH_REC_LIMIT): New macros.
(hash_c_str): Hash only HASH_STR_LIMIT characters.
(equal_hash): Becomes extern function. Takes pointer-to-int
count argument, which is decremented. Function stops
recursing and returns zero when this hits zero.
(eql_hash): Also takes int * param, for compatibility
with function pointer in struct hash. This parameter
is not used, though.
(cobj_hash_op): Take pointer-to-count parameter,
but ignore it.
(hash_hash_op): Take pointer-to-count parameter,
decrement and check that it has not hit zero,
pass down to equal hash.
(hash_grow, gethash_c, gethash, gethash_f, gethash_n,
remhash): Initialize a counter to HASH_REC_LIMIT and
pass down to hashing function.
(hash_eql): Pass down a pointer to a dummy counter
to eql_hash.
(hash_equal): Initialize a counter to HASH_REC_LIMIT
and pass down to hash_equal.
* hash.h (equal_hash): Declared.
* lib.h (cobj_ops): hash member takes int * parameter.
(cobj_hash_op): Declaration updated with new param.
* struct.c (struct_inst_hash): Takes new int * parameter
for count. Calls equal_hash instead of hash_equal,
eliminating c_num calls; pointer to count is
passed to equal_hash.
|
|
|
|
|
|
|
|
|
| |
* struct.c (static_slot_ensure): In the case when we grow the
array of static slots, we were allowing chk_manage_vec to
initialize the newly added element. This is wrong, because
it is just a plain assignment, which causes a mature object
to point to a baby object. This bug caused static slots to
contain junk.
|
|
|
|
|
|
|
| |
* struct.c (lookup_slot_load, lookup_static_slot_load): New
functions.
(slot, static_slot): Use auto-load wrappers for lower-level
slot lookup functions.
|
|
|
|
|
|
| |
* struct.c (umethod_fun): Use proper args interfaces
to check whether there is an object argument, and
to extract it.
|
|
|
|
|
|
|
| |
* struct.c (make_struct_type): Use find_struct_type rather
than direct lookup in struct_type_hash.
(find_struct_type): Use lisplib_try_load if a type is
not found to trigger autoloading on the symbol.
|
|
|
|
|
|
|
|
|
| |
It is already documented that accessing the instance
slots (not static slots) of a lazy struct forces it to
instantiate, thus this is a doc conformance bug.
* struct.c (lookup_slot): Only call check_init_lazy_structs
in the code paths where we calculate the location of an instance slot.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* LICENSE, METALICENSE, Makefile, args.c, args.h, arith.c,
arith.h, cadr.c, cadr.h, combi.c, combi.h, configure,
debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c,
gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h,
lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h,
parser.l, parser.y, rand.c, rand.h, regex.c, regex.h,
share/txr/stdlib/cadr.tl, share/txr/stdlib/except.tl,
share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl,
share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl,
share/txr/stdlib/struct.tl, share/txr/stdlib/txr-case.tl,
share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl,
share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl,
signal.c, signal.h, stream.c, stream.h, struct.c, struct.h,
sysif.c, sysif.h, syslog.c, syslog.h, txr.1, txr.c, txr.h,
unwind.c, unwind.h, utf8.c, utf8.h: Add 2016 copyright.
* linenoise/LICENSE, linenoise/linenoise.c,
linenoise/linenoise.h: Bump one principal author's copyright
from 2014 to 2015. The code is based on a snapshot of 2015
upstream work.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Structs can now have code which executes after an object is
initialized, which is useful for doing work like registering
objects in global lists and whatever, when those actions need
access to the initialized slots of the object.
* share/txr/stdlib/struct.tl (defstruct): Handle :posinit
syntax, by generating lambda as eighth argument of sys:make-struct
call.
* struct.c (struct struct_type): New member, postinitfun.
(struct_init): Adjust registrations of make_struct_type
to account for new parameter. The user visible
make-struct-type is registered as having one optional
argument, for backward compat.
(make_struct_type): New argument, postinitfun. Store this
in the structure. For backward compatibility, the argument
is defaulted.
(struct_type_mark): Mark the new postinitfun member.
(call_postinitfun_chain): New static function.
(make_struct, lazy_struct_init): Call call_postinitfun_chain
after slots are initialized, and after the boa function is
called.
* struct.h (make_struct_type): Declaration updated.
* lib.c (time_init): Pass eighth argument to make_struct type.
* sysif.c (sysif_init): Likewise.
* unwind.c (uw_late_init): Likewise.
* tests/012/struct.tl: Update defstruct expansion test case.
* txr.1: Document new argument of make-struct-type,
and clarify ordering of initfun with regard to
other actions. Likewise, document :postinit, and clarify
ordering of :init actions with regard to other actions.
|
|
|
|
|
|
|
|
|
|
|
| |
* struct.c (static_slot_ensure): Restructured function so that
the subtypes of stype are processed even if stype already has
the static slot. This way static-slot-ensure can be used to
overwrite a static slot value, not only establish one.
And thus defmeth can redefine methods.
* txr.1: Revamped static-slot-ensure doc, and added notes
about redefining to defmeth.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This bug doesn't affect static slots that are defined in
defstruct, because those get initialized in the new type by
the static init function.
The bug is that the values of static slots added later with
static_slot_ensure are not inherited by subtypes that are
created later still.
(Since static_slot_ensure propagates a slot to subtypes which
already exist, those types get the slot value.)
* struct.c (make_struct_type): Copy the contents of the
static slot array of the supertype into the new type,
so that static slot values are inherited. We can just use
memcpy because the ordering of static slots is the same
in the new type, and the inherited ones precede the
new ones, due to the way the all_slots list is combined.
* txr.1: Clarify inheritance of static slots.
|
|
|
|
|
|
| |
* struct.c (method_name): Don't return first match. Resolve to
most ancestral superclass which has that function in the
same slot.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (func_get_name): Use try to use new method_name
function, if unable to get name from the lexical or
global environment for functions.
* struct.c (meth_s): New symbol variable.
(struct_init): Initialize meth_s variable.
(method_name): New function.
* struct.h (method_name): Declared.
* txr.1: Re-documented func-get-name.
|
|
|
|
|
|
| |
* struct.c (super): Fix regression from Oct 17.
When the argument is a struct instance, we must
return the supertype, not the type.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This change eliminates numerous cast expressions and a pointer
chase from some operations, though some, like the struct_type
function, end up chasing an extra pointer.
* struct.c (struct struct_type): New member, self.
(struct struct_inst): Type member changed from val to
struct struct_type *.
(make_struct_type): Initialize new self member.
(super): Obtain type from si->type->self rather than
si->type. There appears to be a bug here.
(make_struct, lazy_struct_init): Initialize type field with
struct pointer rather than type object. Add an assertion which
references the type parameter, to prevent the cobj call from
garbage collecting type.
(copy_struct, clear_struct, replace_struct, reset_struct,
(lookup_slot, slot, slotset, struct_type, uslot_fun,
umethod_fun, struct_inst_print, struct_inst_mark,
struct_inst_equal, struct_inst_hash, struct_inst_equalsub):
All updated to new way of referencing type structure
and type object.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the equal method is defined for structs, its return
value is used in their place for hashing and comparison.
* eval.h (eq_s, eql_s, equal_s): Declared.
* hash.c (equal_hash): If a COBJ defines an equalsub
function, we call it. If it returns non-nil, we
take the object in its place and recurse.
* lib.c (equal): Refactored to support equality substitution.
(less): Support equality substitution.
* lib.h (cobj_ops): New function pointer member, equalsub.
Only struct instances define this, currently.
(cobj_ops_init): Add null entry to initializer for equalsub.
(cobj_ops_init_ex): New initialiation macro for
situations when the equalsub member must be provided.
* struct.c (struct struct_type): new member eqmslot.
(make_struct_type): Initialize emslot to zero.
(static_slot_set, static_slot_ensure): If eqmslot is -1,
indicating positive knowledge that there is no equal method
static slot, we must invalidate that with a zero: it is no
longer known whether there is or isn't such a slot.
(get_equal_method, struct_inst_equalsub): New static functions.
(struct_inst_ops): Initialize the equalsub member using
new cobj_ops_init_ex macro.
* txr.1: Document equality substitution.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/struct.tl (lnew): New macro.
* struct.c (struct_type): Turn id into a bitfield one bit
smaller than cnum. New Boolean bitfield lazy.
(struct_init): Register make-lazy-struct intrinsic.
(make_struct): Initialize lazy bitfield to zero.
(lazy_struct_init, check_init_lazy_struct): New static
functions.
(make_lazy_struct): New function.
(copy_struct, clear_struct, replace_struct, reset_struct,
lookup_slot, struct_inst_equal, struct_inst_hash):
Call check_init_lazy_struct on all structures involved.
(lookup_slot): Call check_init_lazy_struct.
(struct_inst_mark): If the struct is lazy, it has one
instance slot which must be marked, holding the argfun
function passed into make_lazy_struct.
* struct.h (make_lazy_struct): Declared.
* txr.1: Documented lnew and make-lazy-struct.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* struct.c (struct_init): Register uslot intrinsic function.
(uslot_fun): New static function.
(uslot): New function.
* struct.h (uslot): Declared.
* share/txr/stdlib/struct.tl (usl): New macro.
* lisplib.c (struct_set_entries): Add usl macro.
* txr.1: Documented uslot and usl.
|
|
|
|
|
| |
* struct.c (make_struct_type): Don't use nullptr identifier
as variable name.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
TXR is moving to custom assembly-language routines.
This is mainly motivated by a very dubious thing done in the
GNU C Library setjmp and longjmp in the name of security.
Evidently, glibc's setjmp "mangles" certain pointer values
which are stored into the jmp_buf buffer. It's been that way
since 2005, evidently. This means that, firstly, all along,
the use of setjmp in gc.c to get registers into a buffer so
they can be scanned has not actually worked properly. More
importantly, this pointer mangling in setjmp and longjmp is
very hostile to a stack copying implementation of delimited
continuations. The reason is that continuations contain
jmp_buf buffers, which get relocated in the process of
capturing and reviving a continuation. Any pointers in a
jmp_buf which point into the captured stack segment have to be
fixed up to point into the relocated location. Mangled
pointers make this difficult, requiring hacks which are
specific to glibc and the machine architecture. We might as
well implement a clean, well-behaved setjmp and longjmp.
* Makefile (jmp.o): New object file.
(dbg/%.o, opt/%.o): New rules for .S prerequisites.
* args.c, arith.c, cadr.c, combi.c, cadr.c, combi.c, debug.c,
eval.c, filter.c, glob.c, hash.c, lib.c, match.c, parser.c,
rand.c, regex.c, signal.c, stream.c, struct.c, sysif.c,
syslog.c, txr.c, unwind.c, utf8.c: Removed <setjmp.h>
include.
* gc.c: Switch to struct jmp and jmp_save, instead
of jmp_buf and setjmp.
* jmp.S: New source file.
* signal.h (struct jmp): New struct type.
(jmp_save, jmp_restore): New function declarations
denoting assembly language routines in jmp.S.
(extended_jmp_buf): Uses struct jmp instead of
setjmp.
(extended_setjmp): Use jmp_save instead of setjmp.
(extended_longjmp): Use jmp_restore instead of
longjmp.
|
|
|
|
|
|
|
|
| |
* struct.c (make_struct_type): Use chk_manage_vec
for initial allocation of static slot array.
(static_slot_ensure): Use chk_manage_vec to grow
the array when adding a slot. The function will
automatically double the array in power of two step sizes.
|
|
|
|
|
|
|
|
|
|
| |
* struct.c (stype_handle): New static function.
(make_struct_type, super, make_struct, static_slot,
static_slot_set, static_slot_ensure, slotp, static_slot_p):
Use stype_handle,
* txr.1: Documented that static-slot and static-slot-set
take type as a symbol.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/struct.tl (defmeth): New macro.
* struct.c (struct struct_type): New member, dvtypes.
(struct_init): Register static-slot-ensure
intrinsic.
(make_struct_type): Initialize dvtypes of newly instantiated
struct_type struct. If a super is specified, add new type
to the super's dvtypes.
(struct_type_mark): Mark st->dvtypes.
(static_slot_ensure): New function.
* struct.h (static_slot_ensure): Declared.
* txr.1: Documented defmeth and static-slot-ensure.
|
|
|
|
|
|
|
|
|
|
| |
* struct.c (make_struct): Add unwind protection around
the initialization of the struct object, which calls
the partially initialized object's finalizers if
initialization is abandoned by a non-local exit.
* txr.1: Document the behavior, under make-struct and
the new macro.
|
|
|
|
|
|
|
|
|
| |
* struct.c (reset_struct): New function.
(struct_init): Register reset_struct intrinsic.
* struct.h (reset_struct): Declared.
* txr.1: documented reset-struct.
|
|
|
|
|
|
|
|
|
| |
* struct.c (replace_struct): New function.
(struct_init): Register replace_struct intrinsic.
* struct.h (replace_struct): Declared.
* txr.1: documented replace-struct.
|
|
|
|
|
|
|
|
|
| |
* struct.c (clear_struct): New function.
(struct_init): Register clear-struct intrinsic.
* struct.h (struct_init): Declared.
* txr.1: documented clear-struct.
|
|
|
|
|
| |
* struct.c (make_struct): Process property list first,
then call boa constructor, not vice versa.
|
|
|
|
|
| |
* struct.c (make_struct): Don't wastefully evaluate the symbolp
test twice via recursion; assign and fall through.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/struct.tl (sys:prune-nil-inits):
Use of slot-p renamed.
* struct.c (struct_init): Register slotp, and make
registration of slot-p conditional on compatibility option.
(slot_p): Function renamed to slotp.
* struct.h (slot_p): Declaration renamed.
* txr.1: References to slot-p fixed to slotp. Compat notes
added.
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/struct.tl (umeth): New macro.
* struct.c (struct_init): Registered umethod intrinsic.
(umethod_fun): New static function.
(umethod): New function.
* txr.1: Documented.
|
|
|
|
|
|
|
| |
* struct.c (struct_handle): The situation is that
the object isn't a structure instance, not that
the argument isn't a struct type. Use appropriate
error message.
|
|
|
|
|
|
|
|
| |
* struct.c (super): Detect structure instance
and resolve it to its type. Recursion eliminated in favor of
imperative approach that eliminates redundant checks.
* txr.1: Description of super updated.
|
|
|
|
|
|
|
|
|
| |
* struct.c (struct_init): Register super-method.
(super_method): New function.
* struct.h (super_method): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A new optional argument on finalize allows it to
be expressed that multiple finalizers on the same
object are to be called in reverse order, which is
potentially for objects with inheritance.
* gc.c (gc_finalize): New optional argument, rev_order_p.
Insert at the head of the list if this argument is
specified and true.
(gc_late_init): Register finalize as three-argument
function with optional argument.
* gc.h (gc_finalize): Declaration updated.
* share/txr/stdlib/struct.tl (defstruct): Register :fini
functions in reverse, so that derived finalizers
are called before supertype finalizers.
* txr.1: Documented new finalize argument, and
behavior of :fini.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/struct.tl (sys:bad-slot-syntax): New helper function.
(defstruct): Macro revamped with new slot specifier syntax for
writing static slots as well as methods.
* struct.c (STATIC_SLOT_BASE): New preprocessor symbol.
(struct struct_type): New members, nstslots, stinitfun, stslot.
(make_struct_type_compat): New static function.
(struct_init): Register make-struct-type to make_struct_type_compat
if compatibility is 117 or lower.
Register new intrinsics static-slot, static-slot-set, call-super-method,
call-super-fun, slot-p and static-slot-p.
(call_stinitfun_chain): New static function.
(make_struct_type): Two new arguments for specifying static slots and
an initialization function for them. Logic added for setting
up static slots and handling inheritance.
(struct_type_destroy): New static function.
(struct_type_mark): Mark the new stinitfun member of struct type.
Also iterate over the static slots in the new stslot array and
mark them.
(lookup_slot): Altered to return a loc instead of a raw pointer,
and also to accept the instance object as a member.
Now resolves static slots: it can return a loc which references
a static slot in the structure type, or an instance slot in
the structure.
(lookup_static_slot): New static function.
(slot, slotset): Implementation adjusted due to new lookup_slot interface.
(static_slot, static_slot_set, slot_p, static_slot_p): New functions.
(call_super_method, call_super_fun): New static functions.
(struct_inst_print): This function can no longer assume that the slots
list lines up with the array of slots, since it contains a mixture of
static and instance slots. Earnest slot lookup has to be performed.
(struct_type_ops): Point the destroy function to struct_type_destroy
instead of cobj_destroy_free_op. A structure type now has an array
of static slots to free.
* struct.h (make_struct_type): Declaration updated.
(static_slot, static_slot_set, slot_p, static_slot_p): Declared.
* lib.c (time_init): Update call to make_struct_type with new
arguments.
* sysif.c (sysif_init): Likewise.
* tests/012/struct.tl: Update defstruct macro expansion test.
* txr.1: Documented static slots and new functions.
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
* struct.c (struct_inst_equal, struct_inst_hash): New functions.
(struct_inst_ops): Wire new functions into operations table.
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
* 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.
|