| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These functions convert any iterable to a list, vector or
string.
* eval.c (eval_init): Registered list-seq, vec-seq and str-seq
intrinsics.
* lib.c (list_seq, vec_seq, str_seq): New functions.
* lib.h (list_seq, vec_seq, str_seq): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Issues: (nullify 1..1) doesn't return nil as it
should, and (empty 1) fails.
* lib.c (seq_info): Since we would like nullify to use
seq_info, seq_info cannot call nullify. Transplant the probing
of the nullify method out of nullify and into here.
(nullify): Obtain a seq_info_t on the object. If it's not a
sequence and is not range, then just return the object.
Otherwise obtain a seq_iter_t sequence and peek whether it has
a next item.
(empty): Similarly, obtain an iterator and peek.
Definition of empty is relocated to be next to nullify.
* lib.h: Relocate declaration of empty, also.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.h (seq_iter_t): Add some union members to ui and ul for
use with ranges. The purpose of this is to have separate
naming for the iteration variables for ranges.
* lib.c (seq_iter_get_range_cnum, seq_iter_peek_range_cnum,
seq_iter_get_range_chr, seq_iter_peek_range_chr,
seq_iter_get_range_bignum, seq_iter_peek_range_bignum): Use
new union member names for clarity.
(seq_iter_get_rev_range_cnum, seq_iter_peek_rev_range_cnum,
seq_iter_get_rev_range_chr, seq_iter_peek_rev_range_chr,
seq_iter_get_rev_range_bignum,
seq_iter_peek_rev_range_bignum): New static functions.
(seq_iter_with_init_info): Drop obj argument since the si
argument has the object. Add handling for empty and reversed
ranges. Also convert unbounded ranges like N..t and N..: to
just N, recursively. Use new union member names.
(seq_iter_init, seq_iter_init_with_rewind, iter_begin,
iter_reset): Follow elimination of argument in
seq_iter_init_with_info.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (get_iter_f): Renamed to iter_from_binding_f.
(iter_begin_f, iter_more_f, iter_item_f, iter_step_f): New
global variables.
(op_each): Follow rename of get_iter_f.
(mapcarv, mappendv, lazy_mapcar_func, lazy_mapcar,
lazy_mapcarv_func, lazy_mapcarv, mapdov, prod_common):
Convert from car/cdr/null-test iteration to iter-begin.
(eval_init): gc-protect and initialize new variables.
* lib.c (mapcar_listout, mappend, mapdo): Convert to seq_iter
iteration. List argument renamed to seq.
(mapcar): List argument renamed to seq.
* lib.h: Declarations updated with renamed arguments.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I think with the iter-begin API, we have the the "Maxwell's
Equations of Iteration". This not only works well for conses,
but it extends to numbers and ranges.
* lib.h (seq_iter_t): New union member ul, containing a new
member lim. existing len member moved into ul union.
* lib.c (seq_iter_get_vec, seq_iter_peek_vec): Adjust access
of len, now wrapped in union.
(seq_iter_get_range_cnum, seq_iter_peek_range_cnum,
seq_iter_get_range_chr, seq_iter_peek_range_chr,
seq_iter_get_range_bignum, seq_iter_peek_range_bignum,
seq_iter_get_chr, seq_iter_peek_chr, seq_iter_get_num,
seq_iter_peek_num): New static functions.
(seq_iter_init_with_info): Support RNG object, further
classifying the iteration based on the type of the from
element. Support numbers and characters as iterable.
(iter_begin, iter_more, iter_item, iter_step, iter_reset):
Support numbers directly as unencapsulated iterators.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
iter-begin provides a paradigm for iteration that is more
compatible with lists. If the sequence is a list, then the
list itself is returned as the iterator, and the other
functions are basicaly wrappers for car/cdr and null testing.
Yet the API is defined in such a way that other objects can be
iterated with good efficiency, at the cost of allocating a new
iterator object (which can be re-used).
* eval.c (eval_init): Register iter-begin, iter-more,
iter-item, iter-step and iter-reset.
* lib.c (seq_iter_init_with_info): New static function.
(seq_iter_init): Now a thin wrapper for
seq_iter_init_with_info.
(iter_begin, iter_more, iter_item, iter_step, iter_reset): New
functions.
* lib.h (iter_begin, iter_more, iter_item, iter_step,
iter_reset): New functions.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* gencadr.txr (cadr_register): Use scat2 to glue two strings.
* cadr.c: Regenerated.
* lib.c (scat2, scat3): New functions.
* lib.h (scat2, scat3): Declared.
* liblib.c (place_instantiate, ver_instantiate,
ifa_instantiate, txr_case_instantiate,
with_resources_instantiate, path_test_instantiate,
struct_instantiate, with_stream_instantiate, hash_instantiate,
except_instantiate, type_instantiate, yield_instantiate,
sock_instantiate, termios_instantiate, awk_instantiate,
build_instantiate, trace_instantiate, getopts_instantiate,
package_instantiate, getput_instantiate, tagbody_instantiate,
pmac_instantiate, error_instantiate, keyparams_instantiate,
ffi_instantiate, doloop_instantiate, stream_wrap_instantiate,
asm_instantiate, compiler_instantiate, debugger_instantiate,
op_instantiate, save_exe_instantiate, defset_instantiate,
copy_file_instantiate): Use scat2 to glue two strings instead
of format.
* parser.c (find_matching_syms, hist_save, repl): Replace
trivial uses of format with scat2 or scat3.
* sysif.c (ensure_dir): Likewise.
* txr.c (get_self_path, substitute_basename, sysroot,
sysroot_init, parse_once_noerr, read_compiled_file_noerr,
read_eval_stream_noerr): Likewise.
* unwind.c (uw_unwind_to_exit_point): Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Quasistrings compile to code that requires on the sys:fmt-join
function to glue strings together. Rewriting that function to
avoid converting its arguments from struct args * to a list.
* eval.c (fmt_join): Static function removed.
* lib.c (cat_str_measure, cat_str_append): more_p parameter
changed to int type, which better matches the C style Boolean
values it takes.
(fmt_join): New external function.
* lib.h: Declared.
* args.h (args_more_nozap, args_get_nozap): New inline
functions allowing multiple iterations over arguments without
making a copy.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (seq_getpos, seq_setpos): New functions.
* lib.h (seq_getpos, seq_setpos): Declared.
(search_list, rsearch_list): Static functions removed.
(search_common): New static function.
(search, contains, rsearch): These functions are now trivial
wrappers around search_common. A requirement problem is fixed
in rsearch: when the key is empty, the length of sequence is
returned rather than zero, because zero is obviously not the
right most place where an empty key matches.
* txr.1: Documentation updated.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (rt_assert_fail, me_assert): New static functions.
(eval_init): assert macro and sys:rt-assert-fail function
registered.
* lib.c (func_n4ov): New function.
* lib.h (func_n4ov): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I'm fixing a historic mistake copied from ANSI Lisp,
which trips up language newcomers and sometimes even
experienced users.
The function innocently named sort will now return newly
allocated structure. The function previously called sort will
be available as nsort (non-consing/allocating sort).
The shuffle function also becomes pure, and is accompanied by
nshuffle.
* eval (me_op): Continue to use destructive sort in this
legacy code that is only triggered in very old compat mode.
(eval_init): Registered nsort and nshuffle.
* lib.c (nsort, nshuffle): New functions introduced, closely
based on sort and shuffle.
(sort, shuffle): Rewritten to avoid destructive behavior: work
by copying the input and calling destructive counterparts.
(sort_group): Continue to use destructive sort, which is safe;
the structure is locally allocated. The sort_group function
has pure semantics.
(grade): Likewise.
* lib.h (nsort, nshuffle): Declared.
* share/txr/stdlib/getopts.tl (opthelp): Replace an instance
of the (sort (copy-list ...)) pattern with just (sort ...).
* tags.tl (toplevel): Continue to use destructive sort to sort
tags before writing the tag file; the lifetime of the tags
list ends when the file is written.
* tests/010/seq.txr: Switch some sort calls to nsort to keep
test case working.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The c_unum and unum functions are fairly often needed
and and are closely related to c_num and num, which have
always been declared in lib.h even though they live in
arith.c. Files not doing arithmetic are including "arith.h"
just for the sake of c_num or unum.
* arith.h (c_unum, unum): Declarations removed.
* lib.h (c_unum, unum): Declarations moved here.
* chksum.c, debug.c, stream.c, strudel.c, sysif.c, vm.c:
These files no longer require #include "arith.h" as a result,
which is therefore removed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As a final round of this recent work, we observe that
since the accumulator structure has been reduced to two
members, we can eliminate one of them by using a cons
cell as the accumulator, and threading the second value
through the cdr.
That is to say, the listacc grammar rule's semantic
value will now be the tail cons of the list being
constructed. The cdr of this cons will, temporarily,
be a back pointer to the head (making the list temporarily
circular).
The n_exprs reduction will fix this up; it will put the
correct terminating atom in place of the head (either nil,
or the dotted item if there is one), and yield the head as the
semantic value.
* lib.h (struct list_accum): Removed. (Thus, finding a better
home for this would, after all, have been a waste of time).
* parser.y (lacc, splacc): Static functions removed.
(union YYSTYPE): lacc membber removed.
(n_exprs): Adjust to new semantic value coming from listacc.
(listacc): Now of type val again. Yields pointer to tail cons
as semantic value, whose cdr points to the head of the
list.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.h (struct list_accum): dot member removed.
* parser.y (misplaced_consing_dot_check): Function removed.
The misplaced consing dot diagnostic is still provided
as before by yybadtoken.
(n_exprs): Production for CONSDOT is moved here out of
listacc. There is no $1.dot member to deal with;
the dot is very simply handled here.
(listacc): Remove calls to misplaced_consing_dot_check.
CONSDOT production moved to n_exprs.
(lacc, splacc): Remove initialization of dot member.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The r_expr grammar symbol is replaced with listacc which has
a different type: a new Yacc node type that has three fields
for building a list from left to right without nreverse,
and the dotted pair item.
* lib.h (struct list_accum): New struct type. Not a great
place for it, but we don't have a parser-specific header that
is included before y.tab.h: parser.h is included after
y.tab.h.
* parser.y (misplaced_consing_dot_check): The val argument
is just the existing dotted item; if it is other than nao,
the error is generated.
(lacc, splacc): New static functions.
(YYSTYPE): New union member, lacc of type struct list_accum.
(r_exprs): Grammar symbol removed.
(listacc): New grammar symbol of type listacc. The rules are
those of r_exprs upgraded to construct the list in one pass.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is the eight and final round of an effort to enable
GCC's -Wextra option. The C++ compiler, with -Wextra,
doesn't like C's universal struct initializer { 0 },
individually complaining about all the remaining members
not being initialized. What works in C++ is the { }
initializer. Conditional definition to the rescue.
* lib.h (all_zero_init): New macro which expands to
{ } under C++, and { 0 } under C.
* lib.c (make_time_impl, epoch_tm, time_string_meth,
time_parse_meth): Use all_zero_init.
* parser.c (prime_parser): Likewise.
* socket.c (sock_mark_connected): Likewise.
* sysif.c (fcntl_wrap): Likewise.
* termios.c (encode_speeds, decode_speeds): Likewise.
* configure (diag_flags): Add -Wextra.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is the second round of an effort to enable GCC's -Wextra
option. All function parameters that are unused and
are removable are removed. They are eliminated from the
function defintions, declarations, callers, and any related
function pointer variables or structure members.
* arith.c (nary_simple_op): Remove unused self parameter.
See lib.c: maxv, minv.
* chksum.c (crc32_buf, crc32_str): Remove unused self
parameter.
(crc32): Don't pass self to the above functions.
* eval.c (copy_env_handler, copy_bh_env_handler): Remove
unused parent parameter. See unwind.c.
(supplement_op_syms): Remove unused max parameter.
(me_op): Don't pass max to supplement_op_syms.
* lib.c (seq_iter_rewind): Remove unused self parameter.
(lazy_flatten_func): Remove unused env parameter.
(lazy_flatten): Use func_n1 to create non-environment-carrying
funtion out of lazy_flatten_func.
(maxv, minv): Don't pass self parameter to nary_simple_op.
(middle_pivot): Remove unused lessfun param.
(quicksort): Don't pass lessfun to middle_pivot.
(diff, isec): Don't pass self to seq_iter_rewind.
* lib.h (seq_iter_rewind, nary_simple_op): Declarations
updated.
* struct.c (get_super_slots): Remove unused self parameteer.
(make_struct_type): Don't pass self to get_super_slots.
* sysif.c (flock_unpack): Remove unused self parameter.
(fcntl_wrap): Don't pass self to flock_unpack.
* unwind.c (uw_push_cont_copy): Remove parent parameter from
function pointer parameter. See eval.c: copy_env_handler.
(call_copy_handlers): Remove parent parameter and don't
pass that argument to the indirect call via pointer
to the copy handler function.
(revive_cont, capture_cont): Don't pass 0 value to
removed parent parameter of call_copy_handlers.
* unwind.h (struct uw_cont_copy): Function pointer member copy
loses parent parameter.
(uw_push_cont_copy): Declaration updated.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Harmonizes with starts-with and ends-with.
* eval.c (eval_init): Register contains intrinsic.
* lib.c (contains): New function.
* lib.h (contains): Delared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
An object of args type captures into the heap the "struct
args" argument list that normally appears only on the stack.
Such an object also has space for a car and cdr field,
which can come in handy.
* args.c (dyn_args): New function: hoist a struct args *
into an args heap object.
* args.h (dyn_args): Declared.
* gc.c (finalize, mark_obj): Handle DARGS type code.
* hash.c (equal_hash): Handle DARG via eq equivalence.
* lib.c (args_s): New symbol variable.
(code2type): Map DARG to args symbol.
(equal): Handle DARG type, using eq equivalence for now.
(obj_init): Initialize args_s with interned symbol.
* lib.h (enum type, type_t): New type code, DARG.
(struct dyn_args): New struct.
(union obj): New member, a of type struct dyn_args.
* txr.1: Documented args type under typeof.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The various curry_xx_yy functions perform partial application,
not currying. The curry prefix is being renamed to pa
(partially apply).
* lib.c (remq_lazy, remql_lazy, remqual_lazy, tree_Find):
Updated.
(do_curry_12_1, do_curry_12_1_v, do_curry_12_2,
do_curry_123_1, do_curry_123_23, do_curry_123_2,
do_curry_123_3, do_curry_1234_1, do_curry_1234_34):
Renamed to do_pa_12_1, do_pa_12_1_v, do_pa_12_2, do_pa_123_1,
do_pa_123_23, do_pa_123_2, do_pa_123_3, do_pa_1234_1,
do_pa_1234_34.
(curry_12_1, curry_12_1_v, curry_12_2, curry_123_1,
curry_123_23, curry_123_2, curry_123_3, curry_1234_1,
curry_1234_34): Renamed to pa_12_1, pa_12_1_v, pa_12_2,
pa_123_1, pa_123_23, pa_123_2, pa_123_3, pa_1234_1,
pa_1234_34.
(transposev, do_juxt): Updated.
* lib.h: Declarations renamed.
* eval.c (subst_vars, qquote_init, expand_catch, weavev):
Updated.
* filter.c (get_filter, build_filter_from_list,
filter_string_tree, filter_init): Updated.
* match.c (tx_subst_vars, do_txeval, v_freeform, v_bind,
v_throw, v_deffilter, v_assert, h_assert): Updated.
* parser.y (gather_clause): Updated.
* regex.c (regex_range_full_fun, regex_range_left_fun,
regex_range_right_fun, regex_range_search_fun): Updated.
* stream.c (open_files, open_files_star): Updated.
* txr.c (txr_main): Updated.
* unwind.c (me_defex): Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
TXR Lisp is henceforth a dialect in which
(cdr (assq key a-list))
works exactly as shown, without substitution of
assql or assoc.
* eval.c (eval_init): Register assq and rassq intrinsics.
* lib.c (assq, rassq): New functions.
* lib.h (assq, rassq): Declared.
* txr.1: Documented.
* tests/012/ashwin.tl: New file.
* tests/012/ashwin.expected: New file.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register meq, meql an mequal intrinsics.
* lib.c (meq, meql, mequal): New functions.
* lib.h (meq, meql, mequal): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a useful function which supports the use of temporary
packages over the scope of file compilation units.
A file can be read under a temporary package which provides
usefully customized symbol visibility consisting of
an arrangement of symbols from various other packages.
Then, in a single operation, thanks to this new function,
that packag can be deleted and all of its local symbols
(those having been newly interned over the course of the
file) are transferred to some other, more permanent package.
* eval.c (eval_init): merge-delete-package intrinsic
registered.
* lib.c (merge_delete_package): New function.
* lib.h (merge_delete_package): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register coded-length intrinsic.
* lib.c (coded_length): New function.
* lib.h (coded_length): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* LICENSE, LICENSE-CYG, METALICENSE, Makefile, alloca.h, args.c,
args.h, arith.c, arith.h, buf.c, buf.h, cadr.c, cadr.h,
chksum.c, chksum.h, chksums/crc32.c, chksums/crc32.h, combi.c,
combi.h, configure, debug.c, debug.h, eval.c, eval.h, ffi.c,
ffi.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c,
glob.h, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lib.c,
lib.h, linenoise/linenoise.c, linenoise/linenoise.h,
lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h,
parser.l, parser.y, protsym.c, rand.c, rand.h, regex.c,
regex.h, share/txr/stdlib/asm.tl, share/txr/stdlib/awk.tl,
share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl,
share/txr/stdlib/compiler.tl, share/txr/stdlib/conv.tl,
share/txr/stdlib/debugger.tl, share/txr/stdlib/defset.tl,
share/txr/stdlib/doloop.tl, share/txr/stdlib/error.tl,
share/txr/stdlib/except.tl, share/txr/stdlib/ffi.tl,
share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl,
share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl,
share/txr/stdlib/keyparams.tl, share/txr/stdlib/op.tl,
share/txr/stdlib/package.tl, share/txr/stdlib/param.tl,
share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl,
share/txr/stdlib/pmac.tl, share/txr/stdlib/save-exe.tl,
share/txr/stdlib/socket.tl, share/txr/stdlib/stream-wrap.tl,
share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl,
share/txr/stdlib/termios.tl, share/txr/stdlib/trace.tl,
share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl,
share/txr/stdlib/vm-param.tl,
share/txr/stdlib/with-resources.tl,
share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl,
signal.c, signal.h, socket.c, socket.h, stream.c, stream.h,
struct.c, struct.h, strudel.c, strudel.h, sysif.c, sysif.h,
syslog.c, syslog.h, termios.c, termios.h, tree.c, tree.h,
txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, vm.c,
vm.h, vmop.h, win/cleansvg.txr: Extended copyright notices
to 2020.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (sinh_s, cosh_s, tanh_s, asinh_s, acosh_s, atanh_s):
New symbol variables.
(sinh, cosh, tanh, asinh, acosh, atanh): New static functions.
(sineh, cosih, tangh, asineh, acosih, atangh): New functions.
(arith_init): Register sinh, cosh, tanh, asinh, acosh and
atanh intrinsic functions, and initialize the new symbol
variables.
* configure: Detect availability of hyperbolic functions in
math library and defne HAVE_HYPERBOLICS as 1 in config.h
accordingly.
* lib.h (sineh, cosih, tangh, asineh, acosih, atangh):
Declared.
* txr.1: Documented new hyperbolic functions and their method
counterparts that a numeric struct can implement.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
An version of identity with lax argument conventions.
* eval.c (eval_init): Register identity* intrinsic.
* lib.c (identity_star_f): New symbol variable.
(identity_star): New function.
(obj_init): gc-protect identity_star_f variable, and
initialize it.
* lib.h (identity_star_f): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
| |
* lib.h (FIXPARAM_MAX): Switch constant to signed type.
* lib.c (func_vm): Use num instead of unum on FIXPARAM_MAX,
since we are making it signed.
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (us_nreverse): New function.
* lib.h (us_nreverse): Declared.
* parser.y (clauses_opt, n_exprs, r_exprs): Use us_nreverse
instead of nreverse to rorder lists built in reverse into
final shape.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register intrinsic functions
fun-fixparam-count, fun-optparam-count, fun-variadic.
* lib.c (get_param_counts): New static function.
(fun_fixparam_count, fun_optparam_count, fun_variadic): New
functions.
* lib.h (fun_fixparam_count, fun_optparam_count,
fun_variadic): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Functions can only have 127 fixed parameters; some code
ignores this when assigning to the bitfield.
* lib.h (FIXPARAM_BITS, FIXPARAM_MAX): New preprocessor
symbols.
(struct func): Use FIXPARAM_BITS for defining fixparam and
optargs bitfields instead of hard-coded 7.
* lib.c (func_vm): Sanity check the fixparam and reqags
parameters: 0 <= reqargs <= fixparam <= FIXPARAM_MAX.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register copy-tree intrinsic.
* lib.c (copy_tree): New function.
* lib.h (copy_tree): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
One consequence of this is that we no longer pass negative
values to vecref; that functon was protecting us from the
consequences of this signed/unsigned mixup, at the cost of
cyles.
* hash.c (struct hash_ops): hash parameter in assoc_fun and
acons_new_c_fun pointers changes from cnum to ucnum.
(hash_assoc, hash_assql, hash_assq): hash parameter changes to
ucnum.
(hash_acons_new_c, hash_aconsql_new_c, hash_aconsq_new_c):
Likewise.
(gethash_c, gethash_e, remhash): Variable which captures the output of the hashing
function is now ucnum instead of cnum.
* lib.h (struct cons_hash_entry): Member hash changes from
cnum to ucnum.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch fixes numerous instances of a safety hole which
involves the type of a COBJ object being tested to be of
a given class using logic that can be subverted by the
definition of a like-named struct.
Specifically logic like (typeof(obj) == hash_s) is broken,
because if a struct type called hash is defined, then the test
will yield true for instances of that struct type. Those
instances can then be passed into code that only works on COBJ
hashes, and relies on this test to reject invalid objects.
* ffi.c (make_carray): Replace fragile test with strong one,
using new cobjclassp function.
* hash.c (hashp): Likewise.
* lib.c (class_check): The expression used here for the type
test moves into the new function cobjclassp and so is replaced
by a call to that function.
(cobjclassp): New function.
* lib.h (cobjclassp): Declared.
* rand.c (random_state_p): Replace fragile test using
cobjclassp.
* regex.c (char_set_compile): Replace fragile typeof tests
for character type with is_chr.
(reg_derivative, regexp): Replace fragile test with cobjclassp.
* struct.c (struct_type_p): Replace fragile test with cobjclassp.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Binary search tree nodes are being added as a basic heap data
type. The C type tag is TNOD, and the Lisp type is tnode.
Binary search tree nodes have three elements: a key, a left
child and a right child.
The printed notation is #N(key left right). Quasiquoting
is supported: ^#N(,foo ,bar) but not splicing.
Because tnodes have three elements, they they fit into TXR's
four-word heap cell, not requiring any additional memory
allocation.
These nodes are going to be the basis for a binary search tree
container, which will use the scapegoat tree algorithm for
maintaining balance.
* tree.c, tree.h: New files.
* Makefile (OBJS): Adding tree.o.
* eval.c (expand_qquote_rec): Recurse through tnode cells,
so unquotes work inside #N syntax.
* gc.c (finalize): Add TNOD to no-op case in switch; tnodes
don't require finalization.
(mark_obj): Traverse tnode cell.
* hash.c (equal_hash): Add TNOD case.
* lib.c (tnode_s): New symbol variable.
(seq_kind_tab): New entry for TNOD, mapping to SEQ_NOTSEQ.
(code2type, equal): Handle TNOD.
(obj_init): Initialize tnode_s variable.
(obj_print_impl, populate_obj_hash): Handle TNOD.
(init): Call tree_init function in tree.c.
* lib.h (enum type, type_t): New enumeration TNOD.
(struct tnod): New struct type.
(union obj, obj_t): New union member tn of type struct tnod.
(tnode_s): Declard.
* parserc.c (circ_backpatch): Handle TNOD, so circular
notation works through tnode cells.
* parser.l (grammar): Recognize #N prefix, mapping to
HASH_N token.
* parser.y (HASH_N): New grammar terminal symbol.
(tnode): New nonterminal symbol.
(i_expr, n_expr): Add tnode cases to productions.
(yybadtoken): Map HASH_N to "#N" string.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* configure: In several config tests, test HAVE_SUPERLONG_T,
HAVE_LONGLONG_T and HAVE_SYS_WAIT with #if.
* lib.c: Test HAVE_GETENVIRONMENTSTRINGS with #if.
* lib.h: Test HAVE_DOUBLE_INTPTR_T with #if.
* mpi/mpi.c: Likewise.
* mpi/mpi.h: Likewise.
* socket.c: Test HAVE_GETADDRINFO with #if in three places.
* stream.c: Test HAVE_SYS_WAIT and HAVE_SOCKETS with #if.
|
|
|
|
|
|
|
|
|
|
| |
Only struct.c refers to this symbol, and so only struct.c
needs to be recompiled when someone experiments with different
values.
* lib.h (SLOT_CACHE_SIZE): Macro deleted here.
* struct.c (SLOT_CACHE_SIZE): Macro moved here.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register tailp intrinsic.
* lib.c (tailp): New function.
* lib.h (tailp): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register cptr-buf intrinsic.
* lib.c (cptr_buf): New function.
* lib.h (cptr_buf): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
To accompany find-symbol-fb, there is intern-fb, which is like
intern, but searches the fallback list.
* eval.c (eval_init): Register intern-fb intrinsic.
* lib.c (intern_fallback_intrinsic): New function. Does
defaulting and error checks, then calls intern_fallback, just
like intern_intrinsic calls intern.
* lib.h (intern_fallback_intrinsic): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We get rid of some defaulting and error checks from interning.
This saves a few cycles on startup in the large number of
intern calls that are performed.
* eval.c (eval_init): Wire the intern intrinsic to the new
intern_intrinsic function rather than intern.
* lib.c (intern): Remove package lookup and error check on str
argument.
(intern_intrinsic): New function, which has the package lookup
and error check.
(intern_fallback): Remove package lookup and error check.
* lib.h (intern_intrinsic): Declared.
* txr.c (txr_main): Fix one instance of an intern call that
relies on defaulting of the second argument, by passing
cur_package.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Turns out, there is already a find_symbol in lib.c, completely
unused.
* eval.c (eval_init): Register find-symbol and find-symbol-fb
intrinsics.
* lib.c (find_symbol): Fix this hitherto unused function to do
correct defaulting of the package argument and, to accept an
additional argument specifying the not-found value.
(find_symbol_fb): New function.
* lib.c (find_symbol): Declaration updated.
(find_symbol_fb): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
| |
* lib.h (struct seq_iter): union ul with just one member
replaced by that member itself.
* lib.c (seq_iter_get_vec, seq_iter_peek_vec, seq_iter_init):
refer to it->len instead of it->ul.len.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit adds support for working with foreign structures
which use the C99 "flexible array member", or possibly the
old "C struct hack". Some improvements are made in the FFI
code the area of incomplete types and bitfields.
* ffi.c (struct txr_ffi_type): New flag members incomplete
and bitfield.
(ffi_varray_dynsize): Check incomplete type flag rather than
for zero size.
(ffi_flex_dynsize, ffi_flex_alloc, ffi_flex_struct_in): New static functions.
(ffi_struct_in): Call ffi_flex_struct_in when doing by-value
semantics on a flexible structure, just before converting last
member. This checks for the length method, calls it, and
adjusts the last member object as documented.
(ffi_struct_get): Likewise.
(bitfield_syntax_p): Static function removed; there is a
flag for this now in the type, so no need to parse its
syntax.
(make_ffi_type_pointer): Test bitfield flag rather than
using bitfield_syntax_p.
(make_ffi_type_struct): Take new argument indicating that the
struct is flexible. Wire in appropriate virtual functions
based on this flag, and set the type's incomplete flag
accordingly. Check bitfield flag rather than using
bitfield_syntax_p for detecting bitfield members.
Calculate the size of flexible struct differently: it is
the offset of the last member.
(make_ffi_type_union): Test bitfield flag rather than
using bitfield_syntax_p.
(ffi_struct_compile): Renamed to ffi_membs_compile.
(ffi_membs_compile): New pointer parameter for returning an
indication whether the member list specifies a flexible
struct. Test the incomplete flag of a member type rather than
size being zero.
(ffi_type_compile): Follow rename of ffi_struct_compile to
ffi_membs_compile. Pass down the flag obtained from
ffi_membs_compile into make_ffi_type_struct so that a flexible
struct type is created when necessary. Disallow arrays of
bitfields. Set bitfield flag on bitfield types.
(ffi_init_types): Set incomplete flag on void type.
(ffi_make_call_desc): Test for incomplete and bitfield types
using new flags.
(ffi_typedef, ffi_size, ffi_alignof): Test for bitfield type
using new bitfield flag.
(carray_elem_check): New static function.
(carray_buf, carray_pun, carray_unum, carray_num): Use new
carray_elem_check to check for bad array element type. This
uses the incomplete flag rather than checking for zero size,
and also disallows bitfields.
* lib.h (length_s): Declared.
* txr.1: Flexible structs documented in new section. Also
section on incomplete types. Description of sizeof operator
gives more detaild about incomplete types including flexible
structs.
|
|
|
|
|
|
|
|
|
| |
* lib.c (list_collect): Handle sequence-like COBJ objects.
We can add an item to using their respective replace
functions.
(replace_obj): Change to external linkage.
* lib.h (replace_obj): Declared.
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (bitset_s): New symbol variable.
(bitset): New function.
(arith_init): bitset_s initialized, bitset intrinsic
registered.
* lib.h (bitset): Declared.
* txr.1: Documented bitset function and method.
|
|
|
|
|
|
| |
* lib.c (toseq): Function removed.
* lib.h (toseq): Declaration removed.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (seq_iter_peek_nil, seq_iter_peek_list,
seq_iter_peek_vec, seq_iter_peek_hash): New static functions.
(seq_geti): New function.
(seq_iter_init): Initialize new peek member of seq_iter
structure.
* lib.h (struct seq_iter): New member, peek.
(seq_peek): New inline function.
(seq_geti): Declared.
|
|
|
|
| |
* lib.h (maxint, minint): Remove unused macros.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Several new more specific exception types are derived from
file-error and used. Error handlers can distinguish unexpected
non-existence, unexpected existence and permission errors
from each other and other errors.
* lib.c (path_not_found_s, path_exists_s, path_permission_s):
New symbol variables.
(obj_init): New variables initialized.
* lib.h (path_not_found_s, path_exists_s, path_permission_s):
Declared.
* parser.c (open_txr_file): Use new errno_to_file_error
function to convert errno to exception symbol.
* socket.c (open_sockfd): Likewise.
* stream.c (open_directory, open_file, open_fileno,
open_command, open_process, run, remove_path, rename_path):
Likewise, and process-error is used in open_process and run
instead of file-error for problems related to creating the
process.
* sysif.c (errno_to_file_error): New function.
(mkdir_wrap, ensure_dir, chdir_wrap, getcwd_wrap, mknod_wrap,
chmod_wrap, symlink_wrap, link_wrap, readlink_wrap, stat_impl,
umask_wrap, ): Use
errno_to_file_error to convert errno to exception symbol.
(exec_wrap): Use process-error instead of file-error.
* sysif.c (errno_to_file_error): Declared.
* unwind.c (uw_init): Register path-not-found, path-exists and
path-permission as subtypes of file-error.
* txr.1: Documented.
|