| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
* eval.c (eval_init): bugfix: for the functions
package-symbols, package-local-symbols and
package-foreign-symbols, make the package parameter optional,
as is specified in the documentation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The motivation here is that if we define, say, a macro whose
name is the same as a built-in function, we get a warning
which misleadingly uses the word "redefining".
* eval.c (builtin_reject_test): Add a new parameter which
indicates what kind of binding is being defined. This has the
same values as the builtin hash. If the builtin hash reports
that the symbol is a builtin, we can issue one of two
diagnostic messages based on whether the one being defined is
of the same kind or noto.
(expand_macrolet): Pass the defmacro symbol to
builtin_reject_test, since macros are being defined.
(expand_fbind_vars): Pass the defun symbol symbol to
builtin_reject_test.
(do_expand): In the defun/defmacro case, pass the operator in
question to builtin_reject_test.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The eval function uses a null macro environment for expanding
a form, even when it's given an environment object. This
causes spurious warnings about unbound variables/functions.
For instance:
(let ((env (make-env '((x . 42)) nil nil)))
(eval '(+ x x) env)) ;; warning: unbound variable x
To fix this, we have to create a macro version of the
incoming environment and expand with that.
* eval.c (env_to_menv): Take an evaluation environment chain
and convert it to a (flattened) macro environment.
(expand_eval): Take a macro environment parameter and use
that for expanding the form to be evaluated, rather than nil.
(eval_intrinsic): Calculate a macro environment corresponding
to the given evaluation environment. Use that for the
macroexpand call, and also pass it down to expand_eval
to be used for the full expansion.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (op_dohash): Use hash_iter instead of consing up
heap-allocated hash iterator.
* filter.c (trie_compress, regex_from_trie): Likewise.
* hash.c (hash_equal_op, hash_hash_op, hash_print_op):
Likewise.
* lib.c (package_local_symbols, package_foreign_symbols,
find_max, find_if, rfind_if, populate_obj_hash): Likewise.
* parser.c (circ_backpatch, get_visible_syms): Likewise.
* struct.c (method_name, get_slot_syms): Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Issue: (sys:lisp1-value x) throws a warning even if x is a
predefined library function. This is caused by naively using
expand to attempt to expand it as a symbol macro.
* eval.c (expand_lisp1_value): Use expand_lisp1 instead of
expand, just like expand_forms_lisp1. Because I didn't notice
this problem when adding those two functions, expand_lisp1 is
farther down the file and we need a forward declaration.
(expand_lisp1_setq): Likewise, and eliminate the unbound
variable check which is done by expand_lisp1.
|
|
|
|
|
| |
* eval.c (expand): Call sig_check_fast so that if the expander
gets into some kind of loop, it is interruptible.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register copy-tree intrinsic.
* lib.c (copy_tree): New function.
* lib.h (copy_tree): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
| |
* eval.c (eval_intrinsic): macroexpand must be called with the
nil environment. If we had a macro env parameter, we could
pass that. In any case, we mustn't pass an eval environment to
the expander.
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Initialize origin_hash as eq-based hash
table, not eql-based. The main culprit are range #R(x y)
objects. eql equality recurses over these, and if it
encounters a circular one like #R(#1# #1#), it crashes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (tree_lit_s, tree_construct_s): New symbol variables.
(expand_qquote_rec): Handle sys:tree-lit syntax generated by
quasi-quoted #T notaton by expanding and converting to
sys:tree-constuct call.
(eval_init): Initialize tree_lit_s and tree_construct_s.
* eval.h (tree_lit_s, tree_construct_s): Declared.
* parser.y (tree): Produce sys:tree-lit syntax when #T is
quasi-quoted, and unquotes occur inside it.
* tree.c (tree_construct_fname, tree_construct): New static
functions.
(tree_init): Register sys:tree-construct intrinsic function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (lookup_fun): Check for a lambda expression and
return a faked binding containing the interpreted function.
(do_eval, op_fun): Remove checks for lambda that are now
being done in lookup_fun. In many other places where
lookup_fun is used, we still need lambda checks, like
in the expander.
* share/txr/stdlib/place.tl (sys:get-fun-getter-setter): Take
form argument. Diagnose assignments to lambda, and to unknown
function place syntax.
(defplace symbol-function): Pass sys:*pl-form* to
sys:get-fun-getter-setter as form argument.
* txr.1: fboundp and symbol-function doc updated.
|
|
|
|
|
|
| |
* eval.c (op_fun): Don't cons up a fake fbinding when
processing lambda; just return result of func_interp.
Test for null fbinding consolidated, too.
|
|
|
|
|
|
|
|
| |
* eval.c (lookup_fun); Use iteration to search the nested
environments. Put this code ahead of the global search
so we fall back on it. Also, let's check for a compound
function name first, so we don't search the environments for
this.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (func_get_name): when func_get_name has a nil
function argument and nil env, it falls back on method_name,
which naively searches its space and finds some static slots
with a nil value which is then returned as a method name.
Let's put in a type check that the argument must be a
function. Also, let's drop the recursion in the nested
environment search and switch to iteration, so we don't do
these wasteful sanity checks on multiple re-entries of the
function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Adding binary search trees based on the new tnode cell. The
scapegoat algorithm is used, which requires no additional
storage in a cell. In the future we may go to something else,
like red-black trees, and carve out a bit in the tag field
of the cell for the red/black color.
Tree cells store only single key objects, not key/value pairs.
However, which part of the key object is compared is
determined by a custom key function stored in the tree
container. For instance, tree nodes can be cons cells, and car
can be used as the key function; the cdr then stores an
associated value.
Trees have a printed notation
#T(<props> <key>*)
where <props> is a list of up to three items:
<props> ::= ([<key-fn> [<less-fn> [<equal-fn>]]])
key-fn, less-fn and equal-fn are function names.
If they are missing or nil, they default, respectively, to
identity, less and equal.
For security, the printed notation is machine-readable only if
these options are symbols, not lambda expressions.
Furthermore, the symbols must be listed in the special
variable *tree-fun-whitelist*.
* eval.c (less_s): New symbol variable.
(eval_init): Initialize less_s.
* eval.h (less_s): Declard.
* parser.h (grammar): New #T token recognized, mapped to
HASH_T.
* parser.y (HASH_T): New terminal symbol.
(tree): New non-terminal symbol.
(i_expr, n_expr): Add tree to productions.
(fname_helper): New static function.
(yybadtoken): Map HASH_T to "#T".
* protsym.c: Tweaked accidentally; remove.
* tree.c (TREE_DEPTH_MAX): New macro.
(struct tree): New struct type.
(enum tree_iter_state): New enumeration.
(struct tree_iter): New struct type.
(tree_iter_init): New macro.
(tree_s, tree_fun_whitelist_s): New symbol variables.
(tn_size, tn_size_one_child, tn_lookup, tn_find_next,
tn_flatten, tn_build_tree, tr_rebuild,
tr_find_rebuild_scapegoat, tr_insert, tr_lookup, tr_do_delete,
tr_delete, tree_insert_node, tree_insert, tree_lookup_node,
tree_lookup, tree_delete, tree_root, tree_equal_op,
tree_print_op, tree_mark, tree_hash_op): New static functions.
(tree_ops): New static struct.
(tree): New function.
(tree_init): Initialize tree_s and tree_fun_whitelist_s symbol
variables. Register intrinsic functions tree,
tree-insert-node, tree-insert, tree-lookup-node, tree-lookup,
tree-delete, tree-root. Register special variable
*tree-fun-whitelist*.
* tree.h (tree_s, tree_fun_whitelist_s, tree): Declared.
(tree_fun_whitelist): New macro.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register tailp intrinsic.
* lib.c (tailp): New function.
* lib.h (tailp): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
| |
* eval.c (bindings_helper): If there are no bindings or just
one binding, then go through the sequential case. Thus trivial
let is treated like let*. This avoids the continuation-related
overheads incurred in the parallel case.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This was discovered by user vapnik spaknik. If a let* form is
evaluated in a top-level expression such that the incoming
environment is null, and a continuation is captured in the
init-form of the first variable, when that continuation is
invoked, an exception is thrown: "copy-env: nil is not of type
env".
Short repro:
1> (block nil (let* ((x (yield 42)))))
** copy-env: nil is not of type env
In fact, the bug isn't that we're trying to copy nil.
the problem is we are trying to copy an environment we should
not be copying at all. In fact, for sequential binding,
there is no need for that logic at all; it's only parallel
binding which needs it, because all of the init-forms are
inserting bindings into the same environment.
* eval.c (bindings_helper): Don't bother with registering a
copy handler for sequential binding logic, because we
don't mutate environments. All of that code is moved into the
parallel case.
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
| |
* eval.c (expand): Do not create expansion debug frames
for atomic forms, only for compound forms.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (do_expand): In the expansion logic for function
calls, after we have done the dot-to-apply transform,
we must thereafter consistently refer to the new front element
of the form insym, and not the original element sym.
The first element may be a lambda form moved into the second
position by dot-to-apply. We then falsely warn about that
being in the operator position. Test case: ((lambda ()) . 3).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This was broken on April 21, 2019 in commit
2e36e0feae8d1dd75c8410b365d7dc33b30ce66b (April 21, 2019)
which changed parse_once in such a way that the name
being passed down was no longer stored in the parser.
The ensure_parser function being relied upon doesn't take on
the responsibility of propagating the name from the stream
to the parser, so the parser ends up with a nil name.
Let's just smooth this over by having ensure_parser take
a name parameter. If ensure_parser creates a new parser, it
puts in the name. If the name is nil, then it is
taken from the stream.
* eval.c (load): Pass name to ensure_parser.
* match.c (v_load): Likewise.
* parser.c (parser): Take name parameter, and plant into newly
constructed parser.
(ensure_parser): Take name parameter. When creating a parser,
give it that name, or if name is specified as nil, then
give it the name taken from the stream.
(parser_set_lineno): Pass nil name to ensure_parser.
(lisp_parse_impl, read_file_common): Pass name to
ensure_parser.
* parser.h (parser, ensure_parser): Declarations updated.
* parser.y (parse_once): Pass name to ensure_parser.
* txr.c (txr_main): Pass spec_file_str to ensure_parser.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The motivation here is that there are behaviors in the
expander which hinder symbol-macro-based renaming techniques.
For instance (expand '(symacrolet ((x y)) (sys:setq x x)))
throws. The right hand side of the setq is fine, but the left
hand one is a forbidden symbol macro. Yet, we would just like
this to expand to (sys:setq y y). The original idea was that
sys:setq occurs as a result of macro-expansion. Therefore,
if its argument is a symbol macro, something must be wrong; it
didn't get expanded. That reasoning is wrong in the face of
explicit expansion techniques that make multiple expansion
passes. For instance (set a b) can become something like
(sys:setq #:g0005 #:g0007) when the intent that in another round
of renaming these gensyms will be defined as symbol macros
which perform one more renaming.
* eval.c (expand_lisp1_value, expand_lisp1_setq): Macro-expand
the symbol and work with the expanded one. We still keep the
check for a symbol macro; these situations can arise if a
symbol macro cannot expand due to circularity.
(do_expand): When checking sys:setq for a bad symbol or symbol
macro, work with the expanded argument.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This slight inefficiency occurs in some 37 places in the code.
In most places we replace lt(x, zero) with minusp(x).
In a few places, !plusp(x) is used and surrounding logic is
simplified. In one case, the silly pattern
lt(x, zero) ? t : nil is replaced with just minusp(x).
* buf.c (sub_buf, replace_buf): Replace lt.
* combi.c (perm, rperm, comb, rcomb): Likewise.
* eval.c (do_format_field): Likewise.
* lib.c (listref, sub_list, replace_list, split_func,
split_star_func, match_str, lazy_sub-str, sub_str,
replace_str, sub_vec, replace_vec): Likewise.
* match.c (weird_merge): Likewise.
* regex.c (match_regex, match_regex_right_old,
match_regex_right, regex_prefix_match, regex_range_left,
regex_range_right): Likewise.
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (load): Bind *load-path* to the real path that was
used to open the file, not to the tentative path to which
the .tl suffix was added, subject to compatibility option.
* txr.1: Documentation for load revised for better wording and
to document the above change. Fixed *load-path* being wrongly
called a macro, and also load being called a macro.
Compat note added.
|
|
|
|
|
|
| |
* eval.c (me_interp_macro): Combine initialization and
assignment into one. There was previously code between the two
that got removed when the old debugger was scrubbed.
|
|
|
|
|
|
| |
* eval.c (do_eval_args): Since function call expressions all
undergo the dot-to-apply transform, there is no need
look for a form in the dot position.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Refactorings to apply released TXR 192 broke it, causing apply
to fail to treat non-list sequences as individual arguments,
as documented. This affects dotted application as well.
;; wrong
(list . "abc") -> "abc"
;; correct
(list . "abc") -> (#\a #\b #\c)
With some misgivings, I'm not making the behavior subject
to the -C compat option.
* eval.c (applyv): Two things are wrong here: we moved the
last fixed argument into args->list without turning it into a
one-element list. Secondly, we didn't pass this list through
apply_intrinsic_frob_args. We can combine both actions into
just calling tolist, which is what apply_intrinsic_frob_args
will do with the car of a one-element list.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch adds special unwind frames for backtracing
expansions. With this, we can get rid of the global variable
last_form_expanded, since to get the last form expanded, we
just search for the most enclosing expand frame.
* eval.c (last_form_expanded): Global variable removed.
(error_trace): Use uw_last_form_expanded() instead of
last_form_expanded.
(expand_eval): No need to save and restore
last_form_expanded any more.
(expand_lisp_setq, expand_setqf, expand_lisp1, do_expand): Use
uw_last_form_expanded().
(expand, do_macroexpand_1): Push and pop expand frame.
This fixes a bug: do_macroexpand_1 was not recording
last_form_expanded. Evaluation of top-level forms uses
explicit macroexpansion, therefore top-level evaluation was
neglecting to set last_form_expanded.
This explains weird behavior I saw in the listener from
time to time, when errors would report against the expansion
of the wrong form.
(eval_init): Remove reference to last_form_expanded variable.
* eval.h (last_form_expanded): Declaration removed.
* share/txr/stdlib/debug.tl (expand-frame print-trace,
expand-frame loc): New methods.
(print-backtrace): Include uw-expand frames in the backtrace.
* unwind.c (expand_frame_type): New static variable.
(uw_find_frames_by_mask): Handle UW_EXPAND.
(uw_last_form_expanded, uw_push_expand): New functions.
(uw_late_init): Register expand-frame struct type.
* unwind.h (enum uw_frtype): New enum member, UW_EXPAND.
(uw_last_form_expanded, uw_push_expand): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (load): When we read and discard a hash bang line,
we must set the parser line number to two.
* parser.c (parser_set_lineno): New function.
* parser.h (parser_set_lineno): Declared.
* txr.c (check_hash_bang): New argument, occurs.
(txr_main): Track whether hash bang has occurred in a new
local variable hb_occurs. Then, before parsing, if hash bang
has occurred, set the line number to two.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This refactoring is needed for fixing the off-by-one
line number bug when the hash bang line is processed.
* eval.c (load): Don't define parser locally; ensure there is
one in the stream and use it.
* match.c (v_load): Likewise.
* parser.c (get_parser_impl): Renamed to parser_get_impl and
changed from internal to external linkage.
(ensure_parser): Changed to external linkage.
(lisp_parser_impl, read_file_common): Follow rename of
get_parser_impl.
* parser.h (parse_once): Declaration updated.
(parser_get_impl, ensure_parser): Declared.
* parser.y (parse_once): Take self parameter; drop parser
parameter. Ensure a parser to the stream, rather than
declaring one locally. Don't clean up the parser when
done, just let the stream clean it up.
* txr.c (parse_once_noerr): Parser argument is dropped and
not passed to parse_once. Program name is passed as self
argument to parse_once.
(txr_main): When parsing the TXR pattern query, don't define a
parser locally; ensure there is one in the stream and use it,
like in load and v_load.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (enum wmap_op): New enum type.
(window_map_list): Use enum wmap_op for last argument instead
of Boolean flag. If the argument is WMAP_MAPDO, do not
accumulate.
(window_map_vec, window_map, window_mapped): Adjust to new
enum argument.
(window_mapdo): New function.
* lib.h (window_mapdo): Declared.
* eval.c (eval_init): window-mapdo intrinsic registered.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We introduce evaluation tracking frames. The backtrace
function can use these to deduce the line from which
a function is called (if called from interpreted code).
Eventually we will have analogous virtual machine
frames to do this for compiled code.
* eval.c (do_eval): If backtraces are enabled, then push
and pop an eval frame, which holds the two key pieces: the
form and environment.
* share/txr/stdlib/debug.tl ((fcall-frame loc), (fcall-frame
print-trace), (eval-frame loc), (eval-frame print-trace)):
New methods.
(print-backtrace): Loop reduced to just dispatching
frame-specific print-trace methods. It gives the previous and
next frame to each method.
The (fcall-frame print-trace) method prints function frames,
using the previous form to deduce the location from which
the function is called. The (eval-frame print-trace) method
mostly suppresses the printing of eval frames. We print
an eval frame if it is the parent of an internal function
frame, and if it is the topmost frame (to identify the
toplevel form at the root of the backtrace).
* unwind.c (form_s): New symbol variable.
(eval_frame_type): New static variable.
(uw_find_frames_by_mask): Handle UW_EVAL case, producing
eval-frame struct.
(uw_push_eval): New function.
(uw_late_init): Allocate eval-frame struct type, storing it in
eval_frame_type, and gc-protect that new variable.
Register uw-eval variable evaluating to a one bit mask
with the UW_EVAL-th bit set.
* unwind.h (enum uw_frtype): New enum constant UW_EVAL.
(struct uw_eval): New struct type.
(union uw_frame): New member, el.
(uw_push_eval): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The interpreted defun should tag the function form that is
obtainable with func-get-form with source location info.
* eval.c (op_defun): In all cases, propagate source loc info
from the form to the function form that is bound to
the function name.
(op_defmacro): Propagate the source location info in the
same manner: not from the body (which could be empty) but from
the form.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* debug.c (debug_state): Switch to unsigned, since this is now
a bitmask.
(sys_print_backtrace_s): New symbol variable.
(dbg_clear, dbg_set, dbg_restore): New static functions.
(debug_init): Initialize sys_print_backtrace_s. Register
dbg-clear, dbg-set, dbg-restore intrinsics. Register
dbg-enable, dbg-step, dbg-backtrace and dbg-all bitmask
variables, Lisp equivalents of DBG_ENABLE, DBG_SETP,
DBG_BACKTRACE and DBG_ALL.
(debug_dump_backtrace): New function.
* debug.h (opt_debugger): Declaration removed.
(debug_state): Declaration updated.
(DBG_ENABLE, DBG_STEP, DBG_BACKTRACE, DBG_ALL): New
preprocessor symbols.
(debug_set_state): Inline function removed.
(debug_clear, debug_set, debug_restore): New inline functions.
(dbg_backtrace, dbg_fcall_begin, dbg_fcall_end): New macros.
(debug_dump_backtrace): Declared.
* eval.c (error_trace): Invoke debug_dump_backtrace if support
is compiled in and backtraces are enabled.
* lib.c (do_generic_funcall): New function, copy of
generic_funcall.
(generic_funcall): Now a wrapper for do_generic_funcall which
registers fcall frames if backtrace support is enabled.
(funcall, funcall1, funcall2, funcall3, funcall4): Route to
slow generic_funcall path if backtraces are enabled.
* lisplib.c (debugger_instantiate, debugger_set_entries):
New static functions.
(lisplib_init): Autload support for debug module via above
new functions.
(lisplib_try_load): Save and restore debugger state in new
way using debug_set and debug_restore, with specific mask
values.
* parser.y (parse_once): Disable debugging in new way.
* share/txr/stdlib/debug.tl New file.
* sighal.h (EJ_DBG_MEMB, EJ_DBG_SAVE, EJ_DBG_REST): New
macros for saving/restoring debug state.
(EJ_OPT_MEMB, EJ_OPT_SAVE, EJ_OPT_REST): Reference the above
macros to include debug state in extended jump context.
* txr.c (help): Document --backtrace and that that -d
implies --backtrace.
(txr_main): Enable debugger using debug_set.
Provide new --backtrace option to enable backtraces only.
* unwind.c (args_s): New symbol variable.
(fcall_frame_type): New static variable.
(unwind_to_exit_point): Save pointer to original frame stack
and restore it when calling error_trace. This is so that
error_trace can walk the stack to collect a backtrace.
(uw_find_frames_by_mask, uw_push_fcall): New functions.
(uw_late_init): Initialize args_s and fcall_frame_type.
gc-protect fcall_frame_type. Register uw-* variables
corresponding to the UW_* frame types.
* unwind.h (uw_frtype_t): New enum constant UW_FCALL.
(struct uw_fcall): New frame structure.
(union uw_frame): New member fc.
(uw_push_fcall, uw_find_frames_by_mask): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (op_catch): Extra argument in sys:catch syntax
specifies an expression that evaluates to a description
field.
(expand_catch): Expand the desc expression in sys:catch
syntax.
* parser.c (read_file_common): Increase acceptance of compiled
files from versions 1-4 to 1-5, since we are now marking
compiled files with version 5.0 rather than 4.0.
* share/txr/stdlib/asm.tl (op-catch catch): Support new
argument in the opcode syntax. Turns out we have a spare field
in the instruction format which was previously set to zero
We can use that for the description. Thus, the instruction
set and VM remain backward compatible: old code works.
* share/txr/stdlib/compiler.tl (compiler comp-catch): Handle
the desc argument introduced into the sys:catch form.
We must compile it as an expression, then inject the code into
the instruction template, and reference the output register of
that code block in the catch instruction.
(%tlo-ver%): Bump up the compiled file version to 5.0.
* share/txr/stdlib/except.tl (usr:catch, catch*): Add desc
argument to generated sys:catch form, specifying it as nil.
* unwind.c (desc_s): New symbol variable.
(uw_find_frames_impl): Set the desc member of the extracted
catch structure from the corresponding field in the catch
frame.
(uw_late_init): Initialize desc_s with interned symbol.
Add desc slot to catch-frame type.
* unwind.h (struct uw_catch): New member, desc.
(uw_catch_begin_w_desc): New macro.
* vm.c (vm_catch): Extract the desc field from the catch
instruction, and use uw_catch_begin_w_desc to propagate that
to the catch frame.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* debug.c (debug_depth, debug_quit_s): Variables removed.
(step_mode, next_depth, breakpoints, last_command, cols):
Static variables removed.
(debug_check): C99 inline instantiation removed.
(help, show_bindings): Static functions removed.
(debug): Function removed.
(debug_set_state): Now takes one int argument, returns int.
It's anticipated that the new debug system will have a
simple on-off switch; there won't be a debug_depth hack.
(debug_restore_state): Function removed.
(debug_init): Emptied.
* debug.h (debug_depth, debug_state_t): Declarations removed.
(debug_enter, debug_leave, debug_return): Macros removed.
(debug_check): Inline function removed.
(debug_set_state): Declaration updated.
(debug_restore_state): Declaration removed.
(debug_frame, debug_end): Macros removed.
* eval.c (do_eval, me_interp_macro): Debugging support scrubbed.
* lisplib.c (lisplib_try_load): Adapt to debug_set_state
interface change.
* match.c (h_fun, do_match_line, v_fun, match_files,
match_fun): Debugging support scrubbed.
* parser.y (parse_once): Adapt to debug_set_state interface
change.
* protsym.c: Regenerated.
* signal.h (debug_depth): Declaration removed.
(EJ_DBG_MEMB, EJ_DBG_SAVE, EJ_DBG_REST): Macros removed.
(EJ_OPT_MEMB, EJ_OPT_SAVE, EJ_OPT_REST): Reduced to
unconditionally empty definitions for future use.
* unwind.c (uw_push_debug): Function removed.
* unwind.h (uw_frtype_t): UW_DBG enum member removed.
(struct uw_debug): struct declaration removed.
(union uw_frame): db member removed.
(uw_push_debug): Declaration removed.
* txr.1: Debugger doc removed.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register cptr-size-hint intrinsic.
* lib.c (cptr_size_hint): New function.
* lib.h (cptr_size_hint): Declared.
* txr.1: Documented.
|