From 3d6cbdfd5e29a48da30493d98e9653d5eebbd9f5 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 30 Nov 2011 16:12:46 -0800 Subject: * lib.h (or2): Restore macro version of or2, because we need the sequencing! Making it an inline function broke the tests. But we can't have multiple evaluation either, so it's going to use a temporary lexical variable. (uses_or2): Macro which declares the lexical variable needed by or2. * debug.c (debug): add uses_or2. * eval.c (eval_intrinsic, op_modplace): Likewise. * lib.c (lazy_str, lazy_str_force_upto, lazy_str_get_trailing_list): Likewise. * match.c (h_parallel, v_freeform, v_parallel, v_output): Likewise. * parser.y (unquotes_occur): Likewise. * stream.c (format): Likewise. --- ChangeLog | 21 +++++++++++++++++++++ debug.c | 1 + eval.c | 2 ++ lib.c | 3 +++ lib.h | 4 +++- match.c | 4 ++++ parser.y | 2 ++ stream.c | 1 + 8 files changed, 37 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 160ab0b0..9c594728 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2011-11-30 Kaz Kylheku + + * lib.h (or2): Restore macro version of or2, because we need + the sequencing! Making it an inline function broke the tests. + But we can't have multiple evaluation either, so it's going to use + a temporary lexical variable. + (uses_or2): Macro which declares the lexical variable needed by or2. + + * debug.c (debug): add uses_or2. + + * eval.c (eval_intrinsic, op_modplace): Likewise. + + * lib.c (lazy_str, lazy_str_force_upto, lazy_str_get_trailing_list): + Likewise. + + * match.c (h_parallel, v_freeform, v_parallel, v_output): Likewise. + + * parser.y (unquotes_occur): Likewise. + + * stream.c (format): Likewise. + 2011-11-30 Kaz Kylheku Removing useless hash table. diff --git a/debug.c b/debug.c index 35e1e831..38a4b379 100644 --- a/debug.c +++ b/debug.c @@ -34,6 +34,7 @@ val debug(val form, val bindings, val data, val line, val chr) val print_data = t; for (;;) { + uses_or2; val input, command; if (print_form) { diff --git a/eval.c b/eval.c index c932c51b..3f6e7b74 100644 --- a/eval.c +++ b/eval.c @@ -281,6 +281,7 @@ val interp_fun(val env, val fun, val args) static val eval_intrinsic(val form, val env) { + uses_or2; expand(form); return eval(form, or2(env, make_env(nil, nil, env)), form); } @@ -507,6 +508,7 @@ static val op_defun(val form, val env) static val op_modplace(val form, val env) { + uses_or2; val op = first(form); val place = second(form); val third_arg_p = rest(rest(form)); diff --git a/lib.c b/lib.c index a605a556..1989e437 100644 --- a/lib.c +++ b/lib.c @@ -2300,6 +2300,7 @@ val lazy_stream_cons(val stream) val lazy_str(val lst, val term, val limit) { + uses_or2; val obj = make_obj(); obj->ls.type = LSTR; @@ -2344,6 +2345,7 @@ val lazy_str_force(val lstr) val lazy_str_force_upto(val lstr, val index) { + uses_or2; val lim; type_check(lstr, LSTR); lim = cdr(lstr->ls.opts); @@ -2460,6 +2462,7 @@ val lazy_str_get_trailing_list(val lstr, val index) lazy_str_force_upto(lstr, index); { + uses_or2; val split_suffix = split_str(sub_str(lstr->ls.prefix, index, nil), or2(car(lstr->ls.opts), string(L"\n"))); diff --git a/lib.h b/lib.h index 47cb414e..53268c78 100644 --- a/lib.h +++ b/lib.h @@ -507,7 +507,9 @@ INLINE val eq(val a, val b) { return ((a) == (b) ? t : nil); } #define if3(a, b, c) ((a) ? (b) : (c)) -INLINE val or2(val a, val b) { return a ? a : b; } +#define uses_or2 val or2_temp + +#define or2(a, b) ((or2_temp = (a)) ? or2_temp : (b)) #define or3(a, b, c) or2(a, or2(b, c)) diff --git a/match.c b/match.c index ad3d56cc..13122651 100644 --- a/match.c +++ b/match.c @@ -850,6 +850,7 @@ next_coll: static val h_parallel(match_line_ctx c, match_line_ctx *cout) { + uses_or2; elem_bind(elem, directive, c.specline); val specs = third(elem); val plist = fourth(elem); @@ -1806,6 +1807,7 @@ static val v_freeform(match_files_ctx *c) debuglf(specline, lit("freeform match failure: no data"), nao); return nil; } else { + uses_or2; val limit = or2(if2(nump(first(vals)), first(vals)), if2(nump(second(vals)), second(vals))); val term = or2(if2(stringp(first(vals)), first(vals)), @@ -2035,6 +2037,7 @@ static val v_parallel(match_files_ctx *c) if (second(first_spec) == t) { return decline_k; } else { + uses_or2; val sym = first(first_spec); val all_match = t; val some_match = nil; @@ -2641,6 +2644,7 @@ static val v_output(match_files_ctx *c) if (rest(dest_spec)) sem_error(specline, lit("material after :nothrow in output"), nao); } else if (!keywordp(first(dest_spec))) { + uses_or2; val form = first(dest_spec); val val = eval_form(specline, form, c->bindings); dest = or2(cdr(val), dest); diff --git a/parser.y b/parser.y index 6df6452e..affcd636 100644 --- a/parser.y +++ b/parser.y @@ -887,6 +887,8 @@ static val optimize_text(val text_form) static val unquotes_occur(val quoted_form) { + uses_or2; + if (atom(quoted_form)) { return nil; } else { diff --git a/stream.c b/stream.c index 395d9ab6..e337e523 100644 --- a/stream.c +++ b/stream.c @@ -1018,6 +1018,7 @@ val vformat_to_string(val fmtstr, va_list vl) val format(val stream, val str, ...) { + uses_or2; val st = if3(stream == t, std_output, or2(stream, make_string_output_stream())); -- cgit v1.2.3