From 2876e0ac4ecf21f26a3e5b42ac9e9a6f61db1062 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 21 Jul 2017 19:16:54 -0400 Subject: Represent never returning as always_true && always_false Expressions that never return are vacuously always both true and false. Using this representation lets us take advantage of existing truth-based optimizations, which gets us optimizations of command lines like bfs -name foo -quit -print for free. --- eval.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'eval.c') diff --git a/eval.c b/eval.c index 1d2da7c..e6664a6 100644 --- a/eval.c +++ b/eval.c @@ -911,9 +911,12 @@ static bool eval_expr(struct expr *expr, struct eval_state *state) { ++expr->successes; } - assert(!expr->always_true || ret); - assert(!expr->always_false || !ret); - assert(!expr->never_returns || *state->quit); + if (expr_never_returns(expr)) { + assert(*state->quit); + } else if (!*state->quit) { + assert(!expr->always_true || ret); + assert(!expr->always_false || !ret); + } return ret; } -- cgit v1.2.3