summaryrefslogtreecommitdiff
path: root/src/ir/ExpressionAnalyzer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir/ExpressionAnalyzer.cpp')
-rw-r--r--src/ir/ExpressionAnalyzer.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/ir/ExpressionAnalyzer.cpp b/src/ir/ExpressionAnalyzer.cpp
index a4b1efde1..acd446acc 100644
--- a/src/ir/ExpressionAnalyzer.cpp
+++ b/src/ir/ExpressionAnalyzer.cpp
@@ -262,7 +262,10 @@ struct Hasher {
std::map<Name, Index> internalNames;
ExpressionStack stack;
- Hasher(Expression* curr, bool visitChildren) : visitChildren(visitChildren) {
+ Hasher(Expression* curr,
+ bool visitChildren,
+ ExpressionAnalyzer::ExprHasher custom)
+ : visitChildren(visitChildren) {
stack.push_back(curr);
// DELEGATE_CALLER_TARGET is a fake target used to denote delegating to
// the caller. Add it here to prevent the unknown name error.
@@ -287,7 +290,11 @@ struct Hasher {
// call_imports type, etc. The simplest thing is just to hash the
// type for all of them.
rehash(digest, curr->type.getID());
- // Hash the contents of the expression.
+ // If the custom hasher handled this expr, then we have nothing to do.
+ if (custom(curr, digest)) {
+ continue;
+ }
+ // Hash the contents of the expression normally.
hashExpression(curr);
}
}
@@ -365,12 +372,13 @@ struct Hasher {
} // anonymous namespace
-size_t ExpressionAnalyzer::hash(Expression* curr) {
- return Hasher(curr, true).digest;
+size_t ExpressionAnalyzer::flexibleHash(Expression* curr,
+ ExpressionAnalyzer::ExprHasher custom) {
+ return Hasher(curr, true, custom).digest;
}
size_t ExpressionAnalyzer::shallowHash(Expression* curr) {
- return Hasher(curr, false).digest;
+ return Hasher(curr, false, ExpressionAnalyzer::nothingHasher).digest;
}
} // namespace wasm