summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* parser: propagate copyright to generated parser.Kaz Kylheku2018-04-161-2/+2
| | | | | | | | | | * parser.y: Move the copyright comment header into the %{ ... %} section so that it is copied to the generated parser, rathe than stripped away by the generator. The problem is that Bison adds a GPL header to the file wrongly implying that the whole thing is under the GPL (with a special exception). Without our copyright header there, it looks as if the whole file is from Bison.
* Makefile: bugfix: shell quoting issue in macro.Kaz Kylheku2018-04-161-1/+1
| | | | | | | | | | * Makefile (SH): The $(1) macro argument is substituted into a shell '...' quote. It may contain single quotes itself, so these have to be mapped to the famous '\'' sequence. Currently, only one SH call has '...' syntax in it: one in the y.tab.c rule which calls sed -e '/yyparse/d'. That works anyway, and the quotes could be removed from it; but let's fix the SH macro.
* parser: show starting line of unterminated form.Kaz Kylheku2018-04-151-0/+5
| | | | | | * parser.y (parse): Note the line number before parsing. If the error seems to be bad termination, issue an extra message indicating the starting line number of the form.
* compiler: lambda call to let optimization.Kaz Kylheku2018-04-153-7/+81
| | | | | | | | | | | | | | | | | | | Normalize ((lambda ...) args) to (call (lambda ...) args). Reduce (apply (lambda ...) args) and (call (lambda ...) args) to let (let (vars-inited-from-args ...) ...). * lisplib.c (error_set_entries): Autoload for new error functions lambda-too-many-args, lambda-too-few-args, lambda-short-apply-list. * share/txr/stdlib/compiler.tl (comp-fun-form): Restructure to recognize lambda and handle via comp-inline-lambda. (compiler comp-inline-lambda): New method. (lambda-apply-transform): New function. * share/txr/stdlib/error.tl (lambda-too-many-args, lambda-too-few-args, lambda-short-apply-list): New functions.
* compiler: use new parser for macro params.Kaz Kylheku2018-04-151-100/+80
| | | | | | * share/txr/stdlib/compiler.tl (expand-bind-mac-parse-params): Function removed. (expand-bind-mac-params): Use mac-param-parser struct.
* compiler: move lambda param parsing into struct.Kaz Kylheku2018-04-141-85/+116
| | | | | | | | * share/txr/stdlib/compiler.tl (param-parser-base, fun-param-parser, mac-param-parser): New structs. (compiler comp-lambda): Construct a fun-param-parser object using parameter syntax. Then just extract the parsed pieces for further processing.
* compiler: lambda: accurate determination of need-frame.Kaz Kylheku2018-04-141-3/+3
| | | | | | | | | | | | | * share/txr/stdlib/compiler.tl (comp-lambda): The local variable need-frame is supposed to indicate whether the lambda needs a frame for its arguments: i.e. whether it has any parameters. However the way it is calculated is poor: the fixed-pars list potentially includes the semicolon symbol : which separates the required parameters from optionals. Hence the parameter list syntax (:) will be treated as "needs frame", even though it denotes an empty parameter list, just like the syntax (). This slight flaw is now tightened up.
* compiler: bugfix: handle lambda call form.Kaz Kylheku2018-04-131-0/+2
| | | | | | | | | Looks like the compiler neglects to handle the syntax ((lambda (params ...) body ...) args ...). * share/txr/stdlib/compiler.tl (compiler compile): Check for a lambda expression in the car position of a form; if it's present then ((lambda ...) ...) -> (call (lambda ...) ...).
* case macros: switch for integer and char ranges.Kaz Kylheku2018-04-131-0/+77
| | | | | | | | * eval.c (hash_min_max): New static function. (me_case): Check for keys being all integers or all characters in a dense range (> 75% full). Generate code for switching directly on the displacement of the tested value into the key range.
* build: compiling Lisp requires ./txr to exist.Kaz Kylheku2018-04-121-2/+2
| | | | | | | | * Makfile (%.tlo, %.tlo2): We take advantage of Gmake's order-only prerequisites to express this dependency. This means that .tlo and .tlo2 files are not considered outdated when $(PROG) is newer; it only ensures that $(PROG) cannot be missing when a .tlo or .tlo2 must be updated.
* build: prevent make parallelization.Kaz Kylheku2018-04-121-0/+2
| | | | | | * Makefile: add .NOTPARALLEL: special target. This Makfile doesn't support parallel builds; it relies on left-to-right execution of prerequisites in some places.
* compile-file: need endian mark in .tlo files.Kaz Kylheku2018-04-125-3/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | VM machine code is endian-specific: it consists of 32 bit instruction words which are 32 bit in the local byte order. Thus code assembled on a little-endian machine won't run on a big endian-machine, or vice versa: unless we identify the situation and byte-swap the code when we load it. * buf.c (buf_swap32): New function. * buf.h (buf_swap32): Declared. * parser.c (read_file_common): Decode the third element from the version: a Boolean indicating big endian, if true. If the object file's endian is opposite from our endian, then byte swap the code. * itypes.c (itypes_init): Oops, calculation of itypes_little_endian was broken due to classic C =/== typo. Luckily, nothing has used this flag so far; it's been waiting for this first use. I caught this due to testing on a PPC64 box. * share/txr/stdlib/compiler.tl (%big-endian%, %tlo-ver%): New variables. (usr:compile-file): The file version comes from %tlo-ver% now, which includes the big-endian flag.
* Version 191.txr-191Kaz Kylheku2018-04-107-632/+733
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* load: fix vm gc issue.Kaz Kylheku2018-04-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This issue manifested itself as a segfault on Mac OS while compiling a library file using the compiled implementation (hash.tl -> hash.tlo2). The problem is premature reclamation of a virtual machine description. While the asm.tlo module is loaded, suddenly a function table goes corrupt. When we execute machine using vm_execute_toplevel, the vm's stack doesn't actually contain a reference to the description object anywhere. It's passed in as a parameter, and right away converted to the (struct vm_desc *) handle which is planted in the struct vm representing the running instance, which lives on the stack. That pointer isn't a reference traversed by the garbage collector. If the original Lisp object is optimized away and overwritten both in vm_execute_toplevel and in that function's caller, then it can be reclaimed even as it executes. * parser.c (read_file_common): Add a gc_hint(desc) after the vm_execute_toplevel so that the compiler thinks the value of the variable is still needed after the call. That keeps it around on the stack or in a register so that the garbage collector can see it as a root pointer.
* Windows: package .tlo files.Kaz Kylheku2018-04-101-0/+1
| | | | | * inst.nsi (section "TXR"): Add File command to package up the compiled .tlo files.
* vm: don't eagerly resolve functions.Kaz Kylheku2018-04-101-7/+0
| | | | | | | | | | | | | | | * vm.c (vm_make_desc): Do not walk ftab to resolve the function bindings at VM instantiation time. Just let it be done late in vm_ftab when a gcall or gapply instruction is executing. We don't gain anything by doing it early; there is no error checking or anything. This early resolution causes the autoload semantics of the standard library modules to change between interpreted and compiled. When a compiled module is loaded, it immediately triggers autloads of everything that it potentially references. This suddenly broke the build under a newer GNU Make which doesn't sort the files expanded by $(wildcard ...), causing the library to be compiled in a different order.
* defpackage: bugfix: symbol clash.Kaz Kylheku2018-04-101-3/+3
| | | | | | | | * share/txr/stdlib/package.tl (defpackage): Now that library file are read in the sys package, this macro's name-str local variable is the same symbol as sys:name-str, the function it uses. They clash in the (op sys:name-str ...) syntax. Let's rename the local.
* parser: @(if) hack in output must use usr package.Kaz Kylheku2018-04-103-6/+7
| | | | | | | | | | | * match.c (else_s, elif_s): New symbol variables. (syms_init): Initialize new variable with interned symbols. * match.h (else_s, elif_s): Declared. * parser.y (not_a_clause): Refer to if_s, else_s and elif_s, which are symbols in the usr package, instead of intering symbols in whatever package is current.
* parser: duplicate package prefix in diagnostic.Kaz Kylheku2018-04-101-2/+2
| | | | | * parser.l (directive_tok): Fix printing of duplicate package prefix on symbol.
* doc: new package fallback use by printer.Kaz Kylheku2018-04-101-1/+3
| | | | | * txr.1: Update the description of how the printer avoids ambiguity when making use of the packag fallback list.
* doc: document new pub package.Kaz Kylheku2018-04-091-11/+32
| | | | | | * txr.1: Fix places which say that *package* is initialized to the user package. Under *package*, describe the pub package. Compat notes added.
* doc: vm-fun-p described.Kaz Kylheku2018-04-091-0/+22
| | | | * txr.1: Document vm-fun-p.
* compiler: implement with-compilation-unit macro.Kaz Kylheku2018-04-093-36/+82
| | | | | | | | | | | | * lisp.c (compiler_set_entries): Add with-compilation-unit to autoload symbols for compile module. * share/txr/stdlib/compiler.tl (usr:with-compilation-unit): New macro. (usr:compile-file): Use with-compilation-unit macro to dump warnings if a file is processed alone. * txr.1: Documented.
* compiler: record source loc when reading.Kaz Kylheku2018-04-091-0/+1
| | | | | | | * share/txr/stdlib/compiler.tl (usr:compile-file): Bind *rec-source-loc* to t, otherwise the read function doesn't record source loc info and we don't get warnings reported against line numbers in the processed source files.
* doc: document force-flag.Kaz Kylheku2018-04-091-5/+92
| | | | | | * txr.1: Documented force-break and the altered return value of width-check. The existence of a stream's force flag is mentioned under width check.
* compiler: improve and & or.Kaz Kylheku2018-04-091-27/+30
| | | | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-and-or): Handle the trivial zero and one argument cases separately. In particular, the one-argument case results in better code because it eliminates a temporary register. We don't have to test for the zero-arg case any more in the general case, so it is simplified in a few cases.
* doc: document disassemble.Kaz Kylheku2018-04-091-0/+51
| | | | * txr.1: Adding description of disassemble function.
* awk/struct: fix breakage under interpreted mode.Kaz Kylheku2018-04-092-8/+8
| | | | | | | | | | | | | | References to rslot must be usr:rslot because there is a sys:rslot. Some difference in loading order causes this not to be a problem when runing compiled "make tests", but if the .tlo files are removed, the awk test case fails. * share/txr/stdlib/awk.tl (sys:awk-mac-let): Replace rslot with usr:rslot. * share/txr/stdlib/struct.tl (rslot): Replace rslot symbol token with usr:rslot in definitions of rslot macro and rslot place macro.
* doc: describe new ldiff.Kaz Kylheku2018-04-091-87/+160
| | | | | * txr.1: ldiff documentation moved under Sequence Manipulation and rewritten. Compatibility note added.
* listener: completion: wrong use of package fallback.Kaz Kylheku2018-04-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | | The problem is that completion on pub:sym[Tab] is completing on the fallback list, because pub is the current package. If we type pub:l[Tab], we might complete to pub:list. But that's because usr:list was found in the fallbacklist; pub:list isn't that symbol, and its use will shadow usr:list. This is against the documentatiion too, which describes it the way it should work: simply that the fallback list of the current package is used under completion when no package qualifier prefix is present. * parser.c (get_visible_syms): Rename second parameter to reflect its actual meaning, rather than an original intended use. (find_matching_syms): Only allow get_visible_syms to traverse package fallback lists if qualify is false. Thus even if we are completing against the current package, if that package is being explicitly indicated with a prefix, then only the package local symbols are included.
* doc: copy-paste errors in structs.Kaz Kylheku2018-04-081-3/+3
| | | | | | * txr.1: Fixed syntax synopsis under struct-type using structp. Improved some wording here. Fixed static-slot-home's syntax synopsis wrongly referring to static-slot-ensure.
* compiler: fix broken prog1.Kaz Kylheku2018-04-081-3/+3
| | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-prog1): The output of the frag should be fireg, not oreg. We need to move into fireg before re-frag.code is executed, because the data source in fi-frag may be clobbered by re-frag.
* doc: document more about file compilation.Kaz Kylheku2018-04-081-0/+143
| | | | | * txr.1: Add descriptions of compile-file, compile-only and eval-only.
* doc: starting to document compilation.Kaz Kylheku2018-04-081-7/+286
| | | | | * txr.1: Description of load includes treatment of .tlo files. New major section on Lisp compilation.
* expander: no dot-to-apply transform on special forms.Kaz Kylheku2018-04-081-1/+3
| | | | | | | | * eval.c (do_expand): Do not convert (op arg ... . dot) to (sys:apply (fun op) (sys:l1-value arg) ... dot) if op is a special operator; this is only valid for functions. This issue has been uncovered by new diagnosis of undefined functions in the fun operator.
* expander: consolidate dotted argument error.Kaz Kylheku2018-04-081-6/+9
| | | | | | | * eval.c (dotted_form_error): New static function. (expand_forms, expand_forms_ss, expand_forms_lisp1): Call dotted_form_error instead of repeated open coded uw_throwf calls.
* configure: lndir tweaks.Kaz Kylheku2018-04-081-1/+2
| | | | | | * configure (lndir): Strip trailing slash from todir argument to prevent double slashes. Remove the destination in case it is a symlink to a directory.
* trace: refer usr:catch operator rather than sys:catch.Kaz Kylheku2018-04-081-3/+3
| | | | | | * share/txr/stdlib/trace.tl (sys:trace, sys:untrace): Now that library code is being read in the sys package, catch refers to the sys:catch special form; we want the usr:catch macro here.
* trace: bugfix: redefine check mustn't throw exceptions.Kaz Kylheku2018-04-081-6/+10
| | | | | | | | | * share/txr/stdlib/trace.tl (sys:trace-canonicalize-name): Don't call static-slot-home on something that might not be a struct type symbol. Otherwise the trace module will throw whenever some lookup is performed for a non-existent method. That means that when trace is loaded, it is impossible to define a method with defun.
* compiler: fix overestimated register count.Kaz Kylheku2018-04-072-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The compiler internally allocates registers that are never inserted into code (but correctly recycled). Thus the treg bump counter overestimates the actual number of registers that a VM requires; but that's how we use it! That causes wasted stack space. What we can do to get a tightly clamped register count is simply to let the assembler report the highest-numbered treg operand that it finds in the code. (In the future we will need something better to optimize the register allocation. Why: because closures have their own VM instance with its own registers. If an overall VM uses registers t00 through t09, but a certain closure uses only t02 through t06, that closure's frame only needs to allocate seven registers.) * share/txr/stdlib/asm.tl (assembler): New slot, max-treg. (assembler parse-args): Whenever a register operand is parsed, if it is a t register, update max-treg. * share/txr/stdlib/compiler.tl (usr:compile-toplevel): When creating the vm-desc, determine the nreg parameter from the assembler's max-treg value, rather than from the compiler's treg allocation bump counter.
* case macros: bugfix: use hash for caseql and casequal too.Kaz Kylheku2018-04-071-2/+1
| | | | | | | | | | * eval.c (me_case): Correct the condition. We want to generate for all the case comparison types. The only situation we want to avoid is when the keys do not use eq equality, but caseq is used. The reason is that the underlying hash table is eql-based, not eq-based: it's not the right kind of hash table for caseql/caseql*. We can only use it if two keys might be eql that are not eq.
* case macros: reduce consing.Kaz Kylheku2018-04-071-6/+8
| | | | | | | * eval.c (compares_with_eq): New static function. (me_case): Instead of check_fun, call compares_with_eq directly. For the case when we map over check fun, allocate the function just once, outside the loop.
* new function: compile.Kaz Kylheku2018-04-072-1/+16
| | | | | | * lisplib.c (compiler_set_entries): Add compile to autoloads. * share/txr/stdlib/compiler.tl (usr:compile): New function.
* asm: support disassembly on functions.Kaz Kylheku2018-04-071-8/+19
| | | | | | | | | | * share/txr/stdlib/asm.tl (disassemble): Drop usr: prefix since symbol is interned already in usr package. Handle vm functions by obtaining their vm desc and entry point. Disassemble whole desc, then indicate entry point. The fallback case tries the object as a potential function name and recurses, so (disassemble '(meth struct slot)) and (disassemble 'name) will work.
* vm: new accessors for closure objects.Kaz Kylheku2018-04-071-0/+19
| | | | | | | * vm.c (vm_closure_struct): New static function. (vm_closure_desc, vm_closure_entry): New functions. (vm_init): sys:vm-closure-desc and sys:vm-closure-entry intrinsics registered.
* lib: new function vm-fun-p.Kaz Kylheku2018-04-073-0/+7
| | | | | | | | * eval.c (eval_init): vm-fun-p intrinsic registered. * lib.c (vm_fun_p): New function. * lib.h (vm_fun_p): Declared.
* build: don't rebuild tlo's all the time.Kaz Kylheku2018-04-071-2/+2
| | | | | | | | * Makefile (%.tlo, %.tlo2): Drop dependency on $(TXR). Of course, the dependency is strictly correct, but most changes to TXR are irrelevant. Moreover, not all relevant dependencies are in place anyway; if we change compile.tl, only the compile.tlo is recompiled.
* vm: allow vm description to be callable as function.Kaz Kylheku2018-04-062-0/+6
| | | | | | | * lib.c (generic_funall): Handle vm-desc objects via vm_execute_toplevel. * vm.h (vm_desc_s, vm_closure_s): Declared.
* asm: rename disassembly helper function.Kaz Kylheku2018-04-061-2/+2
| | | | | | | | * share/txr/stdlib/asm.tl (disassemble-c-d): Rename to disassemble-cdf. These letters stand for code, data vector, function vector. The name had been was chosen before the VM had function vectors. (usr:disassemble): Follow rename.
* vm: C++ port issue: wrong cast.Kaz Kylheku2018-04-061-1/+1
| | | | | * vm.c (vm_insn_opcode): Conversion between integer types requires convert rather than coerce.