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. --- bfs.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'bfs.h') diff --git a/bfs.h b/bfs.h index 16ce475..79a383a 100644 --- a/bfs.h +++ b/bfs.h @@ -206,8 +206,6 @@ struct expr { bool always_true; /** Whether this expression always evaluates to false. */ bool always_false; - /** Whether this expression never returns. */ - bool never_returns; /** Number of times this predicate was executed. */ size_t evaluations; @@ -265,6 +263,11 @@ struct expr { const char *sdata; }; +/** + * @return Whether expr is known to always quit. + */ +bool expr_never_returns(const struct expr *expr); + /** * Parse the command line. */ -- cgit v1.2.3