summaryrefslogtreecommitdiffstats
path: root/share
Commit message (Collapse)AuthorAgeFilesLines
* Version 208.txr-208Kaz Kylheku2019-01-281-1/+1
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* Version 207.txr-207Kaz Kylheku2019-01-261-1/+1
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* disassemble: tidier data table.Kaz Kylheku2019-01-261-1/+1
| | | | | | * share/txr/stdlib/asm.tl (dissassemble-cdf): Print the rows of the data table with simple numeric offsets, with no d prefix or leading zeros.
* Version 206.txr-206Kaz Kylheku2019-01-181-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Copyright year bump 2019.Kaz Kylheku2019-01-1632-32/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, METALICENSE, Makefile, args.c, args.h, arith.c, arith.h, buf.c, buf.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, ffi.c, ffi.h, filter.c, filter.h, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lib.c, lib.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/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/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/pmac.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, 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 line to 2018.
* ffi: diagnose missing with-dyn-lib.Kaz Kylheku2019-01-161-24/+23
| | | | | | | | | | | | | | | If the programmer writes a deffi, deffi-sym or deffi-var that makes simple references, and that macro is not wrapped in with-dyn-lib, an unhelpful error message results about sys:ffi-lib being unbound. We can detect this situation and provide a warning. * share/txr/stdlib/ffi.tl (sys:with-dyn-lib-check, sys:expand-sym-ref): New functions. (deffi, deffi-sym, deffi-var): Capture environment parameter. Common code replaced by call to sys:expand-sym-ref, where the missing sys:ffi-lib situation is diagnosed. This is only done in cases when the simple reference syntax occurs.
* Version 205.txr-205Kaz Kylheku2019-01-151-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* asm: fix wrong level check in operand parsing.Kaz Kylheku2019-01-091-1/+1
| | | | | | | | * share/txr/stdlib/asm.tl (parse-compound-operand): The index of a (v <lev> <index>) operand must be compard to the maximum index constant, not to the maximum level constant. This bug will prevent compiling frames that have more than 64 variables, which is a serious limitation from 1024.
* asm: fix incorrect level check in frame opcode.Kaz Kylheku2019-01-091-2/+2
| | | | | | * share/txr/stdlib/asm.tl (op-frame): Check the level of the operand against %max-v-lev%, not %max-lev-idx%, which gives the maximum index within a level.
* asm/compiler: fix incorrect frame-related constant.Kaz Kylheku2019-01-091-1/+1
| | | | | | * share/txr/stdlib/vm-param.tl (%max-lev-idx%): The maximum index within a level is one less than the maximum level size, not two less. Use pred rather than ppred to derive it.
* asm/compiler: rename small level/index constants.Kaz Kylheku2019-01-092-3/+4
| | | | | | | | | | | | | | | | * share/txr/stdlib/vm-param.tl (%max-sm-lev-idx%): This constant is named inconsistently relative to %max-lev-idx%. It is providing the maximum level (encodable in a small operand), whereas %max-lev-idx% provides the maximum index within a level. It is hereby renamed to %max-sm-lev%. The %max-sm-lev-idx% name is re-used to denote the quantity which it suggests: the maximum index within a level (encodable in a small operand), which is 63. * share/txr/stdlib/asm.tl (small-op-p): Use the new %max-sm-lev-idx% in place of %sm-lev-size%, getting rid of the funny range starting with -1. Replace the original %max-sm-lev-idx% with its new name, %max-sm-lev%.
* Version 204.txr-204Kaz Kylheku2018-12-171-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* compiler: move variable down in file.Kaz Kylheku2018-12-131-2/+2
| | | | | | * share/txr/stdlib/compiler.tl (assumed-fun): This variable shouldn't be the first item in the compiler. It is moved after the definitions of structs and important constants.
* Version 203.txr-203Kaz Kylheku2018-11-291-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Version 202.txr-202Kaz Kylheku2018-11-221-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* compiler: use binary versions of common math functions.Kaz Kylheku2018-11-161-0/+17
| | | | | | | | | | | | | | | * arith.c (arith_init): Register functions in the sys package: b<, b>, b<=, b=, b+, b-, b*, b/ and neg. * share/txr/stdlib/compiler.tl (%nary-ops%, %bin-ops%, %bin-op%): New global variables. (compiler comp-fun-form): Transform two-argument calls to any of the variadic functions in %nary-ops% functions into calls to their binary counterpart. These calls are faster, since they bypass the wrapper which deals with the variable argument list. Also, we detect unary - and map it to the new sys:neg function, and reduce the one-argument cases of certain functions to noops.
* compile: handle functions that have environments.Kaz Kylheku2018-11-131-2/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this patch, the compile function can handle interpreted function objects that have captured environments. For instance, if the following expression is evaluated (let ((counter 0)) (labels ((bm () (bump)) (bump () (inc counter))) (lambda () (bm)))) then a function object emerges. We can now feed this function object to the compile function; the environment will now be handled. Of course, the above expression is already compileable; compile-toplevel handles it and so does the file compiler. This patch allows the expression to be interpreted and then the function object to be compiled, without access to the surrounding expression. The compiled function will contain a compiled version of the environment, carrying compiled versions of the captured variables and their contents. * eval.c (env_vbindings, env_fbindings, env_next): New static functions. (eval_init): Register env-vbinding, env-fbindings and env-next intrinsics. * share/txr/stdlib/compiler.tl (sys:env-to-let): New function. (usr:compile): Wrap the interpreted lambda terms with let bindings carefully reconstructed from their captured environments. * txr.1: Documented new intrinsic functions.
* Version 201.Kaz Kylheku2018-11-071-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* compiler: bugfix: handle defpackage and such properly.Kaz Kylheku2018-11-051-6/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem is that the file compiler is emitting one big form that contains all of the compiled top-level forms. For obvious reasons, this doesn't work when that form contains symbols that are in a package which is defined by one of those forms; the compiled file will not load due to qualified symbols referencing a nonexistent package. The solution is to break up that big form when it contains forms that manipulate the package system in ways that possibly affect the read time of subsequent forms. * lib.c (delete_package): Use a non-destructive deletion on the *package-alist*, because we are going to be referring to this variable in the compiler to detect whether the list of packages has changed. * share/txr/stdlib/compiler.tl (%package-manip%): New global variable. This is a list of functions that manipulate the package system in suspicious ways. (user:compile-file): When compiling a form which is a call to any of the suspicious functions, add a :fence symbol into the compiled form list. Also do this if the evaluation of the compiled form modifies the *package-alist* variable. When emitting the list of forms into the output file, remove the :fence symbols and break it up into multiple lists along these fence boundaries. * txr.1: Documented the degenerate situation that can arise.
* Version 200.txr-200Kaz Kylheku2018-11-051-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* compiler: optimize dwim.Kaz Kylheku2018-11-042-17/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * share/txr/stdlib/asm.tl (op-getf): Rename to op-oldgetf. This opcode becomes obsolescent. (op-getf): New opcode. * share/txr/stdlib/compiler.tl (assumed-fun): New global variable. (compiler comp-fun): Use the new getf instruction which takes a function table index instead of a data table index. (compiler comp-lisp1-value): Don't use getl1 opcode any more for dynamic lisp1-style lookup. Instead, we bake the behavior at compile time perform a function lookup if the symbol is completely unbound, a variable lookup if it is bound to a variable (where we decide at compile tie whether it is lexical or dynamic) or else a function if a function binding exists at compile time. Also, if we assume that an unbound symbol is a function, put it on the assumed-fun list. (compiler comp-dwim): If the first argument is a symbol with no lexical binding, and is not bound as a variable, then treat it as a function by transforming the form into a function call form with that symbol in the car position. Put the symbol on the assumed-fun list. (compiler-emit-warnings): New function. (with-compilation-unit): Call compiler-emit-warnings when bailing out of most enclosing compilation unit. (%tlo-ver%): Bump compiled file version to 4, since we added an opcode. * vm.c (vm_execute): Follow rename of GETF to OLDGETF. Implement the new GETF. * parser.c (read_file_common): Extend version range to allow version 4 compiled files. * txr.1: Documented everything.
* The code expander becomes a public API.Kaz Kylheku2018-11-023-13/+11
| | | | | | | | | | | | | | | | | | | | | | | The functions sys:expand, sys:expand* and sys:expand-with-free-refs are now in the usr package and documented for public use. * eval.c (eval_init): Move registrations of the symbools expand, expand* and expand-with-free-refs from the system package to the user package. * share/txr/stdlib/awk.tl (sys:awk-mac-let, awk): Uses of sys:expand drop the sys: prefix. * share/txr/stdlib/op.tl (sys:op-alpha-rename): Likewise. * share/txr/stdlib/place.tl (call-upudate-expander, call-clobber-expander, call-delete-expander, sys:placelet-1): Likewise. * tests/011/macros-2.txr, tests/012/struct.tl: Likewise. * txr.1: Documented expand, expand* and expand-with-free-refs.
* Version 199.txr-199Kaz Kylheku2018-10-281-1/+1
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Regenerated.
* op: bugfix: sys:*op-ctx* defined too late.Kaz Kylheku2018-10-261-2/+2
| | | | | | | | * share/txr/stdlib/op.tl (sys:*op-ctx*) Move definition before the make-struct-type call which instantiates the sys:op-ctx structure type, because the variable is referenced in that expression and treated as lexical. This situation now generates a warning.
* compiler: use symtab caching for global lexicals.Kaz Kylheku2018-10-261-9/+16
| | | | | | | | | | | | | | | | * parser.c (read_file_common): Allow version three object files. * share/txr/stdlib/compiler.tl (compiler comp-var): If a global variable isn't special, then treat it via the getlx instruction. The symbol gets added to the symtab, and referenced by index number. (compiler comp-setq): Similarly, treat a non-special global variable using the setlx instruction. (%tlo-ver%): We bump the major version of .tlo files from 2 to 3, since old txr executables won't recognize these new instructions. However, we are backward compatible; hence read_file_common still allows version 2.
* vm/asm: new instructions getlx and setlx.Kaz Kylheku2018-10-261-0/+24
| | | | | | | | | | | | | | | | | | | | These instructions can be used for accessing cached global variable bindings through the symtab of the vm descriptor. The compiler will use these for optimizing access to global lexical variables. * share/txr/stdlib/asm.tl (op-getlx, op-setlx): New opcode classes. * vm.c (vm_stab): Take the lookup function as an argument, so this can be used for variable bindings. (vm_gcall, vm_gapply): Pass lookup_fun function to vm_stab, as well as the appropriate string for the unbound error. (vm_gettab, vm_settab): New static functions. (vm_execute): Implement GETLX and SETLX using vm_gettab and vm_settab. * vmop.h: Regenerated.
* awk: unwanted package prefix in error message.Kaz Kylheku2018-10-121-1/+1
| | | | | | | * share/txr/stdlib/awk.tl (sys:awk-code-move-check): A symbol in the sys: package is being used just for the English word that its name supplies, so print it using ~a so the sys: prefix doesn't appear.
* compiler: typo in error message.Kaz Kylheku2018-08-071-1/+1
| | | | | | | * share/txr/stdlib/compiler.tl (expand-quasi-mods): Fix misspelled "missing". Small repro test case to trigger the diagnostic: (compile-toplevel '`@{"" []}`) where, note, there is nothing between the square brackets.
* compile-file: incremental expansion of top-level forms.Kaz Kylheku2018-07-171-17/+18
| | | | | | | | | | | | | | Harmonizing with the previous change to eval, the compiler should also handle those situations. * share/txr/stdlib/compiler.tl (compile-file): do not perform a full expansion on each object that it reads from the file before passing it into the top-level walk. Rather, the raw form is passed into the top-level walk. It is partially expanded with macro-expand, and this is repated at each descent of the recursion. Only forms which are not top-level forms are then fully expanded before compilation, by not passing the t argument to compile-toplevel.
* opip, oand: rewrite in Lisp.Kaz Kylheku2018-07-161-0/+17
| | | | | | | | | | | | | | | | | * eval.c (opip_s, oand_s, chain_s, chand_s): Variables removed. (me_opip): Function removed. (eval_init): Initializations of removed variables removed. chain and chand symbols interned at point of function registration. * lisplib.c (op_set_entries): Add autoload entries for opip and oand. * share/txr/stdlib/op.tl (sys:opip-expand): New function. (opip, oand): New macros. * protsym.c: Regenerated.
* op: convert to Lisp trivial macros related to op.Kaz Kylheku2018-07-161-0/+18
| | | | | | | | | | | | | | | | | | | | | | | The op macro is no longer written in C, but the trivial macros ap, ip, ado, ido, ret and aret are still C. It's silly to have macros written in C, baked into the TXR executable, which just produce syntax for a complicated macro written in Lisp that must be autoloaded when that code is used. * eval.c (ap_s, apf_s, ipf_s, ret_s, aret_s): Variables removed. (me_ap, me_ip, me_ado, me_ido, me_ret_aret): Functions removed. (eval_init): Do not initialize removed variables. Remove registration for macros ap, ip, ado, ido, ret and aret. Intern the apf and ipf symbols in the same expression which registers these functions. * lisplib.c (op_set_entries): Add autoload entries for ap, ip, ado, ido, ret and aret. * share/txr/stdlib/op.tl (ap, ip, ado, ido, ret, aret): New macros. * protsym.c: Regenerated.
* compile-file: support hash bang.Kaz Kylheku2018-07-111-0/+4
| | | | | | | | | * share/txr/stdlib/compiler.tl (usr:compile-file): Check for a hash bang line in the source file. If so, propagate it to the compiled file. * txr.1: Documented existing support for hash bang in .tlo files, and the translation of hash bang from .tl to .tlo.
* list-build: rewrite methods for semantics & efficiency.Kaz Kylheku2018-07-111-10/+28
| | | | | | | | | | | | | | | | | | The list builder needlessly copies list structure. At any given moment, the last piece of structure added to the list can remain shared. We can leave the tail pointing to that piece and copy it later in a nondestructive operation. Also, we would like (build (add 1) (pend 2)) to produce (1 . 2) rather than an errror. The implementation gives this to us in the same stroke. * share/txr/stdlib/build.tl (list-builder :postinit): Just initialize tail to be head, rather than eagerly chasing to the last cons. (list-builder add, list-builder pend, list-builder pend*, list-builder ncon, list-builder ncon*): Rewrite.
* compiler: bugfix: mishandled empty testKaz Kylheku2018-07-101-6/+9
| | | | | | | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-for): Fix exception thrown when compiling (for init test step ...) when test is nil. Firstly, we must distinguish a (nil) test from (), because the latter means (t). Hence the need for the test-p Boolean. The list of frags must not contain a nil, which isn't a frag. The instruction template must not only omit generating the conditional jump when the test is absent, but also omit generating the test code (insertion of tfrag.code) in that case, because tfrag is nil.
* compiler: duplicated code when compiling switch.Kaz Kylheku2018-07-101-2/+2
| | | | | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-ift): Fix incorrect reference to the vec function rather than the cases-vec local variable. Thus the variable shared is now correctly calculated, and switch syntax which implements fall through cases via a single block of shared code is now translated properly as one block of instructions with with multiple entry points.
* compiler: constant-fold if eql.Kaz Kylheku2018-07-091-4/+9
| | | | | | | | | | | | | | | We put the ifql opcode to use for (if (eql ...) ...) and (if (neql ...) ...) and also constant-fold the constant cases, like we do for eq. * share/txr/stdlib/compiler.tl (%test-funs-pos%): Add eql to list. (%test-funs-neg%): Add neql to list. (%test-funs-ops%): New list of corresponding opcodes. (%test-opcode%): New variable containing a relation function from equality functions to assembler opcodes. (compiler comp-ift): Don't hard code the opcode; look it up from the test function using %test-opcode%.
* compiler: bugfix in constant condition logic.Kaz Kylheku2018-07-091-1/+1
| | | | | | | | | * share/txr/stdlib/compiler.tl (%test-inv%): Fix reversed mapping; the way this is used, it is expected to map the negative tests to their positive counterparts. This didn't matter until the previous commit because before that commit, the value that was computed through this table wasn't used for anything. It is being used now.
* compiler: don't hardcode eq in if optimization.Kaz Kylheku2018-07-091-1/+1
| | | | | | | | * share/txr/stdlib/compiler.tl (copmiler comp-ift): In the case when both values being compared are constant expressions, evaluate the comparison statically using the function, rather than a hard coded eq. Right now, the only funtion handled is in fact eq.
* Version 198.txr-198Kaz Kylheku2018-07-061-1/+1
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Regenerated.
* awk: bugfix: block optimized away by compiler.Kaz Kylheku2018-06-281-1/+1
| | | | | | | | | | | This breaks the (next) awk macro, breaking awk expressions which want to short-circuit to the next record. * share/txr/stdlib/awk.tl (sys:awk-state loop): The :awk-rec block is being optimized away by the compiler because it doesn't contain any direct function calls to functions that are not in the standard library. We must use block*, which isn't subject to this optimization.
* Version 197.txr-197Kaz Kylheku2018-05-271-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* compiler: fix broken block*.Kaz Kylheku2018-05-261-2/+2
| | | | | | | | | | | Compiling a block* fails with an exception: nil is accessed as a structure. * share/txr/stdlib/compiler.tl (comp-block): when compiling block*, nenv is nil; we must use env when compiling the name subexpression. Also, we can't use nenv when compiling the body. We must use nenv when it is available (block case) or else fall back on env (block* case).
* compiler/vm: renaming funvec.Kaz Kylheku2018-05-252-20/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The virtual machine's funvec will be used for global lexical variables also, so it is being renamed to symvec. Related structure members, functions and variables are also renamed. * share/txr/stdlib/asm.tl (disassemble): Print the table heading as syms: rather than funs:. Follow the rename of vm-desc-funvec to vm-desc-symvec. * share/txr/stdlib/compiler.tl (compiler): Slots fidx-cntr fidx and ftab are renamed to sidx-cntr, sidx and stab, resp. (compiler get-fidx): Renamed to get-sidx. (compiler get-funvec): Renamed to get-symvec. (compiler comp-setqf, compiler comp-catch, compiler comp-fun-form, usr:compile-toplevel): Follow rename. (list-from-vm-desc): Follow rename of sys:vm-desc-funvec. * vm.c (strut vm_desc): Members funvec and ftab renamed to symvec and stab. (vm_make_desc): Parameters and local variables renamed. Follow rename of struct members. (vm_desc_funvec): Renamed to vm_desc_symvec. (vm_desc_destroy, vm_desc_mark): Follow rename struct members. (vm_ftab): Renamed to vm_stab. (vm_gcall, vm_gapply): Follow rename of vm_ftab. (vm_init): Register renamed vm_desc_symvec function as sys:vm-desc-symvec.
* compiler: fix wrong free symbol calculations.Kaz Kylheku2018-05-251-10/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calculation of free symbols emanating out of let, let*, flet and labels is wrong, not taking into account the differences, respectively between let and let*, and between flet and labels. Compilation of lambda also has the same problem; variable references in initforms are considered free without regard for shadowing by earlier parameters. Another issue is the incorrect handling of special variables: special variable references are incorrectly being considered free in scopes where they are bound. * share/txr/stdlib/compiler.tl (compiler comp-let): For sequential bindings (let*), we must cull the prior variables from the list of free vars emanating out of each init form; these references do not emanate out of the binding construct. We pull the prior vars list out of the environment before binding the current variable so that it is not included in the list. Both special and lexical variables must be considered reference-capturing. (compiler comp-fbind): If compiling a recursive binding, cull the newly bound functions from the free references emanating from the local function bodies. A bug is fixed here that we were not referring to the correct list of symbols and so not taking into account the function references inside the local functions themselves at all. (compile comp-lambda): Build a correct list of free vars in relation to the initforms of optional parameters, taking account the scope, and that special variables capture references.
* compiler: elide unused lexical functions.Kaz Kylheku2018-05-231-8/+16
| | | | | | | | | | This makes certain macros cheaper: macros which wrap code with numerous local functions, not all of which are expected to be used. * share/txr/stdlib/compiler.tl (compiler comp-fbind): Detect functions that are completely unused, and eliminate their code.
* compiler: streamline marking bindings used.Kaz Kylheku2018-05-231-19/+30
| | | | | | | | | | | | | | | NB: Accesses to lexical variables are not all marked used yet. * share/txr/stdlib/compiler.tl (binding): New slot, used. (sys:env lookup-var, sys:env lookup-fun, sys:env lookup-lisp1, sys:env lookup-block): Support optional Boolean argument which, if true, causes the lookup to mark the binding used. (compiler comp-return-from): Pass t to lookup-block, and remove code to mark used. (compiler comp-fun, compiler comp-fun-form): Pass t to lookup-fun to mark function used. (compiler comp-lisp1-value): Pass t to lookup-lisp1 to mark function used.
* Version 196.txr-196Kaz Kylheku2018-05-181-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* compiler: warn on misleading references in load-time.Kaz Kylheku2018-05-071-0/+9
| | | | | | | | | | | | | | | If code does something like this, we produce a warning: (let ((var 42)) (load-time (+ var 3))) A load-time form occurs in an empty lexical environment, so this code appears right but actually cannot work; the appearance is a mere trompe d'oeil. * share/txr/stdlib/compiler.tl (misleading-ref-check): New function. (compiler comp-load-time-lit): Apply misleading-ref-check.
* Version 195.txr-195Kaz Kylheku2018-05-041-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* compiler: correct semantics of special var args.Kaz Kylheku2018-05-011-7/+15
| | | | | | | | | | | | | | | | | | | The same, correct semantics for special variables in function arguments get implemented in the compiler. * share/txr/stdlib/compiler.tl (compiler comp-lambda): We stick with the strategy that each parameter which is a special variable is aliased by an anonymous lexical variable. The difference is that we bind the underlying special variable from the hidden lexical's value as early as possible. The overall processing is rearranged. On entry into the function, if any of the required arguments are specials, their values are immediately bound to the special variables in a new environment. Then the optional arguments are processed, and they bind specials in the dynamic environment also. Previously, the specials were bound in one fell swoop after processing the optionals, leading to the same incorrect semantics that the interpreter code had.