| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
* lib.h (enum functype): New member, N8.
(struct func): New members n8 and n8v in embedded f struct.
(func_n8, func_n8v, func_n70, func_n8o): Declared.
* lib.c (equal): Handle N8 in switch.
(func_n8, func_n8v, func_n70, func_n8o): New functions.
(generic_funcall): Handle N8 in two switches.
|
|
|
|
|
|
|
|
| |
* lib.c (dwim_set): When the range argument is a
vector or list, it is wrongly hangled through replace, even if
seq is a hash. replace throws since it doesn't handle hashes.
We must treat the vector or list as a hash key and
handle through sethash.
|
|
|
|
|
|
|
| |
* lib.c (replace_list, replace_str, replace_vec): The from
argument must be checked to be a list using listp not consp.
The legacy convention that nil is treated as missing does not
work in this function as it does in sub.
|
|
|
|
|
| |
* lib.c (less): Missing test for equality
before comparing to fields.
|
|
|
|
|
|
|
|
|
|
|
| |
* regex.c (range_regex): Return range.
(search_regst): Use appropriate accessors on
range returned by range_regex.
* lib.c (tok_where): Destructure range returned by
range_regex, using range_bind.
* txr.1: Documented changed behavior.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (env_vbind_special): Remove unused ctx_form
parameter.
(bind_args, bind_macro_params): Don't pass ctx_form to
env_vbind_special.
(apply): Remove unused ctx_form parameter.
(apply_intrinsic, applyv, mapcarv, mappendv,
lazy_mapcarv_func, mapdov, do_mapf): Don't pass nil third
argument to apply.
* eval.h (apply): Declaration updated.
* lib.c (do_juxt): Do not bind third argument of apply
to lin when currying; curry as two argument function.
(do_not): Do not pass third nil argument to apply.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (funcall_interp): Drop the env argument.
The fun argument is now the whole function object, not the
encapsulated code to be interpreted. We pull the
environment and code out of the object locally
and interpret as before.
* eval.h (funcall_interp): Declaration updated.
* lib.c (generic_funcall, funcall, funcall1, funcall2,
* funcall3, funcall4): Calls to funcall_interp simplified,
just passing fun.
|
|
|
|
|
|
|
|
|
| |
* eval.c (interp_fun): Function renamed to funcall_interp.
* eval.h (interp_fun): Declaration updated.
* lib.c (generic_funcall, funcall, funcall1, funcall2,
funcall3, funcall4): Calls to interp_fun updated.
|
|
|
|
|
|
|
|
| |
* lib.c (partition_split_common): nullify indices after
calling function, because function can put out an empty
sequence of non-list type. Use "not sequence" test
rather than "atom" on final index list, so that
vectors and strings can specify indices, as documented.
|
|
|
|
|
|
|
|
| |
* lib.c (transpose): This function turns an input list
into an argument list which ends up in an args structure,
which potentially destroys it to prevent spurious retention.
The list must be copied. We don't use copy-list because
the function supports vectors.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* args.h (args_set_fill): New inline function.
* eval.c (eval_init): Register window-map and window-mappend
intrinics.
* lib.c (wrap_k, reflect_k): New keyword variables.
(calc_win_size): New static function.
(window_map_list, window_map_vec): New static functions.
(window_map, window_mappend): New functions.
(obj_init): Initialize wrap_k and reflect_k.
* lib.h (window_map, window_mappend): Declared.
* txr.1: Documented window-map and window-mappend
|
|
|
|
|
|
|
|
|
|
| |
When the index argument is a function and it returns
an empty list, the functions behave incorrectly.
* lib.c (partition_split_common): Exchange order
of two operations. The handling of an empty indices list must
be done after testing for and calling the function which can
potentially produce that value.
|
|
|
|
|
|
|
| |
* lib.c (sub_list, replace_list): Use original list
variable instead of copying it to iter. Use gc_hint on list so
that the old value doesn't hang around on the stack, while a
register copy marches through the list.
|
|
|
|
|
|
| |
* lib.c (last): Handle non-list sequences via sub function.
* txr.1: Updated description of last.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Allowing rankings among types which documentation says
are not comparable.
* lib.c (enum less_handling): New enum.
(less_tab): Elements are values of the less_handling enum.
(less_tab_init): Entries are renumbered. Everything that was
given precedence 5 or higher is now zero: not comparable.
Precedences 0 to 4 remap to 1 to 5. less_tab is populated
differently, since there are four values now. If either
the left or right type has 0 precedence, the value is
less_cannot: comparison is not possible.
(less): Only a less_tab value of less_compare now passes
control through to the switch statement. The less_cannot
value shortcuts to a cannot compare error.
Types that cannot occur in the switch now are removed,
and a default case goes to internal error.
|
|
|
|
|
|
|
|
| |
* lib.c (equal): We cannot pass both arguments to the
left object's equal function just because both arguments are
COBJ. We must make sure they are using the same operations.
The equal functions blindly assume that both arguments are
objects of the same type, and cast the pointers.
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (lazy_conses, term, nthcdr, memq, memql, memqual,
member, member_if, remq, remql, remqual, remove_if, keep_if,
countqual, countql, countq, count_if, some_satisfy,
all_satisfy, none_satisfy, proper_listp, length_list,
getplist, do_and, do_or, mappend, find, find_if, posqual,
posql, posq, pos, pos_if): Use gc_hint on list parameter.
(find_max, pos_max, in, search_list, where): Restructure so
that list parameter is used as iterator. Use gc_hint on it.
|
|
|
|
|
|
| |
* lib.c (mapdo): gc_hint the list variable so that the list
march isn't entirely optimized into a register, leaving a
pointer to the top of the list on the stack.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Registered butlast intrinsic.
* lib.c (butlast): New function.
* lib.h (butlast): Declared.
* txr.1: Documented butlast.
|
|
|
|
|
|
|
| |
* lib.c (generic_funcall): If an object is used as a function,
get its lambda method and call that.
* txr.1: Document functors.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* debug.c (show_bindings): Use ~d for level, so as
not to be influenced by *print-base*.
(debug): Use ~d for line numbers.
* lib.c (gensym): Use ~d conversion specifier
for formatting gensym counter into symbol name.
* match.c (LOG_MISMATCH, LOG_MATCH): Use ~d for
line number references.
(h_skip, h_coll, h_fun, h_chr, match_line_completely, v_skip,
v_fuzz, v_gather, v_collect, v_output, v_filter, v_fun,
v_assert, v_load, v_line, h_assert, open_data_source): Use ~d
for line refs, number of iterations, errno values.
* parser.c (repl): Use ~d for prompt line numbers,
numbered variables and the expr-<n> string in error
messages.
* parser.l (yyerrorf, source_loc_str): Use ~d for line
numbers.
* stream.c (print_base_s): New symbol variable.
(formatv): Implement *print-base*.
(stdio_maybe_read_error, stdio_maybe_error, stdio_close,
pipe_close, open_directory, open_file, open_fileno, open_tail,
open_process, run, remove_path): Use ~d for errno values.
(stream_init): Initialize print_base_s and register
*print-base* special variable.
sysif.c (mkdir_wrap, ensure_dir, getcwd_wrap, mknod_wrap,
chmod_wrap, symlink_wrap, link_wrap, readlink_wrap,
excec_wrap, stat_impl, pipe_wrap, poll_wrap, getgroups_wrap,
setuid_wrap, seteuid_wrap, setgid_wrap): Use ~d for
errno values and system function results.
* txr.1: Documented *print-base* and ~d conversion specifier.
|
|
|
|
|
|
|
|
|
| |
* lib.c (obj_print_impl): When rendering quote,
quasiquote, unquote, splice, vector literals, and
meta-vars/meta-numbers into their read syntax, we must ensure
that these forms have the correct abstract syntax. If not, we
must print these as ordinary compound expressions. Otherwise
we throw errors, or don't print the complete object.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register revappend and nreconc
intrinsics.
* lib.c (list_collect_nreconc): New function.
(revlist): New static function.
(list_collect_revappend): New function.
(revappend, nreconc): New functions.
* lib.h (revappend, nreconc): Declared.
(list_collect_nreconc, list_collect_revappend): Declared.
* txr.1: Documented revappend and nreconc.
|
|
|
|
|
|
|
|
| |
* lib.c (nreverse): Handle strings and vectors
individually, and do strings and vectors in-place.
(reverse): Handle strings and vectors individually,
by duplicating and then in place. Handle lazy
strings by forcing, then reversing a copy.
|
|
|
|
|
| |
* lib.c (obj_print_impl): Handle rcons in same place
as other special syntax like sys:expr and quote.
|
|
|
|
|
|
| |
* lib.c (func_n6o): New function.
* lib.h (func_n6o): Declared.
|
|
|
|
|
|
| |
* lib.c (quicksort): Sort the shorter partition with real
recursion, then tail recurse with explicit goto to sort
the longer partition.
|
|
|
|
|
|
| |
* lib.c (med_of_three, middle_pivot): New static functions.
(quicksort): Use med_of_three to choose a pivot above a
threshold array size, otherwise just the middle element.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register intrinsic functions rcons,
rangep from and to.
(eval_init): Register rangep intrinsic.
* gc.c (mark_obj): Traverse RNG objects.
(finalize): Handle RNG in switch.
* hash.c (equal_hash, eql_hash): Hashing for for RNG objects.
* lib.c (range_s, rcons_s): New symbol variables.
(code2type): Handle RNG type.
(eql, equal): Equality for ranges.
(less_tab_init): Table extended to cover RNG.
(less): Semantics defined for ranges.
(rcons, rangep, from, to): New functions.
(obj_init): range_s and rcons_s variables initialized.
(obj_print_impl): Produce #R notation for ranges.
(generic_funcall, dwim_set): Recognize range objects for indexing
* lib.h (enum type): New enum member, RNG. MAXTYPE redefined
to RNG value.
(TYPE_SHIFT): Increased to 5 since there are now 16 type
codes.
(struct range): New struct type.
(union obj): New member rn, of type struct range.
(range_s, rcons_s, rcons, rangep, from, to): Declared.
(range_bind): New macro.
* parser.l (grammar): New rule for recognizing
the #R sequence as HASH_R token.
* parser.y (HASH_R): New terminal symbol.
(range): New nonterminal symbol.
(n_expr): Derives the new range symbol.
The n_expr DOTDOT n_expr rule produces rcons expression rather
than const.
* match.c (format_field): Recognize rcons syntax in fields
which is now what ranges translate to. Also recognize range
object.
* tests/013/maze.tl (neigh): Fix code which destructures
range as a cons. That can't be done any more.
* txr.1: Document ranges.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This function manages a dynamic array using only the filled
size as input, while minimizing reallocations. The allocated
size is implicitly always the next power of two at or above
the filled size.
* lib.c (next_pow_two): New static function.
(chk_manage_vec): New function.
* lib.h (chk_manage_vec): Declared.
|
|
|
|
|
| |
* lib.c (chk_grow_vec): It is newelems which must be compared against
the no_oflow value, not bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* combi.c (perm_list, perm_str, rperm_list, reperm_gen_fun,
rperm_vec, comb_vec, rcomb_list, rcomb_vec, rcomb_str):
Follow rename of list_vector to list_vec.
* eval.c (vector_list_s): Global variable renamed to
vec_list_s.
(expand_qquote): Follow vector_list_s to vec_list_s.
(eval_init): Follow renames of all identifiers. Functions
num-chr, chr-num, vector-list and list-vector are
registered under new names, while remaining registered
under old names.
* eval.h (vector_list_s): Declaration renamed.
* filter.c (url_encode): Follow chr_num to chr_int rename.
* lib.c (make_like, interpose, shuffle): Follow vector_list to vec_list rename.
(tolist, replace, replace_list): Follow list_vector to list_vec rename.
(num_chr): Renamed to int_chr.
(chr_num): Renamed to chr_int.
(vector_list): Renamed to vec_list.
(list_vector): Renamed to list_vec.
* lib.h (num_chr, chr_num, list_vector, vector_list):
* Declarations renamed.
* parser.y (vector): Follow vector_list to vec_list rename.
* txr.1: Updated documentation for num-chr, chr-num,
list-vector and vector-list with new names, and notes
about the old names being supported, but obsolescent.
|
|
|
|
|
| |
* lib.c (conses): Use consp termination test
only if input is a list.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (take_list_fun, take_while_list_fun,
take_until_list_fun): New static functions.
(take, take_while, take_until, drop, drop_while,
drop_until): New functions.
* eval.c (eval_init): Register intrinsics take,
take-while, take-until, drop, drop-while, drop-until.
* txr.1: Documented.
|
|
|
|
|
|
|
| |
* lib.c (copy_lazy_str): New static function.
(copy_str): Use copy_lazy_str to copy lazy strings.
* txr.1: Documentation added under copy-str.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
| |
* lib.c (lazy_str_force_upto): Don't allow wastefully small
increments; force at least 1024 characters beyond the
current length of the prefix.
|
|
|
|
|
|
|
|
|
| |
* lib (lazy_str_force, lazy_str_force_upto): The existing
algorithm keeps catenating pieces onto a string, which
triggers wasteful reallocations and is quadratic.
This is replaced with a different approach: we collect
pieces into a list, and then make a single call to
cat_str.
|
|
|
|
|
|
| |
* lib.c (lazy_sub_str): Check from and to args
correctly using null_or_missing_p instead of
comparing to nil.
|
|
|
|
|
|
|
| |
This bug means that range indexing doesn't work on
lazy strings. Ouch!
* lib.c (sub): Added missing LSTR switch case.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Two-fold benefit. Simplifies code which allocates wchar_t
arrays. Provides overflow check for the multiplication.
* lib.c (chk_wmalloc): New function.
(chk_strdup, mkstring, mkustring, upcase_str, downcase_str,
sub_str, cat_str, trim_str): Use chk_wmalloc.
* lib.h (chk_wmalloc): Declared.
* stream.c (make_string_output_stream): Use chk_wmalloc.
* utf8.c (utf8_dup_from_uc, utf8_dup_from): Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Registered flatcar* intrinsic.
* lib.c (lazy_flatcar_scan, lazy_flatcar_func):
New static functions.
(lazy_flatcar): New function.
* lib.h (lazy_flatcar): Declared.
* txr.1: Documented, also touching flatten documentation.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register flatcar intrinsic.
* lib.c (flatcar): New function.
* lib.h (flatcar): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
| |
* lib.c (obj_print_impl): Print whether
a function is interpreted or intrinsic, and
include argument information.
* tests/012/struct.tl: Test case relying on
function printed rep updated.
|
|
|
|
|
|
| |
* lib.c (car, cdr, car_l, cdr_l):
Check for signal before calling forcing
function of a lazy cons.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register subtypep and typep.
* eval.h (list_s): Existing variable declared.
* lib.c (atom_s, integer_s, number_s, sequence_s, string_s):
new symbol variables.
(subtypep, typep): New functions.
(obj_init): Initialize new symbol variables.
* lib.c (atom_s, integer_s, number_s, sequence_s, string_s):
Declared.
* txr.1: Documented type hierarchy and the new functions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (compat_fixup): Call rand_compat_fixup.
* rand.c (random_state_var_s): New global symbol variable.
(rand_compat_fixup): New static function.
(rand_init): Initialize random_state_var_s by intering
the earmuffed symbol *random-state*. Initialize random_state_s
to the non-earmuffed symbol random-state.
* rand.h (random_state_var_s): Declared.
(random_state): Macro updated to look up the special
variable using random_state_var_s, rather than random_state_s.
(rand_compat_fixup): Declared.
|