summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-07-21 19:16:54 -0400
committerTavian Barnes <tavianator@tavianator.com>2017-07-21 19:30:26 -0400
commit2876e0ac4ecf21f26a3e5b42ac9e9a6f61db1062 (patch)
tree1e4b483c77fd5e31d5b9c66804d16d4dc5cdf628 /eval.c
parent462589f69859354a9c623cad9015821e769beecb (diff)
downloadbfs-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.c9
1 files changed, 6 insertions, 3 deletions
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;
}