diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2017-07-21 19:16:54 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2017-07-21 19:30:26 -0400 |
commit | 2876e0ac4ecf21f26a3e5b42ac9e9a6f61db1062 (patch) | |
tree | 1e4b483c77fd5e31d5b9c66804d16d4dc5cdf628 /eval.c | |
parent | 462589f69859354a9c623cad9015821e769beecb (diff) | |
download | bfs-2876e0ac4ecf21f26a3e5b42ac9e9a6f61db1062.tar.xz |
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.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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; } |