summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
| * * configure: Support a gen-gc configuration variable whichKaz Kylheku2012-04-0312-58/+195
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | causes CONFIG_GEN_GC to be defined as 1 in config.h. * eval.c (op_defvar, dwim_loc, op_modplace, transform_op): Handle mutating assignments via set macro. (op_dohash): Inform gc about mutated variables. TODO here. * filter.c (trie_add, trie_compress): Handle mutating assignments via set macro. * gc.c (BACKPTR_VEC_SIZE, FULL_GC_INTERVAL): New preprocessor symbols. (backptr, backptr_idx, partial_gc_count, full): New static variables. (make_obj): Initialize generation to zero. (gc): Added logic for deciding between full and partial gc. (gc_set, gc_mutated): New functions. * gc.h (gc_set, gc_mutated): Declared. * hash.c (hash_mark): Changed useless use of vecref_l to vecref. (gethash_f): Use set when assigning through *found since it is a possible mutation. * lib.c (car_l, cdr_l, vecref_l): Got rid of loc macro uses. Using the value properly is going to be the caller's responsibility. (push): push may be a mutation, so use set. (intern): Uset set to mutate a hash entry. (acons_new_l, aconsq_new_l): Use set when replacing *list. * lib.h (PTR_BIT): New preprocessor symbol. (obj_common): New macro for defining common object fields. type_t is split into two bitfields, half a pointer wide, allowing for generation to be represented. (struct any, struct cons, struct string, struct sym, struct package, struct func, struct vec, struct lazy_cons, struct cobj, struct env, struct bignum, struct flonum): Use obj_common macro to defined common fields. (loc): Macro removed. (set, mut): Macros conditionally defined for real functionality. (list_collect, list_collect_nconc, list_collect_append): Replace mutating operations with set. * match.c (dest_set, v_cat, v_output, v_filter): Replace mutating operations with set. * stream.c (string_in_get_line, string_in_get_char, strlist_out_put_string, strlist_out_put_char): Replace mutating operations with set. * unwind.c (uw_register_subtype): Replace mutating operation with set.
| * * lib.c (vec_set_length): Use set instead of assignment.Kaz Kylheku2012-04-023-3/+15
| | | | | | | | | | | | | | | | (vecref_l): Use loc to lift address of cell. (replace_vec): Use macro mut to indicate the object is being mutated. * lib.h (mut): New macro.
| * Start of ground-work for ephemeral GC. We must add some abstractionKaz Kylheku2012-04-015-30/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to places where we potentially assign a reference to a younger object inside a field located in an older object (chronological backreference) and also where we take the address of an object field, making it possible that the user of the address will do so. This patch does not take care of vectors. No, this is not an April Fool's joke. * eval.c (env_fbind, env_vbind, env_replace_vbind, lookup_var, lookup_sym_lisp1): Use set macro instead of assignment. * hash.c (hash_grow, set_hash_userdata, hash_next): Use set macro instead of assignment. * lib.c (rplaca, rplacd, string_extend, length_str, replace_str, rehome_sym, lazy_stream_func, lazy_str, lazy_str_force, lazy_str_force_upto, obj_init): Use set macro instead of assignment. (car_l, cdr_l): Use loc instead of address-of operator. * lib.h (set, loc): New macros.
* | * txr.vim: @[...] syntax not marked as "contained" because itKaz Kylheku2012-04-052-1/+6
|/ | | | can freely occur, and is useful in @(output).
* * hash.c (last_equal_key, last_equal_hash): New static variables.Kaz Kylheku2012-03-312-23/+58
| | | | | | | (equal_hash): Caching optimization implemented. (eql_hash): Optimization extended to those objects that have equal semantics. (hash_process_weak): Clear the cached hash during gc.
* If one of the blocks which are subordinate to a @(trailer)Kaz Kylheku2012-03-315-11/+100
| | | | | | | | | | | | | | | | | | | | | happen to request a successful termination by invoking @(accept) the position must not advance into the trailer material. * match.c (v_trailer): Added an unwind protect which detects that an accept is taking place and adjusts the return value to restrict the input position at the point given to trailer. (accept_fail): Use uw_block_return_proto instead of uw_block_return and pass the symbol as the protocol identifier. * unwind.c (uw_current_exit_point): New function. (uw_block_return): Function renamed to uw_block_return_proto; takes new parameter which is stored in the block structure. * unwind.h (struct uw_block): New member, protocol. (uw_block_return): Becomes an inline wrapper for uw_block_return_proto. (uw_block_return_proto, uw_current_exit_point): Declared. * txr.1: Interaction between @(trailer) and @(accept) documented.
* * match.c (h_var): Disallow the variable named by the symbol tKaz Kylheku2012-03-303-10/+45
| | | | | | | | by throwing an exception. Allow nil, but wherever nil occurs, do not produce a binding. * txr.1: State the restrictions against using t in the section on Variables and also describe the nil ignore feature.
* * txr.1: Correction: backtracking does NOT take place into a blockKaz Kylheku2012-03-302-3/+8
| | | | which completed.
* * txr.1: Documenting the debugger with an example session.Kaz Kylheku2012-03-302-0/+196
|
* Version 63txr-63Kaz Kylheku2012-03-305-4/+59
| | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES: Updated.
* * lib.c (num_str): Much more accurate test for deciding whetherKaz Kylheku2012-03-303-7/+57
| | | | | | | | | to treat the number as floating or integer. We can't just look for the presence of E, e or . because these coudl be part of trailing junk for instance "123XYZE." should convert to the integer 123, where "XYZE." is trailing junk. * txr.1: Documented int-str, flo-str and num-str.
* * arith.c (numeq): Fix misplaced parenthesis.Kaz Kylheku2012-03-292-1/+5
|
* * lib.c (min2, max2): Semantics tweak. If the numbers are equal,Kaz Kylheku2012-03-293-2/+34
| | | | | | favor the left one. * txr.1: Documented min and max.
* * arith.c (numeq): New function.Kaz Kylheku2012-03-297-8/+208
| | | | | | | | | | | | | | | | | (exptmod): Bugfix: was no normalizing the bignum, ouch. Also was reporting "non-integral operands" for other errors. * eval.c (eval_init): Registered = intrinsic function. * lib.c (numeqv): New function. * lib.h (numeq, numeqv): Declared. * txr.1: Documented expt, sqrt, isqrt, exptmod, fixnump, bignump, integerp, floatp, numberp, zerop, evenp, oddp, >, <, >=, <= and =. * txr.vim: Highlight =
* * arith.c (gcd): Allow zeros. Don't issue "non-integral"Kaz Kylheku2012-03-296-3/+141
| | | | | | | | | | | | | | | exception if MPI fails. (floorf, ceili): Map integer argument to itself. (tang, asine, acosi): New functions. * eval.c (eval_init): New intrinsics: tan, asin, acos. * lib.h (tang, asine, acosi): Declared. * txr.1: Documented gcd, abs, floor, ceil, sin, cos, tan asin, acos, atan, log, and exp. * txr.vim: Highlighting for tang, asine, acosi.
* * arith.c (dmod): New static function.Kaz Kylheku2012-03-293-7/+57
| | | | | | | | (mod): Use dmod instead of fmod directly, to calculate the correct semantics for combinations of negative operands in the floating point domain also. * txr.1: Documented /, trunc and mod.
* * txr.1: Documented +, - and *.Kaz Kylheku2012-03-292-1/+73
|
* * txr.1: num-str added to doc stub.Kaz Kylheku2012-03-293-2/+8
| | | | * txr.vim: num-str added.
* * lib.c (obj_print, obj_pprint): Do not use the #<lazy-string ..>Kaz Kylheku2012-03-282-2/+15
| | | | notation for lazy strings that have been forced.
* * stream.c (vformat): Compensate for differences in printfKaz Kylheku2012-03-273-6/+58
| | | | | | | implementations with regard to printing floating point exponents. by deleting any plus sign and leading zeros after the 'e'. * tests/009/json.expected: Regenerated.
* Filtering on lists and nested lists is hereby made to work.Kaz Kylheku2012-03-264-21/+48
| | | | | | | | | | | | | | | | | | For instance given @(bind a ("a" "b" "c")) it is now possible to do @(filter :upcase a) whereby a promptly takes on the value ("A" "B" "C"). * filter.c (string_filter): Function renamed to string_tree_filter. (compound_filter): Follows rename. (filter_string): Function renamed to filter string tree. Can filter tree of strings, or possibly other objects, if the filter function allows. (filter_equal): No special case test for objects that are strings. Just put them through the filter. * filter.h (filter_string): Declaration updated. * match.c (format_field, subst_vars, v_filter): Follow rename.
* * match.c (v_output): Bugfix: we should flush the streamKaz Kylheku2012-03-262-0/+10
| | | | | | | after each @(output) block. Otherwise if output blocks that go to standard output are interleaved with output blocks which pipe to some command which then goes to standard out, the output won't be in the proper order.
* * eval.c (eval_init): New intrinsic num-str registered.Kaz Kylheku2012-03-267-5/+71
| | | | | | | | | | | | | | | * filter.c (tonumber_k, tointeger_k, tofloat_k, hextoint_k): New keyword variables. (filter_init): New variables initialized; new filters registered. * filter.h (tonumber_k, tointeger_k, tofloat_k, hextoint_k): Declared. * lib.c (num_str): New function. * lib.h (num_str): Declared. * txr.1: New filters documented.
* * arith.c (to_float): Fix unterminated argument list in throwf.Kaz Kylheku2012-03-263-2/+8
| | | | * lib.c (funcall): Likewise.
* * lib.c (rebind_s): New symbol variable.Kaz Kylheku2012-03-245-5/+69
| | | | | | | | | | * lib.h (rebind_s): Declared. * match.c (v_rebind): New static function. (dir_tables_init): Registered rebind_s to v_rebind, and also to hv_trampoline in the horizontal directive table. * txr.1: Documented it.
* Bug #35989Kaz Kylheku2012-03-242-1/+8
| | | | | * match.c (syms_init): text_s must be in the system package because it's not a user-visible operator.
* Performance improvement in the GC: keep at least one heap's worthKaz Kylheku2012-03-242-4/+23
| | | | | | | | | | | | | of free space, so programs close to exhausting a heap do not waste cycles frequently calling the collector. * gc.c (more): Do not assert that free_list is null; this will not be the case any more. (make_obj): Comment added regarding why we the free_tail variable is fixed up. (sweep): Now returns a count of the objects that are free. (gc): If sweep reports that less than 75% of the objects are free then let us add another heap.
* * eval.c (eval_init): Register match-str and match-str-treeKaz Kylheku2012-03-245-0/+24
| | | | | | | | | | intrinsics. * lib.c (match_str, match_str_tree): Default position to zero. * txr.1: Doc stubs created. * txr.vim: Highlighting for match-str and match-str-tree.
* Bugfix: code like @(skip)@{var /partial/} whereKaz Kylheku2012-03-242-11/+34
| | | | | | | | | | | | | | | | the regular expression does not match all the way to the end of the line was getting by the check for a complete match. * match.c (do_match_line): Loses the second parameter named completely. The check whether the line was matched completely is done higher up, in match_line_completely. This is needed because do_match_line has some early successful return cases which bypass the check. (match_line): Remove second paramter in call to do_match_line. (match_line_completely): Do the check here that the line was matched completely. Nothing can get by this. (v_freeform): Do notpass second nil argument to do_match_line.
* * lib.c (search_str): If start_num is nil, default it to zero.Kaz Kylheku2012-03-242-0/+9
| | | | This is needed for this to work right as an optional argument.
* Version 62txr-62Kaz Kylheku2012-03-234-4/+14
| | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped.
* * RELNOTES: Updated.Kaz Kylheku2012-03-233-2/+90
| | | | * txr.1: Describe floating-point constants.
* * Makefile (TXR_ARGS): Pass new file to tests/009/json.txr test.Kaz Kylheku2012-03-235-18/+130
| | | | | | | | | | * tests/009/json.expected: Updated. * tests/009/json.txr: Updated source. Translates to a more native representation with vectors and hash tables. Numbers go to floating point instead of remaining as strings. * tests/009/pass1.json: New file: a test case from json.org.
* Merge branch 'float-support'Kaz Kylheku2012-03-2216-424/+1322
|\ | | | | | | | | Conflicts: ChangeLog
| * * arith.c (expo): New function.Kaz Kylheku2012-03-226-2/+21
| | | | | | | | | | | | | | | | | | | | * eval.c (eval_init): expo registered as intrinsic exp. * lib.h (expo): Declared. * txr.1: Added to stub heading. * txr.vim: Highlighting for exp.
| * * eval.c (transform_op): use integerp instead of numberp.Kaz Kylheku2012-03-222-1/+7
| | | | | | | | | | Not all numbers are integers now, and that situation requires an integer.
| * * parser.l: Bugfix: was not allowing e-notation floatsKaz Kylheku2012-03-223-21/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with no decimal point like 1E1. * stream.c: (vformat): Keep track of whether or not precision was given in precision_p local variable. When printing #<bad-float> pass a precision of 0 to vformat_str, not precision, since precision does not apply. In ~f and ~e, if the precision was not given, default it to 3. Restructured float printing in ~a and ~s. It now just uses sprintf's %g with a precision. If user does not specify precision, it defaults to DBL_DIG to print the number with reasonable accuracy. A .0 is added if it sprintf produces an integer, and the conversion is ~s rather than ~a.
| * Fix sqrt confusion. There must be a separate isqrtKaz Kylheku2012-03-226-16/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for the integer square root. * arith.c (sqroot_fixnum): Renamed back to isqrt_fixnum. (sqroot): Rewritten to handle only floating-point square root. (isqrt): New function, based on previous sqroot, handles only integers. * eval.c (eval_init): New intrinsic, isqrt. * lib.h (isqrt): New declaration. * txr.1: Doc stubs. * txr.vim: Highlighting for isqrt.
| * * arith.c (floorf, ceili, sine, cosi, atang, loga): New functions.Kaz Kylheku2012-03-226-2/+60
| | | | | | | | | | | | | | | | | | | | | | * eval.c (eval_init): New intrinsic functions registered: floor, ceil, sin, cons, atan, log. * lib.h (floorf, ceili, sine, cosi, atang, loga): Declared. * txr.1: Doc stub section for new functions. * txr.vim: Highighting added.
| * * arith.c (int_flo): If sprintf produces somethingKaz Kylheku2012-03-223-0/+29
| | | | | | | | | | | | | | | | that doesn't begin with a digit, it's most likely NaN or Inf. We can turn that into an exception. * stream.c (vformat): If sprintf produces a non-number, turn it into the printed representation #<bad-float>.
| * * arith.c (to_float): New static function.Kaz Kylheku2012-03-224-137/+197
| | | | | | | | | | | | | | | | | | | | | | | | | | (divi): Uses to_float. (zerop, gt, lt, ge, le, expt): Floating support. (isqrt_fixnum): Static function renamed to sqroot_fixnum. (isqrt): Renamed to sqroot. Floating support. (evenp, oddp, exptmod, gcd): Work with integers, not floats. * eval.c (eval_init): intrinsic registration of sqrt follows rename of isqrt to sqroot. * lib.h (isqrt): Declaration replaced.
| * * arith.c (divi): New function.Kaz Kylheku2012-03-216-2/+54
| | | | | | | | | | | | | | | | | | | | * eval.c (eval_init): divi registered as / intrinsic. * lib.h (divi): Declared. * txr.1: divi added to stub heading. * txr.vim: / operator highlighted.
| * * arith.c (mod): Floating support.Kaz Kylheku2012-03-212-82/+107
| |
| * * arith.c (trunc): Floating support.Kaz Kylheku2012-03-212-34/+77
| |
| * * arith.c (plus, minus, mul): Removing unnecessary type checks,Kaz Kylheku2012-03-212-7/+5
| | | | | | | | which are already implied by the switch case.
| * * txr.1: Doc stubs for new functions floatp, integerp,Kaz Kylheku2012-03-213-3/+14
| | | | | | | | | | | | float-str, int-flo and flo-int. * txr.vim: Highlighting for new functions.
| * * Makefile: link in -lm, which is needed now on some systems.Kaz Kylheku2012-03-213-57/+97
| | | | | | | | | | * arith.c (plus, minus): Eliminated some unnecessary (double) casts. (abso, mul): Floating support.
| * * arith.c (neg): Floating-point support.Kaz Kylheku2012-03-214-31/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | * parser.l: FLO and FLODOT cases had to be reordered because the lex trailing context counts as part of the match length, causing 3.0 to be matched as three characters with 0 as the trailing context. The cases are split up to eliminate a flex warning. * stream.c (vformat): Support bignum in floating point conversion. Bugfixes: floating point conversion was accessing obj->fl.n instead of using n. Changed some if/else ladders to switches.
| * * arith.c (plus): Minor code simplification.Kaz Kylheku2012-03-213-61/+87
| | | | | | | | | | | | | | | | (minus): Floating point support. * mpi-patches/mpi-to-double (mp_to_double): Re-apply lost bugfix: index incremented instead of decremented. Didn't refresh patch last time, then did a make distclean.
| * Regression fix: 1..3 scans incorrectly into 1. .3 tokens.Kaz Kylheku2012-03-202-3/+21
| | | | | | | | | | | | | | | | | | | | | | * parser.l (SGN, EXP, DIG): New regex definitions. (FLO): Do not recognize numbers of the form 123. Decimal point must be followed either by exponent, or digits (which may then be followed by an exponent). (FLODOT): New token type, recognizes 123. (grammar): Recognize FLODOT as a floating point number, only if it not trailed by another dot, and recognize FLO unconditionally.