summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Better identify functions that misuse COBJ-s and hashes.Kaz Kylheku2018-11-0720-300/+445
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In this patch, the cobj_handle, cobj_ops and variants of gethash get an additional argument to identify the caller. Many functions are updated to pass this down. * buf.c (buf_strm): Pass self name to cobj_handle. * eval.c (env_fbind, env_vbind, rt_defvarl, me_case): Pass self name to gethash_c or gethash_e. (load): Pass self name to read_eval_stream and read_compiled_file. (reg_symacro): Pass situation-identifying string to gethash_c. * ffi.c (ffi_type_struct_checked, ffi_closure_struct_checked, ffi_call_desc_checked, uni_struct_checked): Take self name parameter, and pass down to cobj_handle. (ffi_get_type, ffi_get_lisp_type): Take self name and pass down to ffi_type_struct_checked. (union_get_ptr): Take self name and pass to uni_struct_checked. (ffi_union_in, ffi_union_put): Pass self name to union_get_ptr. (ffi_type_compile): Pass self name to ffi_get_lisp_type. (ffi_make_call_desc): Pass self name to ffi_type_struct_checked, ffi_get_type and ffi_call_desc_checked. (ffi_make_closure): Pass self name to ffi_call_desc_checked. (ffi_closure_get_fptr): Take self name, pass to ffi_closure_struct_checked. (ffi_typedef, ffi_size, ffi_alignof, ffi_offsetof, ffi_arraysize, ffi_elemsize, ffi_elemtype, ffi_put_into, ffi_put, ffi_in, ffi_get, ffi_out, make_carray): Pass self name to ffi_closure_struct_checked. (carray_struct_checked): Take self name, pass to cobj_handle. (carray_set_length, carray_dup, carray_own, carray_free, carray_type, length_carray, copy_carray, carray_ptr, buf_carray, vec_carray, list_carray, carray_ref, carray_refset, carray_sub, carray_replace, carray_get_common, carray_put_common, unum_carray, num_carray, put_carray, fill_carray): Pass self name to carray_struct_checked. (carray_blank, carray_buf, carray_cptr): Pass self name ffi_type_struct_checked. (carray_pun): Pass self name to carray_struct_checked and ffi_type_struct_checked. (make_union): Pass self name to ffi_type_struct_checked. (union_members, union_get, union_put, union_in, union_out): Pass self name to uni_struct_checked. (make_zstruct, zero_fill, put_obj, get_obj, fill_obj): Pass self-name to ffi_type_struct_checked. * ffi.h (ffi_closure_get_fptr, union_get_ptr): Declarations updated. * filter.c (trie_add): Pass self-name to gethash_l. * hash.c (make_similar_hash, copy_hash, hash_count, get_hash_userdata, set_hash_userdata, hash_begin, hash_next, hash_uni, hash_diff, hash_isec): Pass self name to cobj_handle. (gethash_c, gethash_e): Take self name parameter and pass down to cobj_handle. (gethash_f): Take self parameter and pass down to gethash_e. (gethash, inhash, gethash_n, sethash, pushhash, remhash, clearhash, hash_update_1): Pass self name to gethash_e or gethash_c. * hash.h (gethash_c, gethash_e, gethash_f): Declarations updated. (gethash_l): Take self name, and pass down to gethash_c. * lib.c (class_check): Take self name parameter and use in type mismatch diagnostic. (use_sym, unuse_sym, symbol_needs_prefix, find_symbol, intern, unintern, intern_fallback, unique, in, sel, obj_print_impl, populate_obj_hash, obj_hash_merge): Pass self name to gethash_f or gethash_l. (symbol_visible, obj_init): Pass situation-identifying string to gethash_e. (cobj_handle, cobj_ops): Take self name parameter and pass down to class_check. * lib.h (class_check, cobj_handle, cobj_ops): Declarations updated. * match.c (v_load): Pass self name to read_compiled_file and read_eval_stream. * parser.c (get_parser_impl): Take self name and pass to cobj_handle. (ensure_parser): Pass situation-identifying string to gethash_c. (parser_circ_def): Pass self-name to gethash_c. (lisp_parser_impl): Pass self name to get_parser_impl and class_check. (lisp_parse, nread, iread): Pass self-name to lisp_parser_impl. (read_file_common): Take self name parameter and pass down to get_parser_impl. (read_eval_stream, read_compiled_file): Take self name and pass down to read_file_common. (load_rcfile): Pass situation-identifying string to read_eval_streem. (get_visible_syms): Pass situation-identifying string to gethash_c. (parser_errors, parser_eof): Pass self name to cobj_handle. * parser.h (read_eval_stream, read_compiled_file): Declarations updated. * parser.y (rlset): Pass self name to gethash_c. * rand.c (make_random_state, random_state_get_vec,l random_fixnum, random_float): Pass self name to cobj_handle. * regex.c (regex_source, regex_print, regex_run): Pass self-name to cobj_handle. (regex_machine_init): Take self name param and pass to cobj_handle. (search_regex, match_regex, match_regex_right, regex_prefix_match, read_until_match): Pass self-name to regex_machine_init. * stream.c (stdio_get_fd): Pass self name to cobj_handle. (generic_get_line): Get COBJ operations via unsafe, diret object access rather than cobj_ops. (set_mode_props): Get object handle via unsafe, direct object access. (stream_fd, sock_family, sock_type, sock_peer, set_sock_peer, get_string_from_stream, get_list_from_stream, stream_set_prop, stream_get_prop, close_stream, get_error, get_error_str, clear_error, get_line, get_char, get_byte, unget_char, unget_byte, put_buf, fill_buf, put_string, put_char, put_byte, flush_stream, seek_stream, truncate_stream, get_indent_mode, test_set_indent_mode, set_indent_mode, get_indent, set_indent, inc_indent, width_check, force_break, get_set_ctx, get_ctx): Pass self name to cobj_ops. (make_delegate_stream): Take self name parameter, pass down to cobj_ops. (record_adapter): Pass self name down to make_delegate_stream. (format): Pass self name to class_check. * struct.c (stype_handle): Pass self name to cobj_handle. (make_struct_type): Pass self name to class_check. * txr.c (read_eval_stream_noerr): Take self name parameter, pass to read_eval_stream. (txr_main): Pass istuation-identifying string to read_compiled_file and read_eval_stream_noerr. * unwind.c (revive_cont): Pass self-name to cobj_handle. * vm.c (vm_desc_struct): Take self name parameter, pass to cobj_handle. (vm_desc_nlevels, vm_desc_nregs, vm_desc_bytecode, vm_desc_datavec, vm_desc_symvec, vm_execute_toplevel, vm_execute_closure, vm_closure_entry): Pass self name to vm_desc_struct. (vm_closure_struct): Take self name parameter, pass to cobj_handle.
* lib: remove unused type checking functions.Kaz Kylheku2018-11-072-19/+0
| | | | | | * lib.c (type_check2, type_check3): Functions removed. * lib.h (type_check2, type_check3): Declarations removed.
* Fix wrong uses of ~s for function name string.Kaz Kylheku2018-11-074-18/+18
| | | | | | | | | | | | * ffi.c (make_ffi_type_enum): Use ~a for function name rather than ~s because it's a string which is quoted under ~s. * lib.c (chk_xalloc, string_extend, find_symbol, intern_fallback): Likewise. * stream.c (open_process, run): Likewise. * sysif.c (exec_wrap, setgroups_wrap, dlclose_wrap): Likewise.
* type_check: take function name arg.Kaz Kylheku2018-11-076-56/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * arith.c (flo_int): Pass down name to type_check. * eval.c (copy_env, env_fbind, env_vbind, env_vb_to_fb, func_get_name, lexical_var_p, lexical_fun_p, lexical_lisp1_binding, squash_menv_deleting_range, op_upenv): Pass relevant Lisp function name to type_check. (lookup_global_var, lookup_sym_lisp1, lookup_fun, lookup_mac, lookup_symac, lookup_symac_lisp1): For these widely used functions, pass situational prefix in place of function name. They may get a funtion name argument in the future. * gc.c (gc_finalize): Pass function name to type_check. * lib.c (throw_mismatch): Take function nme argument, incorporate into mesage. (lcons_fun, c_flo, string_extend, symbol_name, symbol_package, get_package, package_name, func_get_form, func_get_env, func_set_env, vec_set_length, length_vec, size_vec, list_vec, lay_str_force, lay_str_force_upto, lazy_str_get_trailing_list, from, too, set_from, set_to): Pass relevant Lisp function name to type_check. (symbol_setname, symbol_visible): Pass indication of internal error into type_check, since this doesn't pertain to any Lisp function being wrong. * lib.h (throw_mismatch): Declaration updated. (type_check): Take new parameter and pass down to throw_mismatch. * signal.c (set_sig_handler): Pass name down to type_check.
* symbol_needs_prefix: take function name argument.Kaz Kylheku2018-11-072-4/+4
| | | | | | | | * lib.c (symbol_needs_prefix): New parameter. (unquote_star_check, obj_print_impl): Pass Lisp function name to symbol_needs_prefix. * lib.h (symbol_needs_prefix): Declaration updated.
* lazy strings: remove two type checks.Kaz Kylheku2018-11-071-2/+0
| | | | | | * lib.c (lazy_str_put, out_lazy_str): The very few calls to these functions already ensure that the object is a lazy string; let's drop the check.
* math: improve error diagnosis.Kaz Kylheku2018-11-076-123/+198
| | | | | | | | | | | | | | | | | | | | | | | | | | More streamlined code, better identification of functions. * arith.c (not_number, not_integer, invalid_ops, invalid_op, divzero): New static functions. (num_to_buffer, bugnum_len, plus, minus, neg, abso, signum, mul, trunc1, mod, floordiv, round1, roundiv, divi, zerop, plusp, minusp, evenp, oddp, gt, lt, ge, le, numeq, expt, exptmod, floorf, ceili, sine, cosi, tang, asine, acosi, atang, loga, logten, logtwo, expo, sqroot, int_flo, flo_int, cum_norm_dist, inv_cum_norm): Establish function's Lisp name as self variable. Use new static functions for reporting common errors. Pass function name to new argument of c_flo function. * buf.c (buf_put_float, buf_put_double): Pass function's Lisp name to c_flo function. * ffi.c (ffi_float_put, ffi_double_put): Likewise. * lib.c (c_flo): Takes new argument, name of calling function. * lib.h (c_flo): Declaration updated. * stream.c (formatv): Pass function name to c_flo.
* lib: use type switch in some string functions.Kaz Kylheku2018-11-061-79/+67
| | | | | | * lib.c (length_str, c_str, length_str_gt, length_str_ge, length_str_lt, length_str_le): Streamline code into single switch on the type code of the object.
* gc: eliminate most uses of gc_mutated.Kaz Kylheku2018-11-066-17/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code is using gc_mutated in situations that resemble assignment: a value is stored into a slot in some object. These situations should be handled using the same logic as embodied in the gc_set function. This is because gc_set will consider both objects, and in many cases will not have to do anything special. E.g. if an immature object is stored into another immature object, or mature into immature, or mature into mature. Whereas gc_mutated is a "just in case" function which forces the garbage collector to traverse the indicated object, if that object is mature. In this patch we refactor gc_set to expose its underlying logic with a somewhat more flexible function called gc_assign_check. We put that behind a conditionally defined macro called setcheck, and then use that to replace invocations of the mut macro in various places. The only uses of gc_mutated that remain are in the bulk vector assignment and copy_struct: operations in which potentially many element values are migrated from one aggregate object to another, making it potentially expensive to do individual assignment checks. * gc.c (gc_assign_check): New function, formed from guts of gc_set. (gc_set): Now a trivial function, implemented via call to gc_assign_check. * gc.h (gc_assign_check): Declared. * lib.c (cons): Use setcheck instead of gc_mutated, since we are storing only two values into the existing cons: the car and the cdr. * struct.c (clear_struct): Use setcheck instead of gc_mutated, since we are just storing one value into the structure, the clear_val. The fact that we are storing it into multiple slots is irrelevant. * vm.c (vm_make_closure): Use setcheck instead of mut, using the new heap_vector as the child object with regard to the closure. Rationale: the only threat here is that when we allocate the heap vector, a GC is triggered which pushes the closure into the mature generation. Then the store of the heap vector into the closure is a wrong-way reference, with regard to generational GC. The elements in the vector are immaterial; they are older than both the closure and the vector, therefore their relationship to either object is a right-way reference. (vm_set, vm_sm_set): Replace mut by a setcheck between the vector from the display and the new value being stored in it. (vm_stab): Replace the gc_mutated check, which should have been a mut macro call, with a setcheck between the vm, and the binding being stored into the table. The gc_mutated should have been wrapped with an #if CONFIG_GEN_GC so we are fixing a build bug here: the code would have prevented TXR from being built with the generational GC disabled.
* doc: load: document hash bang treatment.Kaz Kylheku2018-11-061-0/+8
| | | | | * txr.1: Document that the load function ignores the hash bang line in both compiled and source files.
* vim: colorize hash bang for Lisp.Kaz Kylheku2018-11-061-1/+2
| | | | | | * genvim.txr: generate the txr_hashbang match in both txr.vim and tl.vim, not only txr.vim. Use Vim's \% regex operator to match only in the first line of a file.
* doc: split/split*: formatting of syntaxKaz Kylheku2018-11-061-2/+2
| | | | * txr.1: Fix funny formatting.
* load: tolerate hash bang files.Kaz Kylheku2018-11-051-0/+3
| | | | | * eval.c (load): Consume the first line of the input file if it starts with hash bang.
* bugfix: error on empty script file.Kaz Kylheku2018-11-051-8/+12
| | | | | * txr.c (check_hash_bang): When the file is empty, get_line returns nil.
* compiler: bugfix: handle defpackage and such properly.Kaz Kylheku2018-11-053-7/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-057-1006/+1054
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* buffers: implement copy-buf.Kaz Kylheku2018-11-044-0/+34
| | | | | | | | | | | * buf.c (copy_buf): New function. (buf_init): Register copy-buf intrinsic. * buf.h (copy_buf): Declared. * lib.c (copy): Handle BUF via copy_buf. * txr.1: Documented.
* compiler: optimize dwim.Kaz Kylheku2018-11-046-24/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-027-29/+318
| | | | | | | | | | | | | | | | | | | | | | | 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.
* doc: lexical-fun-p: mistake in code example.Kaz Kylheku2018-11-021-2/+2
| | | | * txr.1: Fix misnamed references to macro parameter.
* listener: use temp file when saving history.Kaz Kylheku2018-11-021-2/+8
| | | | | | | | | We don't want ot overwrite the history file in-place; if something goes wrong, we will lose half of it. * parser.c (repl): Save the history to a .tmp file, and then rename that to the target name, if the write is successful.
* listener: avoid unnecessary string duplication.Kaz Kylheku2018-11-021-2/+1
| | | | | | | | | | * parser.c (repl): There is no need to use chk_strdup on the string inside histfile. We can just use the original string, since it won't be garbage collected. The existing gc_hint(histfile) at the end of the function ensures this. The reason the chk_strdup was done is that originally this was a utf8_dup_to that I just blindly replaced when the listener Unicode conversion took place.
* linenoise: use move_cursor in movement operations.Kaz Kylheku2018-11-011-36/+23
| | | | | | | | * linenoise/linenoise.c (edit_move_left, edit_move_right, edit_move_home, edit_move_sol, edit_move_end, edit_move_eol, edit_move_matching_paren): Use the efficient move_cursor instead of punching in the new position and calling refresh_line.
* linenoise: check for null move in move_cursor.Kaz Kylheku2018-11-011-0/+3
| | | | | * linenoise/linenoise.c (move_cursor): Do nothing if the requested position is current.
* linenoise: small move_cursor bugfix.Kaz Kylheku2018-11-011-0/+1
| | | | | | | | | | | * linenoise/linenoise.c (move_cursor): We must update the oldrow variable, expected by refresh_line to be tracking the row position of the cursor. This bug doesn't affect the current use of move_cursor for paren_jump, because that logic moves the cursor to the original position, which makes the oldrow value correct, and refresh_line is never called in between. If we want to use move_cursor in more situations, this has to be fixed.
* linenoise: fix use of int for wide char.Kaz Kylheku2018-11-011-1/+1
| | | | | | | * linenoise/linenoise.c (history_search): The c variable for capturing the input character should be of type wint_t, not int. This was caught by GNU C++, due to a signed/unsigned warning when c was compared to WEOF.
* linenoise: avoid refresh in paren matching.Kaz Kylheku2018-11-011-4/+51
| | | | | | | | | | * linenoise/linenoise.c (move_cursor_multiline, move_cursor): New functions. (paren_jump): Use move_cursor rather than refresh_line. In multi-line mode, this calculates the required cursor movement and emits the escape sequences to make it happen, without issuing a refresh, sending way less data to the terminal.
* linenoise: avoid refresh for new text in multi-line mode.Kaz Kylheku2018-11-011-3/+9
| | | | | | | | * linenoise/linenoise.c (edit_insert): This function is missing an important optimization for multi-line mode. Let's add it. Since multi-line mode doesn't scroll horizontally, it is very simple: if a character is added at the end, there is no need for refresh.
* linenoise: clear need_refresh in refresh_line.Kaz Kylheku2018-11-011-3/+3
| | | | | | | | | | * linenoise/linenoise.c (refresh_line): Clear the need_refresh flag here. (edit): No need to clear it here any more. This will prevent some useless calls to refresh_line. Some edit operations set refresh_line, but then execute something that performs refresh_line unconditionally. If the flag is then reset, the top of the loop doesn't have to do another wasteful refresh.
* linenoise: move modulo operation into function.Kaz Kylheku2018-11-011-3/+3
| | | | | | | | | * linenoise/linenoise.c (col_offset_in_str): Take a cols parameter and wrap the return value into the number of columns. (refresh_multiline): No need to do the % cols operation on the return value of col_offset_in_str any more; just pass cols down into it.
* linenoise: guard against setting cols to zero.Kaz Kylheku2018-11-011-1/+1
| | | | | | | | * linenoise/linenoise.c (get_columns): Avoid the situation that cols is zero or negative. The cols value is involved in a modulo calculation (position % cols), which requires cols not to be zero. The situation hasn't been observed; this is just defensive coding.
* linenoise: improve efficiency of warning flash.Kaz Kylheku2018-11-011-12/+20
| | | | | | | | | | | * linenoise/linenoise.c (usec_delay): return a Boolean indicator whether the delay was prematurely canceled by input. (flash): Use the return value of usec_delay to bail out of the loop early, canceling the flashing. Instead of doing full line refreshes to display and hide the exclamation mark, perform the flash by simply printing the exclamation mark at the current location and then erasing it with backspace-space-backspace.
* repl: bugfix: slow paste into terminal window.Kaz Kylheku2018-11-011-1/+3
| | | | | | | | | | * stream.c (stream_init): When stdin is a TTY, we make it unbuffered. This affects the parenthesis matching and incomplete line warning flash in the listener, in the following way. The listener uses the poll function to execute delays which is canceled by the presence of TTY input. This logic breaks when data is pasted into the terminal, because the stdin stream buffers the input.
* repl: bugfix: abort on window size change.Kaz Kylheku2018-10-311-3/+21
| | | | | | * parser.c (lino_getch): Catch the exception that is thrown by get_char when the read fails with EINTR due to the SIGWINCH interrupt. Convert exception to WEOF return.
* repl: allocate the "catch all" exception list once.Kaz Kylheku2018-10-311-5/+3
| | | | | | * parser.c (catch_all): New static variable. (provide_atom, repl): Use static catch_all. (parse_init): Protect catch_all from GC reclamation.
* linenoise: bugfix: incorrect tests for WEOF.Kaz Kylheku2018-10-311-7/+7
| | | | | | | * linenoise/linenoise.c (complete_line, history_search, edit): The test c < 0 is not correct. Unlike EOF, WEOF isn't required to be negative, and in fact in the glibc environment, it isn't.
* Hide deprecated, undocumented variables.Kaz Kylheku2018-10-303-7/+19
| | | | | | | | | | * arith.c (arith_init): Do not define *flo-dig*, *flo-max*, *flo-min*, *flo-epsilon*, *pi* and *e* unless compatibility with TXR 199 or earlier is requested. * txr.c (txr_main): Likewise for *self-path*. * txr.1: Compat note added.
* initialization: use self_path_s instead of re-interning.Kaz Kylheku2018-10-301-1/+1
| | | | | | * txr.c (txr_main): When establishing self-path with a new value, use self_path_s instead of calling intern on the symbol name again.
* doc: correction under Object TypeKaz Kylheku2018-10-301-1/+1
| | | | | | * txr.1: Square brackets in the graph indicate a categorization node that is invisible to programs, not visible.
* html doc: "collapse all" shouldn't hide whole TOC.Kaz Kylheku2018-10-291-7/+9
| | | | | | | | | | | | * genman.txr: show the toggle as "expand all" initially. Assign the sections of the TOC to the "tocsec" class, and then select the elements by class rather than by the dl element type. This avoids selecting the dl that wraps the entire TOC. (xpanded): New boolean variable. (toggleall): Base toggle on boolean variable rather than the state of the first section dl element. Toggle the xpanded variable.
* Version 199.txr-199Kaz Kylheku2018-10-287-490/+536
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Regenerated.
* hash: gnu C++ signed/unsigned warning.Kaz Kylheku2018-10-281-1/+1
| | | | | * hash.c (hash_double): Fix comparison warning between signed loop variable and unsigned limit expression.
* genvim: include .tlo files in vimrc example.Kaz Kylheku2018-10-281-2/+2
| | | | | * genvim.txr: In the Vim syntax file comment's example .vimrc lines, include .tlo files, which are just TXR Lisp syntax.
* doc: *rec-source-loc* bad heading formattingKaz Kylheku2018-10-281-1/+1
| | | | * txr.1: Fix missing @ for code font.
* doc: new section: Compiled File Compatibility.Kaz Kylheku2018-10-271-0/+54
| | | | | | | * txr.1: TXR doesn't guarantee backwards compatibility for handling compiled files, as it does for most aspects of its operation. This has to documented in its own section. Also adding a paragraph to COMPATIBILITY to discuss this.
* doc: document compile-file and load-time interaction.Kaz Kylheku2018-10-271-0/+18
| | | | | * txr.1: Document that compile-file evaluates load-time forms during compilation unless compile-only is used.
* doc: add Compilation Library section header.Kaz Kylheku2018-10-271-0/+2
| | | | | | | | * txr.1: We need a SS section for the compilation functions, otherwise they appear to be children of the preceding "Treatment of the Hash Bang Line" section. An alternative would have been to promote them to a higher section level with .coSS instead of .coNP.
* 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.
* defvar: warn about prior lexical uses.Kaz Kylheku2018-10-263-1/+11
| | | | | | | | | | | | | | | | | | | Now that the compiler has a more efficient treatment of global lexical variables, code which accesses global variables that have not yet been defined will misbehave if the intent is to for those variables to be dynamically scoped. There is such a bug in the op expander, in fact. * eval.c (me_def_variable): When defvar/defparm are expanding, they now check whether there is an outstanding unbound warning against the variable. If so, then a warning is issued that the variable was previously used lexically and is now being marked special. * unwind.c (uw_warning_exists): New function. * unwind.h (uw_warning_exists): Declared.
* compiler: use symtab caching for global lexicals.Kaz Kylheku2018-10-262-10/+17
| | | | | | | | | | | | | | | | * 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.