summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* ensure-dir: fail if exists and not dir.Kaz Kylheku2020-01-252-21/+34
| | | | | | | | | | | | | * sysif.c (do_stat, do_lstat): Functions relocated before mkdir_nothrow_exists. (mkdir_nothrow_exists): In the EEXIST case, call stat on the object. If it's not a directory or a symlink to a directory, then do not suppress the error; propagate it to the caller, where it will become an exception. * txr.1: Specify the behavior of ensure-dir more precisely: that it only supresses the existence error for directories and directory symlinks.
* New function: mkfifo.Kaz Kylheku2020-01-233-0/+73
| | | | | | | * configure: detect mkfifo. (sysif_init): Register mkfifo intrinsic. * txr.1: Documented.
* mknod: third arg must be optional.Kaz Kylheku2020-01-231-1/+1
| | | | | * sysif.c (sysif_init): Fix incorrect registration of mknod, whose third argument (dev) is documented as optional.
* New functions utimes, lutimes.Kaz Kylheku2020-01-213-1/+326
| | | | | | | | | | | | | * configure: Detect various functions for setting file timestamps. * sysif.c (get_fd): Define this function for use by utimes also. (timens, do_utimes): New static functions. (wrap_utimes, wrap_lutimes): New static functions. (sysif_init): Register utimes and lutimes intrinsics. * txr.1: Documented.
* New function: coded-length.Kaz Kylheku2020-01-184-0/+25
| | | | | | | | * eval.c (eval_init): Register coded-length intrinsic. * lib.c (coded_length): New function. * lib.h (coded_length): Declared.
* ffi: fix broken char handling in undimensioned arrays.Kaz Kylheku2020-01-173-36/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | The undimensioned (array <type>) and (zarray <type>) types are not doing UTF-8 conversion when <type> is char or zchar, or doing what they are supposed to with the FFI character types, which is inconsistent from their dimensioned counterparts. * ffi.c (ffi_varray_dynsize): if the element type is marked for character conversion, then do the size calculation for char and zchar by measuring the UTF-8 coded size. (ffi_varray_alloc): Call ffi_varray_dynsize to get the size, to benefit from the char handling. Thus when FFI allocates buffers for a variable length array, it will allocate correct size required for the UTF-8 encoded string. (ffi_varray_put, ffi_varray_in): Here we must call ffi_varray_dynsize and divide by the element type to get the proper numer of elements. Then we must check for character conversion and handle the cases. (ffi_varray_null_term_in): Check for character conversion cases and route those through ffi_varray_in, which handles null-terminated strings. * tests/017/ffi-misc.tl: New file. * tests/017/ffi-misc.expected: New file.
* sysif: fix inappropriate use of w_ convention.Kaz Kylheku2020-01-153-16/+15
| | | | | | | | | | | | | | | | | | | | | | | Some functions in utf8.c have w_ prefixes. They are wide character wrappers for functions that take multi-byte string inputs. The prefix is being inappropriately used in the names of a few sysif functions that should be named _wrap. * sysif.c (w_stat, w_lstat, w_fstat): Rename to do_stat, do_lstat and do_fstat, respectively. These are callbacks used with stat_impl. (statp, statl, statf): Rename to stat_wrap, lstat_wrap and fstat_wrap, following existing convention. Additionally, stat_wrap becomes static since nothing outside this file calls it. (sysif_init): Follow renames of statp, statl and statf. * sysif.h (statp): Declaration removed. (statf): Renamed to fstat_wrap. * parser.c (load_rcfile): Follow statf rename.
* fstat: take fd argument.Kaz Kyheku2020-01-152-15/+14
| | | | | | | * sysif.c (get_fd): Make available under HAVE_SYS_STAT. (fstat): Allow fd or stream argument using get_fd. * txr.1: Documented.
* with-resources: support multiple cleanup forms.Kaz Kyheku2020-01-152-15/+36
| | | | | | | | * share/txr/stdlib/with-resources.tl (with-resources): Rearrange tree-case cases to recognize a sequence of cleanup forms and insert into the output accordingly. * txr.1: Documented.
* chmod: work on streams and descriptors using fchmod.Kaz Kyheku2020-01-153-12/+59
| | | | | | | | | * configure: extend chmod detection to cover fchmod. * sysif.c (get_fd): New static functions. (chmod_wrap): Include fchmod wrapping for integer or stream argument. (sysif_init): Register fchmod intrinsic.
* Version 231.txr-231Kaz Kylheku2020-01-126-917/+952
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* hash: bug: not hashing key of tree node.Kaz Kylheku2020-01-121-1/+1
| | | | | | | * hash.c (equal_hash): Spurious semicolon in TNOD case causing part of expression that includes the key to be cut off. This was not diagnosed by the C compiler of GCC 4.x or 7.4.0. The GCC 7.4.0 C++ front end caught this bug.
* configure: don't try to remove phony target.Kaz Kylheku2020-01-101-1/+0
| | | | | | | * configure: there is no need to 'rm -f conftest.yacc' before requesting that target, because it's correctly marked as a phony target. Even if a file by that name exists, make will execute the rule.
* build: deal with the mess of new Bison warnings.Kaz Kylheku2020-01-102-1/+29
| | | | | | | | | | | | | | | | | | | | | | | | Newer versions of Bison produce spurious warnings in Yacc mode about %pure-parser being not POSIX conforming and also deprecated. Plus some strange fluff about "fix-its" that can be applied if option --update is specified. Let's detect at configure time whether the Yacc program being used is actually Bison 3.0 or greater, and if so, give it some flags to shut up these warnings. * Makefile (YACC_FLAGS): New variable, conditionally set based on yacc_is_newer_bison, also new variable, that being generated into config.make. (y.tab.c): Invoke $(TXR_YACC) with $(YACC_FLAGS). (conftest.yacc-version): New phony target for running Yacc with --version, out of the configure script. * configure (yacc_is_newer_bison): New variable. (gen_config_make): Generate yacc_is_newer_bison make variable. New test for whether Yacc is Bison. If so, and the version is >= 3.0, sets the yacc_is_newer_bison variable to y.
* gc: obtain stack top using alloca.Kaz Kylheku2020-01-091-10/+5
| | | | | | | | | | | | | | | | This trick gets rid of the hack for aarch64. If we call alloca, the pointer we get should be below all frame information. Even if for the given target, the compiler-generated code happens to be saving callee-saved registers below the declared variables, any pointer we get from alloca must be below all of that still. * gc.c (STACK_TOP_EXTRA_WORDS): Macro removed. (mark): Don't subtract STACK_TOP_EXTRA_WORDS from gc_stack_top; take the top as-is. (gc): Don't allocate the machine context as an automatic variable; obtain the storage for it from alloca. That then also serves as the stack top.
* gc: consolidate top-of-stack and context handling.Kaz Kylheku2020-01-091-8/+2
| | | | | | | | * gc.c (mark): Eliminate mach_context_t * argument; just gc_stack_top is passed. (gc): Specify the base address of the machine context as the top of the stack. Still, on aarch64, STACK_TOP_EXTRA_WORDS is required, otherwise we get prematurely freed objects.
* aarch64: gc: mark farther beyond apparent stack.Kaz Kylheku2020-01-091-1/+1
| | | | | * gc.c (STACK_TOP_EXTRA_WORDS): Changing from 4 to 12 eliminates crashes.
* gcc: disable annoying code quoting.Kaz Kylheku2020-01-081-0/+27
| | | | | | | | | | | | | Newer versions of gcc add a lot of aggravating spewage to the diagnostics, by including copies of the lines of code where the error occurs followed by a line showing the error location with a caret and some tilde underlining. * configure: new test to see whether the compiler emits a caret line for a program that has a syntax error (missing closing brace). If so, we test whether the compiler accepts the option -fno-diagnostics-show-caret, and if so, we add that option to DIAG_FLAGS in config.make.
* tests: broken glob test cases crash under musl.Kaz Kylheku2020-01-083-7/+21
| | | | | | | | | | | | | | | | | | | | | | Among several issues, the main one is that these test cases use the str-d FFI type for strings. This type means that TXR will take ownership of the memory; it creates the Lisp strings for the Lisp array, and then assuming that it has owership of the C strings, it will free them. On musl, this causes an instant crash, probably because the strings might not be individually coming from malloc. The only documented interface for freing glob resources is globfree; programs cannot assume that the strings can be freed. * tests/017/glob-carray.expected: Updated. * tests/017/glob-carray.tl (glob-t): Add missing flags member of type int. Change the array element string type from str-d to str. * tests/017/glob-zarray.tl: Likewise, and also add a comment to explain why we are not calling globfree in this test case.
* config.h: double definition of FLO_MAX_DIGKaz Kylheku2020-01-071-0/+1
| | | | | | * configure: add missing break statement into the loop that determines the definition for FLO_MAX_DIG, so we don't add multiple definitions. This reproduces on the Musl library.
* ffi: fix non-libffi build on big endian.Kaz Kylheku2020-01-061-0/+1
| | | | | | | | This is cribbed from a patch by q66 <daniel@oct***rge.org>, commited recently to the Void Linux distro. * ffi.c (ffi_arg): Define this type when HAVE_FFI is not enabled. Some big-endian-specific code refers to it.
* builtin redefinition: better diagnostic message.Kaz Kylheku2020-01-061-6/+10
| | | | | | | | | | | | | | | | | | | 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.
* sysif.h: remove dependency on off_t.Kaz Kylheku2020-01-012-14/+6
| | | | | | | | | | | | | | The sysif.h header breaks on some systems because it references off_t, which requires <sys/types.h>. But the off_t materials in this header are unnecessary; we can remove them. * sysif.c (off_t_num, num_off_t): Extern functions become static, and are wrapped with #if HAVE_FSEEKO. These functions are only called from sysif.c, only from code relying on fseeko. * sysif.h (OFF_T_MAX, OFF_T_MIN): Macros not used anywhere are removed. (off_t_num, num_off_t): Declarations removed.
* Copyright year bump 2020.Kaz Kylheku2019-12-31121-123/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* doc: usage note for compile-update-file.Kaz Kylheku2019-12-231-0/+16
| | | | | | * txr.1: Document how compile-update-file can be used together with load to ensure that the compiled version of a file is loaded without unnecessary recompiling.
* doc: redocument keyword argument description.Kaz Kylheku2019-12-231-15/+29
| | | | | | * txr.1: Under :key parameter macro, rewriting the description of what keyword arguments are. This was prompted by the strange wording "Arguments to keyword appear ...".
* doc: spurious blank line under build macro.Kaz Kylheku2019-12-231-1/+0
| | | | * txr.1: Remove spurious blank line.
* New function: compile-update-file.Kaz Kylheku2019-12-223-59/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | The new function only compiles a file if the output file doesn't exist or is out of date. In addition, both compile-file now deletes the output file if compilation fails, and has a documented return value. * lisplib.c (compiler_set_entries): Add autoload entry fro compile-update-file. (open-compile-streams): Accepts a third argument: a function to test the input stream against the output path. The output file is opened, and the streams are returned, only if that test function returns true. Also, a third element is returned: the output path. This lets the caller to know what to delete, if the output file must be deleted. (compile-file-conditionally): New internal function, formed from compile-file. Takes an extra argument, the test function to pass to open-compile-streams. Compilation is skipped if open-compile-streams returns nil. Internals reshuffled a bit. If compilation doesn't set the success flag, then the with-resources logic now removes the output file in addition to closing the output stream. Prior to setting the success flag, we flush the output stream. * txr.1: Documented new function, all return values, and deletion of output file on unsuccessful compilation.
* Version 230.txr-230Kaz Kylheku2019-12-204-5/+24
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* config: improve check for PIE-disabling flags.Kaz Kylheku2019-12-191-2/+2
| | | | | | | * configure: the logic must be cumulative; the test for the code generation flag (e.g. -fno-pie) needs to incorporate the previously detected linker flag (e.g. -no-pie). On x86_64, -fno-pie by itself without -no-pie fails with errors.
* configure: better check for missing make.Kaz Kylheku2019-12-191-2/+2
| | | | | | * configure: don't fail with a "unbound variable $3" error if make is not found; correctly print "missing" and quit cleanly.
* configure: disable building as PIE.Kaz Kylheku2019-12-181-0/+25
| | | | | | | | | | | | | | | | On some GNU/Linux distributions, the compiler is configured for PIE (position-independent executables). This is horrible garbage which causes our "make tests" to run more than 22% slower (e.g. 8.22 seconds versus 6.69) which is unacceptable. Worse, this was implicated in a crash in TXR's exception handling logic. The committed workaround for that problem stays in place for users who want to build TXR in the PIE style anyway. * configure: detect which, if any, of the known gcc and clang options are available for disabling PIE and add those to opt_flags (which turns into OPT_FLAGS in config.make).
* Move jmp-related stuff from signal.h to unwind.h.Kaz Kylheku2019-12-173-170/+177
| | | | | | | | | | | | | | | | | | * gc.c: Include "unwind.h" for jmp_buf. * signal.h (struct jmp): All versions removed from here. (jmp_save, jmp_restore): Declarations removed from here. (EJ_DBG_MEMB): Macro removed. (extended_jmp_buf): Struct type removed. (extended_setjmp, extended_longjmp): Macros removed. (extjmp_save, extjmp_restore): Declarations removed. * unwind.h (struct jmp): Declared here. (jmp_save, jmp_restore): Declared here. (EJ_DBG_MEMB): Macro moved here. (extended_jmp_buf): Struct type moved here. (extended_setjmp, extended_longjmp): Declared here. (extjmp_save, extjmp_restore): Declared here.
* bugfix: crash in extended_setjmp due to PIE.Kaz Kylheku2019-12-173-55/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A crash occurs on Ubuntu 18.04, 32 bit x86, when executing the test case tests/007/except-2.txr, whereby TXR segfaults in the v_try function. This is reminiscent of a January, 2016 report in the txr-users mailing list from Morit Barsnick, who also ran into a crash in the same test case. Background: it appears that the compiler in Ubuntu 18.04 enables PIE (position-independent executables) by default. Thus even simple executables that are not shared libraries reference their own global variables through an offset table, instead of direct addressing. To access globals, the compiler has to emit code that retrieves their addresses from a table, pulling them into a register, and then performing indirect memory accesses through the register. Sometimes the emitted code doesn't keep these addresses in a register. The address of a global variable accessed multiple times in a block of code may get spilled from a register into the stack, and then later retrieved from the stack again to access that same global. In our extended_setjmp logic, we save the values of a few global variables and restore them if the extended_longjmp takes place to return to that point. The problem is that when restoring some of the globals, the compiler is relying on retrieving the effective addresses from the temporary spill locations in the stack. However, those temporary locations have since been re-used for other purposes and the access to the globals therefore crashes or produces unpredictable results. Essentially, it's as if GCC did this around our code: { unsigned *debug_enable_addr = &debug_enable; /* save and restore logic here uses *debug_enable_addr * to refer to debug_enable */ if (extended_setjmp(...)) ... } /* Oops, debug_enable_addr is now garbage! * We are jumping back into the scope which will try to use * its value to restore the debug_enable global. */ extended_longjmp(...); I have experimented with a few approaches that did not work, and settled on moving the code which saves and restores the globals into functions. GCC will not cache the effective address calculation of a global variable access between calls to different external functions which access that variable. The mitigation in this commit gets the test cases to pass even if TXR is compiled with PIE. However, PIE should be disabled. Not only does it cause the above problem, but it has a huge performance impact: a more than 16% slowdown, which is quite unacceptable. * eval.h (dyn_env): Delare here. Some sources were depending on signal.h providing this, which is wrong. Now signal.h doesn't declare it any longer. * signal.h (EJ_DBG_SAVE, EJ_DBG_REST): Macros removed. (extended_setjmp): Greatly simplified. Extended restoring logic is now done in extended_longjmp, and the extended save for the globals is a function call. Just moving the restore into extended_longjmp probably would have fixed this issue. (extended_longjmp): Call extjmp_restore. (extjmp_save, extjmp_restore): Declared. * unwind.c (extjmp_save, extjmp_restore): New functions.
* ffi: bug: zchar not handled in array out semantics.Kaz Kylheku2019-12-161-0/+1
| | | | * ffi.c (ffi_array_out): Add missing zchar case.
* ffi: shut up gcc7 warnings about switch case.Kaz Kylheku2019-12-161-0/+7
| | | | | | * ffi.c (ffi_array_put, ffi_array_out): Handle conv_none in the switch, even though the whole switch is conditional on the value being other than conv_none.
* Version 229.txr-229Kaz Kylheku2019-12-147-972/+1014
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* ffi: new type zcharKaz Kylheku2019-12-142-21/+126
| | | | | | | | | | | | | | | | | | | The zchar type, when used as an array element, specifies an optionally null-terminated or padded field, which is subject to UTF-8 conversion. * ffi.c (zchar_s): New symbol variable. (enum char_conv): New member, conv_zchar. (ffi_zchar_array_get): New static function. (ffi_array_in, ffi_array_get_common): Handle conv_zchar via ffi_zchar_array_get. (ffi_array_put): Handle conv_char together with conv_zchar. (ffi_type_compile): Handle zchar array element type, mapping to conv_zchar. (ffi_init_types): Register zhar type. (ffi_init): Initialize zchar_s symbol variable. * txr.1: Documented.
* ffi: turn char conversion flags into enum.Kaz Kylheku2019-12-141-52/+85
| | | | | | | | | | | | | | | | | | The three flags controlling character array conversion semantics are mutually exclusive. Let's turn them into an enumeration, so we can (1) test that a conversion is in effect by testing a single value and (2) switch on the conversion type instead of successively testing the flags and (3) assure the aforementioned mutual exclusion. * ffi.c (enum char_conv): New enum. (struct txr_ffi_type): Members char_conv, wchar_conv and bchar_conv gone, replaced by ch_conv. (ffi_array_in, ffi_array_put, ffi_array_out, ffi_array_get_common, ffi_array_release_common, ffi_varray_null_term_get, ffi_type_compile, carray_ensure_artype): Work with ch_conv instead of three flags.
* listener: C++ enum issue.Kaz Kylheku2019-12-131-1/+1
| | | | | | * parser.c (is_balanced_line): don't initialize an "enum state" variable with 0, but with the equivalent enum constant.
* doc: doubled word in compat note.Kaz Kylheku2019-12-131-1/+1
| | | | | * txr.1: fix "invoked invoked" in compatibility note for compat value 151.
* doc: make-buf: document default value.Kaz Kylheku2019-12-131-2/+5
| | | | | * txr.1: documnt that the default value of the optional alloc-size parameter is taken from the len parameter.
* multiple-inheritance: test static-slot-home.Kaz Kylheku2019-12-132-1/+6
| | | | | | | * tests/012/oop-mi.tl: Add some coverage for static-slot-home function. * tests/012/oop-mi.expected: Updated.
* multiple-inheritance: super-method loose ends.Kaz Kylheku2019-12-134-41/+87
| | | | | | | | | | | | | | | | | * struct.c (do_super): New function. Now the common implementation for call_super_method, call_super_fun and super_method. (call_super_method, call_super_fun): Reduced to small wrappers around do_super. (super_method): Drill into the object to geet the struct_type handle, and then use do_super to get the method. * tests/012/oop-mi.tl: New tests for call-super-fun and call-super-method. * tests/012/oop-mi.expected: Updated. * txr.1: Updated.
* define-option-struct: use multiple inheritanceKaz Kylheku2019-12-131-14/+22
| | | | | | | | | | | | * share/txr/stdlib/getopts.tl (sys:option-base): New struct type, holding the boiler-plate methods and slots that were generated into the user-defined struct by define-option-struct. (define-option-struct): Inject the required properties by inheritance from sys:option-base, greatly reducing code bloat in the macro. The slot hash and opt-desc-list static slots have to be redefined in the derived structure so that type has its own instance of them.
* OOP: implementing multiple inheritance.Kaz Kylheku2019-12-117-94/+344
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Multiple inheritance is too useful to ignore any longer. * lib.c (subtypep): Perform subtypep calculation between two struct types via the new struct_subtype_p function. It's too complicated now to do with ad hoc code outside of struct.c. * share/txr/stdlib/struct.tl (defstruct): This macro now needs to deal with the super argument being possibly a list of base types instead of a single one. * strut.c (struct struct_type): Member super and super_handle are removed. New member nsupers, supers, and sus. (struct_init): The super function re-registered; it has an optional argument. (call_stinitfun_chain): The compat code here must now access the supertype differently. We don't bother dealing with multiple inheritance in the compat case; programs requesting compatibility with TXR 151 shoudn't be trying to use multiple inheritance. (get_struct_handles, count_super_stslots, get_super_slots, find_super_for_slot): New static functions, to off-load some new complexity from make_struct_type. (make_struct_type): Handle the increased complexity due to multiple inheritance. (super): Takes an additional argument now, to request which supertype to retrieve. Defaults to zero: the first one. (struct_type_destroy): Free the sus array. (struct_type_mark): Mark the supers slot. (call_initfun_chain): Call init functions of all bases, in right-to-left order. (call_postinitfun_chain): Likewise for postinit functions. (call_super_method, call_super_fun, super_method): Use the first base as the supertype. This requirement feels bad; it needs to be revisited. (do_struct_subtype_p): New static function. (struct_subtype_p): New function. (ancestor_with_static_slot): New static function. (method_name): Revised for multiple inheritance; now relies on ancestor_with_static_slot to find the original ancestor that has brought in a method, so we can use that type in the method name. * struct.h (super): Declaration updated. (struct_subtype_p): Declared. * tests/012/oop-mi.expected: New file. * tests/012/oop-mi.tl: New test cases. * txr.1: Revised in order to document multiple inheritance.
* doc: clarify inheritance of static slot value.Kaz Kylheku2019-12-091-0/+31
| | | | | | | | | * txr.1: In relation of the previous bugfix, a certain situation is worth clarifying. A static slot does not inherit the value of a grandparent type's static slot of the same name, if the supertype has specified that slot as an instance slot. Inheritance of the static slot value is from the direct supertype only.
* structs: bugfix: crash in static slot inheritance.Kaz Kylheku2019-12-091-1/+1
| | | | | | | | | | | | | * struct.c (make_struct_type): When a struct defines a static slot that exists as an instancee slot in the supertype, there is a crash. This is because the code assumes that the supertype's slot is static. The index value m ends up negative due to subtracting STATIC_SLOT_BASE from an instance slot index, and so the code tries to copy the value of a negatively indexed static slot from the supertype into the new static slot. We can fix this by not doing the copy when a negative index has been calculated. That way we treat the situation as if the supertype didn't have that slot at all.
* New function: path-dir-empty.Kaz Kylheku2019-12-093-0/+38
| | | | | | | | | | * lisplib.c (path_test_set_entries): Autoload entry for path-dir-empty. * share/txr/stdlib/path-test.tl (path-dir-empty): New function. * txr.1: Documented.
* Add hyperbolic functions: sinh, cosh, and others.Kaz Kylheku2019-12-074-0/+146
| | | | | | | | | | | | | | | | | | | | * 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.