diff options
Diffstat (limited to 'src/ast_utils.h')
-rw-r--r-- | src/ast_utils.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/ast_utils.h b/src/ast_utils.h index 8952114bc..3d4d57b77 100644 --- a/src/ast_utils.h +++ b/src/ast_utils.h @@ -242,7 +242,8 @@ struct ExpressionAnalyzer { return func->result != none; } - static bool equal(Expression* left, Expression* right) { + template<typename T> + static bool flexibleEqual(Expression* left, Expression* right, T& comparer) { std::vector<Name> nameStack; std::map<Name, std::vector<Name>> rightNames; // for each name on the left, the stack of names on the right (a stack, since names are scoped and can nest duplicatively Nop popNameMarker; @@ -284,6 +285,8 @@ struct ExpressionAnalyzer { popName(); continue; } + if (comparer.compare(left, right)) continue; // comparison hook, before all the rest + // continue with normal structural comparison if (left->_id != right->_id) return false; #define PUSH(clazz, what) \ leftStack.push_back(left->cast<clazz>()->what); \ @@ -426,6 +429,15 @@ struct ExpressionAnalyzer { return true; } + static bool equal(Expression* left, Expression* right) { + struct Comparer { + bool compare(Expression* left, Expression* right) { + return false; + } + } comparer; + return flexibleEqual(left, right, comparer); + } + // hash an expression, ignoring superficial details like specific internal names static uint32_t hash(Expression* curr) { uint32_t digest = 0; |