| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
* unwind.c (uw_unwind_to_exit_point): Prior to printing
diagnostics related to an unhandled exception to std_error,
flush std_output. This clarifies the output in situations when
both std_error and std_output go to the same destination, and
the exception occurred while producing output on std_output.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We have a bug in that when an exception occurs in a context
called from obj_print, the guard for stopping continuation
captures across obj_print also unintentially blocks the
unwinding. Let's make the unwinding blockage optional
* unwind.c (uw_unwind_to_exit_point): If a UW_GUARD is
encountered, do not abort if the uw_ok flag is set;
keep unwinding.
(uw_push_guard): New uw_ok argument, initializes the
uw_ok member of a guard frame.
* unwind.h (struct uw_guard): New struct type.
(union uw_frame): New member gu of type struct uw_guard.
(uw_push_guard): Declaration updated.
* ftw.c (ftw_callback): Pass zero as new uw_push_guard
argument: no unwinding across the POSIX library function ftw.
* glob.c (errfunc_thunk): Likewise, no unwinding across
the library function glob.
* lib.c (obj_print): Pass 1 as new uw_push_guard argument:
continuations can't be captured, but unwinding is okay.
|
|
|
|
|
|
|
|
|
| |
* signal.c (set_signal_handler, get_sign_handler): Eliminate
newline in exception messages.
* stream.c (unimpl, formatv): Likewise.
* unwind.c (uw_block_abscond): Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c,
combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c,
filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h,
jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c,
parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h,
share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl,
share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl,
share/txr/stdlib/except.tl, share/txr/stdlib/hash.tl,
share/txr/stdlib/ifa.tl, share/txr/stdlib/path-test.tl,
share/txr/stdlib/place.tl, share/txr/stdlib/socket.tl,
share/txr/stdlib/struct.tl, share/txr/stdlib/termios.tl,
share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl,
share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl,
share/txr/stdlib/yield.tl, signal.c, signal.h, socket.c, socket.h,
stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c,
syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h, unwind.c,
unwind.h, utf8.c, utf8.h: Revert to verbatim 2-Clause BSD.
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (panic_s): New symbol variable.
(obj_init): Initialize panic_s.
* lib.h (panic_s): Declared.
* unwind.c (uw_init): Register panic exception.
* unwind.h (panic): New macro.
|
|
|
|
|
|
|
| |
* unwind.c (revive_cont): When scanning the stack of the
revived continuation to fix up pointers, we can save the
Valgrind validity bits of each word, mark it defined, and then
restore the validity bits.
|
|
|
|
|
| |
* unwind.c (uw_block_abscond): If a UW_GUARD frame
occurs in the search for the abscond point, throw an error.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* unwind.c (uw_continue): Don't take the current frame as an
argument and consequently don't pop the current frame. This
function currently has only one use, the uw_catch_end macro.
* unwind.h (uw_continue): Declaration
updated.
(uw_catch_end): Slight code rearrangement: pop the frame
unconditionally before the test for whether uw_continue must
be called.
|
|
|
|
|
| |
* unwind.c (uw_unwind_to_exit_point): Misspelled
"execute".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If some external function is invoked which can call back
into TXR Lisp, we should guard against the called-back
code from capturing a continuation across the external
stack frames, and also from unwinding across those
frames. This patch prepares a mechanism for this.
* unwind.c (uw_unwind_to_exit_point): Abort with message on
standard error if attempt is made to unwind across UW_GUARD
frame.
(uw_push_guard): New function.
(uw_capture_cont): If the frame search
encounters a UW_GUARD block, an exception is thrown.
* unwind.h (enum uw_frtype): New enum constant, UW_GUARD.
(uw_push_guard): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (timeout_error_s): New symbol variable.
(obj_init): Intern timeout-error, init new variable.
* lib.h (timeout_error_s): Declared.
* socket.c (sock_timeout, sock_send_timeout,
sock_recv_timeout): New static functions.
(sock_load_init): Register sock-send-timeout and
sock-recv-timeout intrinsics.
* stream.c (stdio_maybe_read_error, stdio_maybe_error):
Convert EAGAIN into timeout_error_s.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* unwind.c (unhandled_ex): New static structure.
(unwind_to_exit_point): The code to print the unhandled exception info
and bail the process is moved here out of uw_throw. We do this in the
situation when we have an unhandled exception, which is represented
by the fact that the exception pointer points to the unhandled_ex
structure.
(uw_throw): If unhandled hook isn't a function, we don't abort; we go
through the unwinding and unhandled processing. Also, ditto if the
unhandled function returns, ditto. Unhandled processing is entered
by substituting unhandled_ex for the not-found exception, and
allowing unwind_to_exit point to be called.
* txr.1: Document new behavior for unhandled exceptions
and *unhandled-hook*.
|
|
|
|
|
|
|
| |
* arith.c, cadr.c, debug.c, eval.c, filter.c, gencadr.txr, glob.c,
hash.c, linenoise/linenoise.c, lisplib.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: Remove unncessary header files.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* LICENSE, METALICENSE, Makefile, args.c, args.h, arith.c,
arith.h, cadr.c, cadr.h, combi.c, combi.h, configure,
debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c,
gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h,
lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h,
parser.l, parser.y, rand.c, rand.h, regex.c, regex.h,
share/txr/stdlib/cadr.tl, share/txr/stdlib/except.tl,
share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl,
share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl,
share/txr/stdlib/struct.tl, share/txr/stdlib/txr-case.tl,
share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl,
share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl,
signal.c, signal.h, stream.c, stream.h, struct.c, struct.h,
sysif.c, sysif.h, syslog.c, syslog.h, txr.1, txr.c, txr.h,
unwind.c, unwind.h, utf8.c, utf8.h: Add 2016 copyright.
* linenoise/LICENSE, linenoise/linenoise.c,
linenoise/linenoise.h: Bump one principal author's copyright
from 2014 to 2015. The code is based on a snapshot of 2015
upstream work.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Structs can now have code which executes after an object is
initialized, which is useful for doing work like registering
objects in global lists and whatever, when those actions need
access to the initialized slots of the object.
* share/txr/stdlib/struct.tl (defstruct): Handle :posinit
syntax, by generating lambda as eighth argument of sys:make-struct
call.
* struct.c (struct struct_type): New member, postinitfun.
(struct_init): Adjust registrations of make_struct_type
to account for new parameter. The user visible
make-struct-type is registered as having one optional
argument, for backward compat.
(make_struct_type): New argument, postinitfun. Store this
in the structure. For backward compatibility, the argument
is defaulted.
(struct_type_mark): Mark the new postinitfun member.
(call_postinitfun_chain): New static function.
(make_struct, lazy_struct_init): Call call_postinitfun_chain
after slots are initialized, and after the boa function is
called.
* struct.h (make_struct_type): Declaration updated.
* lib.c (time_init): Pass eighth argument to make_struct type.
* sysif.c (sysif_init): Likewise.
* unwind.c (uw_late_init): Likewise.
* tests/012/struct.tl: Update defstruct expansion test case.
* txr.1: Document new argument of make-struct-type,
and clarify ordering of initfun with regard to
other actions. Likewise, document :postinit, and clarify
ordering of :init actions with regard to other actions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (error_trace): New function. Consolidates
error reporting between unhandled exception handling
in uw_throw, and the catcher in the repl.
(op_defmacro, expand_macrolet): Propagate location info from
body to wrapping block, and to the macro binding. In the
latter function, also to the body that is wrapped by local
macros.
(do_expand, macroexpand_1): Propagate location info from macro
expander to expansion, only taking it from the form if the
macro doesn't supply it.
* eval.h (error_trace): Declared.
* parser.c (repl): Replace error reporting code with call to
error_trace.
* unwind.c (uw_throw): uw_throw: likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (origin_hash): New global variable.
(lookup_origin): New function.
(expand_macro): Enter original form into origin hash, keyed by
new form.
(eval_init): gc-protect and initialize origin_hash.
* eval.h (lookup_origin): Declared.
* parser.c (repl): Report chain of expansions from
last_form_evaled.
* unwind.c (uw_throw): Likewise.
|
|
|
|
|
|
|
|
|
|
|
| |
* unwind.c (revive_cont): Don't just reserve frame_slack
bytes below the continuation for any stack frame, but
clear the bytes to zero. On Cygwin, this fixes a failing
continuation test case. The issue is that the cont_obj
variable in capture_cont lands into this area (implying
it is not captured). When the continuation is revived,
the variable has a garbage value, rather than nil,
as expected.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When continuations are captured/restored in the middle of
variable binding constructs, a hidden problem occurs.
Binding constructs work by allocating an empty environment
and then destructively extending it. Since the environment
is not on the stack, but a referenced object, it doesn't
get deep copied into a continuation. As the continuation is
revived repeatedly, parts of the variable binding code are
repeatedly re-executed, and keep pushing fresh bindings into
the same environment object. Though the new bindings
correctly shadow the old, the old bindings are there and
potentially hang on to garbage.
The solution taken here is to introduce a new kind of frame
for handling the situation: a continuation copy handling
frame. This frame allows functions to register objects to
be copied more deeply if a continuation is captured/revived
across them.
* eval.c (copy_env): New static function.
(copy_env_handler): New static function.
(bind_args, bind_macro_params): Install continuation copy
handling frame for cloning new_env.
(struct bindings_helper_vars): New struct type.
(copy_bh_env_handler): New static function.
(bindings_helper): Install continuation copy handling frame
for de and ne variables which hold environments. The variables
are moved to a struct to facilitate access from the handler.
* eval.h (copy_env): Declared.
* unwind.c (uw_push_cont_copy): New function.
(call_copy_handler): New static function.
(revive_cont): When a continuation is being revived invoke the
copying actions in its continuation copy handling frames,
but not if it is only being temporarily revived for immediate
unwinding.
(capture_cont): After copying the continuation, invoke any
continuation copying frames in the "parent": the original
frames that were captured.
* unwind.h (enum uw_frtype): New type, UW_CONT_COPY.
(struct uw_cont_copy): New struct type.
(union uw_frame): New member cp.
(uw_push_cont_copy): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* unwind.c (revive_cont): Don't wrap cons cell around
passed arg; just pass it directly. We don't need
that convention any more.
* capture_cont: Take functional argument. Pass the captured
continuation to the function. If the function returns,
return whatever it returned. When resuming, return the
continuation argument.
(uw_capture_cont): Take functional second argument
and pass to capture_cont. Context form becomes third
argument.
(uw_late_init): Update registration of sys:capture-cont
to three arguments, two required.
* unwind.h (uw_capture_cont): Declaration updated.
* share/txr/stdlib/yield.tl (sys:yield-impl): Not
needed any more; all this was doing was implementing
a call/cc style interface around sys:capture-cont
which can now be used directly.
(yield-from): Use sys:capture-cont directly.
(suspend): Simplified to the point of triviality
with new sys:capture-cont.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/yield.tl (sys:obtain-impl): Pass
sys:cont-free symbol to each abandoned continuation
to release its stack buffer.
(obtain): Handle the sys:cont-free symbol in the
lambda, so the initial lambda can be treated
uniformly with continuation functions.
* txr.1: Documented sys:obtain-impl.
* unwind.c (sys_cont_free_s): New symbol variable.
(cont_mark): Check for null stack pointer and avoid marking.
(revive_cont): If arg is sys:cont-free, then free the
continuation and return nil. If the continuation has a null
stack buffer, throw an error.
(uw_late_init): Initialize sys_cont_free_s.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* unwind.c (sys_cont_poison_s): New symbol variable.
(revive_cont): If the argument is the poison symbol, then
unwind through the continuation all the way back to
revive_cont's own block, instead of to the continuation's very
top block. Thus the continuation is not restarted but
completely unwound.
(uw_late_init): Initialize sys_cont_poison_s.
* txr.1: Documented sys:cont-poison.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (sys_abscond_from_s): New symbol variable.
(op_abscond_from): New static function.
(do_expand): Handle abscond-from like return-from.
(eval_init): Initialize sys_abscond_from_s and
register sys:abscond-from operator.
* share/txr/stdlib/yield.tl (yield-from): Use
sys:abscond-from instead of return-from, to avoid
tearing down the continuation's resources that it may
need when restarted.
* txr.1: Documented sys:abscond-from and added
a mention to the Delimited Continuations introduction.
* unwind.c (uw_abscond_to_exit_point): New static function.
(uw_block_abscond): New function.
* unwind.h (uw_block_abscond): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* unwind.c (sys_capture_cont_s): New variable.
(uw_capture_cont): Second argument is now a context
form rather than a symbol; eval_error is used for error
reporting. The form's operator symbol si used in the
error message, or else sys:capture-cont if the
context argument is null or missing.
(uw_late_init): Initialize sys_capture_cont_s.
* unwind.h (uw_capture_cont): Declaration updated.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The issue is that captures from within a restarted
continuation of the same continuation, are using the
restart prompt as the delimiter rather than re-using
captured block of the same name. Thus each successive
capture adds a new frame, causing the size to grow
drastically.
* unwind.c (uw_capture_cont): Allow the existing captured
block to be the delimiter; don't delimit up to
the revive_cont's prompt block of the same name.
|
|
|
|
|
|
|
|
|
|
| |
Without this we don't properly capture some of the context in
some built-in special operator functions like op_for when we
capture up to their implicit blocks.
* unwind.c (capture_cont): Capture an extra region of the
stack above the delimiting block. 32 words seems like a
reasonable fudge value.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* unwind.c (sys_cont_s): New symbol variable.
(uw_pop_block): New function, supporting uw_block_end macro.
Special logic is needed for popping blocks now, because a
block can be a captured stub at the top of a continuation,
which must not be popped in the
regular manner.
(struct cont): New struct type.
(cont_destroy, cont_mark): New static functions.
(cont_ops): New static structure.
(revive_cont, capture_cont): New static functions.
(uw_capture_cont): New functions.
(uw_init): Initialize sys_cont_s.
Register sys:capture-cont intrinsic.
* unwind.h (enum uw_frtype): New enum member
UW_CAPTURED_BLOCK. When a block is captured as a stub copy of
the prompt block of a delimited continuation, its type is
changed from UW_BLOCK to this new type. This does two things:
it makes the block invisible to block-related code that does
nothing with continuations (code that looks for UW_BLOCK
and ignores anything else). Secondly, there is some special
handling related to UW_CAPTURED_BLOCK frames.
(uw_pop_block, uw_capture_cont): Declared.
(uw_block_begin): New local pointer uw_rslt introduced
which helps communicate the result variable over to the
uw_block_end macro (so we don't have to add a variable
argument to the latter).
(uw_block_end): Use uw_pop_block instead of uw_pop_frame.
* txr.1: Documented delimited continuations.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
* eval.c (apply, do_eval): Use ARGS_MIN instead of ARGS_MAX.
* unwind.c (uw_throw): Ditto, when invoking handler.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* unwind.c (uw_find_frame): New function.
(uw_late_init): Registered find-frame intrinsic.
* unwind.h (uw_find_frame): Declared.
* lib.h (default_arg_strict): New inline function.
Will not replace nil value with default.
* txr.1: Documented find-frame.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* unwind.c (types_s, jump_s): New symbol variables.
(frame_type, catch_frame_type, handle_frame_type): New globals
denoting struct types.
(uw_get_frames, uw_invoke_catch): New functions.
(uw_late_init): Initialize new global variables.
Register get-frames and invoke-catch intrinsics.
* unwind.h (uw_get_frames, uw_invoke_catch): Declared.
* txr.1: Documented frame, catch-frame,
handle-frame, get-frames and invoke-catch.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (handler_bind_s): New symbol variable.
(op_handler_bind): New static function.
(do_expand): Traverse handler-bind forms.
(eval_init): Initialize handler_bind_s variable and register handler-bind
operator.
* lisplib.c (except_set_entries, except_instantiate): New functions.
(lisplib_init): Register new functions in dl_table.
* parser.c (intr_s): New symbol variable.
(repl_intr): Throw exception of type intr, rather than error.
This way we can interrupt accidental exception handling loops involving
exceptions derived from error.
(parse_init): Initialize intr_s.
* share/txr/stdlib/except.tl: New file, defines handle macro.
* unwind.c (uw_push_handler): New function.
(invoke_handler): New static function.
(uw_throw): Search loop looks for and processes handlers in addition to
catches.
* unwind.h (uw_frtype_t): New enum member, UW_HANDLE.
(struct uw_catch): Move member visible so it
is in the same position as in struct uw_handler.
(struct uw_handler): New struct type.
(union uw_frame): New member ha of type struct uw_handler.
(uw_push_handler): Function declared.
* txr.1: Added introductory paragraphs to Exception Handling section.
Documented handler-bind and handle. Some minor errors corrected.
|
|
|
|
|
| |
* unwind.c (uw_register_subtype): Error messages should print
symbols with ~s, not the information-losing ~a.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* args.c (args_copy_to_list): New function.
* args.h (ARGS_MIN): New preprocessor symbol.
(args_add_list): New inline function.
(args_copy_to_list): Declared.
* debug.c (debug): Args in debug frame are now struct args *.
Pull them out nondestructively for printing using
args_copy_to_list.
* eval.c (do_eval_args): Fill struct args argument list
rather than returning evaluated list.
Dot position evaluation is handled by installing
the dot position value as args->list.
(do_eval): Allocate args of at least ARGS_MAX for the
call to do_eval_args. Then use generic_funcall to
invoke the function rather than apply.
(eval_args_lisp1): Modified similarly to do_eval_args.
(eval_lisp1): New static function.
(expand_macro): Construct struct args argument list for
the sake of debug_frame.
(op_dwim): Allocate args which are filled by eval_args_lisp1,
and applied to the function/object with generic_funcall.
The object expression is separately evaluated with
eval_lisp1.
* match.c (h_fun, v_fun): Construct struct args arglist for
the sake of debug_frame call.
* unwind.c (uw_push_debug): args argument becomes
struct args *.
* unwind.h (struct uw_debug): args member becomes
struct args *.
(uw_push_debug): Declaration updated.
* txr.1: Update documentation about dot position argument in
function calls. (list . a) now works, which previously didn't.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Function arguments are now allocated on the stack using alloca,
in conjunction with the struct alloc header structure.
The generic_funcall and apply functions are refactored
for this, as are most functions that take variadic arguments.
* args.c (args_add_list, args_cons_list): Functions removed.
(args_normalize, args_normalize_fill): New functions.
(args_get_checked): Draw arguments from list when array runs out.
(args_copy, args_copy_zap): New functions.
* args.h (ARGS_MAX): Reduced to 32.
(ARGS_MIN): New preprocessor symbol.
(args_init): Call args_init_list.
(args_add2, args_add3, args_add4): New inline functions.
(args_more): Take into account list, which may hold additional arguments.
(args_two_more): New inline function.
(args_normalize, args_normalize_fill): Declared.
(args_get_list): Normalize all arguments into one list and return it.
(args_get_rest, args_at, args_atz): New inline functions.
(args_get): Draw arguments from list when array runs out.
(args_clear): New inline function.
* arith.c (maskv): Convert to new args.
* eval.c (APPLY_ARGS): Preprocessor symbol removed.
(bind_args): Converted to accept struct args.
(apply): Function reduced down to trivial adapter which
converts a list of arguments to args, and calls the new
generic_funcall.
(applyv): New static function: struct args wrapper
around apply_intrinsic.
(iapply): Converted to struct args.
(call): Static function removed. The call intrinsic
function binding now goes directly to generic_funcall.
(list_star_intrinsic, interp_fun): Converted to struct args.
(op_catch): Adjustments for bind_args, which requires
a struct args arglist.
(me_op): Must use the new minl and maxl, since minv and maxv
don't take lists any more.
(mapcarv, mappendv, lazy_mapcarv, lazy_mappendv, mapdov,
weavev, or_fun, and_fun, tf, nilf, do_retf, do_apf,
do_ipf, callf, do_mapf, mapf): Converted.
(mapcarl): New function, like the old mapcarv.
(eval_init): call_f initialized from generic_funcall
rather than call. apply registered to applyv rather than
apply_intrinsic. Registrations for zip, hash_from_pairs, vec,
alist-remove, alist-nremove, and throw similarly updated to
new or renamed functions.
* eval.h (interp_fun, mapcarv): Declarations updated.
(mapcarl): Declard.
* hash.c (hashv): Converted to struct args.
(hashl): New function.
(hash_construct): Use hashl, not hashv.
(hash_from_pairs, hash_list, group_by): Converted.
* hash.h (hashv, hash_construct, hash_from_pairs, hash_list,
group_by): Declarations updated.
(hashl): Declared.
* lib.c (appendv, nconcv, lazy_appendv): Converted to
struct args.
(lazy_appendl): New function.
(multi): Converted.
(listv): New function.
(nary_op, plusv, mulv, logandv, logiorv, gtv, ltv, gev, lev,
numeqv, numneqv, maxv, minv): Converted.
(maxl, minl): New functions, like old maxv and minv.
(exptv, gcdv, lcmv, lessv, greaterv, lequalv, gequalv): Converted.
(func_f0v, func_f1v, func_f2v, func_f3v, func_f4v): Converted.
(func_n0v, func_n1v, func_n2v, func_n3v, func_n4v): Converted.
(func_n0v, func_n1v, func_n2v, func_n3v, func_n4v): Converted.
(func_n1ov, func_n2ov, func_n3ov): Converted.
(generic_funcall): Converted to take struct args.
(funcall, funcall1, funcall2, funcall4): Pass stack-allocated
struct args as trailing arguments to variadic functions, and to
generic_funcall.
(do_curry_12_1_v): New struct-args-based static function,
needed to implement curry_12_1_v now.
(curry_12_1_v): Converted.
(transposev): New function based on previous tranpose.
(transpose): Now a wrapper for transposev.
(do_chain, chainv, do_chand, chandv, do_juxt, juxtv,
do_and, andv, do_or, orv, do_not, do_iff): Converted.
(vectorv): New function. Implementation basis for vec intrinsic function.
(alist_removev, alist_nremovev): New functions.
(multi_sort): Switch from mapcarv to mapcarl.
(unique): Converted.
(uniq): Allocate struct args for calling unique.
(obj_init): list_f function now based on new listv, rather than
identity.
* list.h (varg): New typedef.
(struct func): All variadic function pointers converted to use
struct args.
(appendv, nconcv, lazy_appendv, multi, nary_op, plusv, minusv,
mulv, gtv, ltv, gev, lev, numeqv, numneqv, maxv, minv, exptv,
gcdv, lcmv, logadnv, logiorv, maskv, lessv, greaterv, lequalv,
gequalv, func_f0v, func_f1v, func_f2v, func_f3v, func_f4v,
func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_n0v,
func_n1v, func_n2v, func_n3v, func_n4v, func_n1ov, func_n2ov,
func_n3ov, generic_funcall, chainv, chandv, juxtv, adnv, orv,
unique): Declarations updated.
(lazy_appendl, listv, maxl, minl, transposev,
vectorv, alist_removev, alist_nremovev): Declared.
* stream.c (make_catenated_stream_v): New function.
(aformat): Renamed to formatv. The recognition of the nil
and t streams (standard output and string) is done here now.
(vformat): Follow rename of aformat to formatv.
(formatv): Function removed. Nobody calls this anymore.
(stream_init): make-catenated-stream re-registered to new
make_catenated_stream_v function.
* stream.h (formatv): Declaration updated.
(make_catenated_v): Declared.
* syslog.c (syslog_init): syslog registred to syslog_wrapv.
(syslog_wrapv): New function based on syslog_wrap converted to struct
args.
(syslog_wrap): Now wrapper for syslog_wrapv.
* syslog.h (syslog_wrapv): Declared.
* unwind.h (uw_throwv): New function.
(uw_throwfv, uw_errorfv): Converted to struct args.
* unwind.h (uw_throwv): Declared.
(uw_throwfv, uw_errorfv): Declarations updated.
|
|
|
|
|
|
|
|
|
| |
* lib.c (system_error_s): New symbol variable.
(obj_init): Initialize new variable.
* lib.h (system_error_s): Declared.
* unwind.c (uw_init): Register system-error exception type.
|
|
|
|
|
|
|
| |
of multi-line context form.
(apply): Use ~! for proper indentation of function code.
* unwind.c (uw_throw): Use ~! for proper indentation of code.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(eval_error): Derive location of error from
the last_form_evaled, if form doesn't have it.
(eval_init): Re-register source-loc-str as binary with an optional arg.
* match.c (debuglf, sem_error, file_err, typed_error): Default new
argument of source_loc_str.
* parser.h (source_loc_str): Declaration updated.
* parser.l (source_loc_str): Take second argument which specifies
alternative value if the source loc info is not found.
* unwind.c (uw_throw): Simplify code thanks to source_loc_str
default argument.
* txr.1: Document new argument of source-loc-str.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (last_form_expanded): New variable.
(do_expand): New static function; contains previous expand
function.
(expand): Becomes a wrapper for do_expand, with re-entry
counting.
(eval_init): GC-protect last_form_expanded.
* eval.h (last_form_expanded): Declared.
* parser.l (regex_parse, lisp_parse): Just use a simple word for
the name of the regex or string parse location, not the entire
expression itself.
* unwind.c (uw_throw): Check whether expansion was going on
when the unhandled exception was thrown and print additional
information.
|
|
|
|
|
| |
Cautiously, we use fprintf rather than our streams system, in case some
problem with the streams is involved in this mess.
|
|
|
|
| |
exception in early initialization message.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
One upshot of all this is that (throw 'foo "msg") now
does exactly the same thing as (throwf 'foo "msg").
A message-only exception really is a one-string exception argument
list ("message ..."), like the documentation says.
* unwind.h (struct uw_catch): exception member renamed to args.
(uw_catch): Macro follows structure member rename.
* eval.c (op_catch): Removed now unnecessary kludge of turning non-list
exception argument list into a one-element argument list.
* match.c (v_try): Similar hack to the one in op_catch
removed here.
* unwind.c (uw_unwind_to_exit_point, uw_push_catch): Follows rename of
exception member.
(uw_throw): The exception parameter is renamed to args. The kludge
removed from op_catch re-appears here, because numerous calls
to uw_throw just pass a string as args. It's less of a kludge here
because this is the master entry point to exception processing,
and it straightens out the representation right away.
The exception arguments or message are printed in a clearer way.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(uw_throw): In the unhandled case, check if *unhandled-hook* variable
has a function, and use it instead of the default logic. If it's not a
function, abort with an error message. Clear it so that if the hook
function re-enters this code, it will not be used. Always exit now on
unhandled exceptions; do not abort.
(uw_late_init): New function.
* unwind.h (uw_late_init): Declared.
* lib.c (init): Call uw_late_init.
* txr.1: Documented *unhandled-hook*.
* genvim.txr: Scan the unwind.c file, since it has a reg_var now.
* tl.vim, txr.vim: Updated.
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c, arith.h, combi.c, combi.h, debug.c, debug.h, eval.c, eval.h,
filter.c, filter.h, gc.c, gc.h, hash.c, hash.h, lib.c, lib.h,
match.c, match.h, parser.h, rand.c, rand.h, regex.c, regex.h,
signal.c, signal.h, stream.c, stream.h, sysif.c, sysif.h, syslog.c,
syslog.h, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h:
Update.
* LICENSE, METALICENSE: Likewise.
|
|
|
|
|
|
|
|
|
|
| |
(GREP_CHECK): New macro.
(enforce): Rewritten using GREP_CHECK, with new checks.
* arith.c, combi.c, debug.c, eval.c, filter.c, gc.c, hash.c, lib.c,
* lib.h, match.c, parser.l, parser.y, rand.c, regex.c, signal.c,
* signal.h, stream.c, syslog.c, txr.c, unwind.c, utf8.c: Remove
trailing spaces.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
to C++ style casts when compiling as C++.
* lib.h (strip_qual, convert, coerce): New casting macros.
(TAG_MASK, tag, type, wli_noex, auto_str, static_str,
litptr, num_fast, chr, lit_noex, nil, nao): Use cast macros.
* arith.c (mul, isqrt_fixnum, bit): Use cast macros.
* configure (INT_PTR_MAX): Define using cast macro.
* debug.c (debug_init): Use cast macro.
* eval.c (do_eval, expand_macro, reg_op, reg_mac, eval_init):
Use cast macros.
* filter.c (filter_init): Use cast macro.
* gc.c (more, mark_obj, in_heap, mark, sweep_one, unmark): Use
cast macros.
* hash.c (hash_double, equal_hash, eql_hash, hash_equal_op,
hash_hash_op, hash_print_op, hash_mark, make_hash, make_similar_hash,
copy_hash, gethash_c, gethash, gethash_f, gethash_n, remhash,
hash_count, get_hash_userdata, set_hash_userdata, hash_iter_destroy,
hash_iter_mark, hash_begin, hash_uni, hash_diff, hash_isec): Use
cast macros.
* lib.c (code2type, chk_malloc, chk_malloc_gc_more, chk_calloc,
chk_realloc, chk_strdup, num, c_num, string, mkstring, mkustring,
upcase_str, downcase_str, string_extend, sub_str, cat_str, trim_str,
c_chr, vector, vec_set_length, copy_vec, sub_vec, cat_vec,
cobj_print_op, obj_init): Likewise.
* match.c (do_match_line, hv_trampoline, match_files, dir_tables_init):
Likewise.
* parser.l (grammar): Likewise.
* parser.y (parse): Likewise.
* rand.c (make_state, make_random_state, random_fixnum, random):
Likewise.
* regex.c (CHAR_SET_L2_LO, CHAR_SET_L2_HI, CHAR_SET_L1_LO,
CHAR_SET_L1_HI, CHAR_SET_L0_LO, CHAR_SET_L0_HI, L0_full, L0_fill_range,
L1_full, L1_fill_range, L1_contains, L1_free, L2_full, L2_fill_range,
L2_contains, L2_free, L3_fill_range, L3_contains, L3_free,
char_set_create, char_set_cobj_destroy, nfa_state_accept,
nfa_state_empty, nfa_state_single, nfa_state_wild, nfa_state_set,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
to account for new parameter.
* lib.c (syntax_error_s): New symbol_variable.
(obj_init): New symbol variable initialized.
* lib.h (syntax_error_s): Declared.
* parser.h (lisp_parse): Declaration updated.
* parser.l (lisp_parse): Takes third parameter.
* txr.1: Third parameter of read described.
* txr.c (txr_main): Pass colon_k to third parameter of lisp_parse
to obtain exception throwing behavior.
* unwind.c (uw_init): Register syntax-error as subtype of error.
|
|
|
|
|
|
|
|
| |
debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, hash.c,
hash.h, lib.c, lib.h, match.c, match.h, parser.h, parser.l, parser.y,
rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c,
stream.h, syslog.c, syslog.h, txr.c, txr.h, unwind.c, unwind.h,
utf8.c, utf8.h: Synchronize license header with LICENSE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
executable, whether this is due to being required to use C99.
For instance, the Solaris environment requires compilation
using the C99 dialect if _XOPEN_SOURCE is set to 600 or higher.
* debug.c: When compiling as C99, we have to obey the special
C99 conventions for instantiating inline functions.
* hash.c: Likewise.
* lib.c: Likewise.
* parser.y: Likewise.
* unwind.c: Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
be explicitly requested by the -B option.
* match.c (opt_nobindings): Variable removed.
(opt_print_bindings): New variable.
(extract): Print bindings or "false" if opt_print_bindings is true.
* stream.c (output_produced): Variable removed.
(stdio_put_string, stdio_put_char, stdio_put_byte): Remove
update of output_produced.
* stream.h (output_produced): Declaration removed.
* txr.1: Documentation updated.
* txr.c (txr_main): Option 'b' does nothing. 'B', 'l', 'a',
and '--lisp-bindings' set opt_print_bindings to 1.
* txr.h (opt_nobindings): Declaration removed.
(opt_print_bindings): Declared.
* unwind.c (uw_throw): When exiting due to a query error or
file error, print false when opt_print_bindings is true.
|