Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/ir/branch-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ void operateOnScopeNameUsesAndSentValues(Expression* expr, T func) {
func(name, sw->value);
} else if (auto* br = expr->dynCast<BrOn>()) {
func(name, br->ref);
} else if (auto* tt = expr->dynCast<TryTable>()) {
} else if (expr->is<TryTable>()) {
// The values are supplied by throwing instructions, so we are unable to
// know what they will be here.
func(name, nullptr);
} else if (auto* res = expr->dynCast<Resume>()) {
} else if (expr->is<Resume>()) {
// The values are supplied by suspend instructions executed while running
// the continuation, so we are unable to know what they will be here.
func(name, nullptr);
Expand Down Expand Up @@ -419,10 +419,14 @@ struct BranchTargets {

// Gets the expression that defines this branch target, i.e., where we branch
// to if we branch to that name.
Expression* getTarget(Name name) { return inner.targets[name]; }
Expression* getTarget(Name name) const {
auto iter = inner.targets.find(name);
assert(iter != inner.targets.end());
return iter->second;
}

// Gets the expressions branching to a target.
std::unordered_set<Expression*> getBranches(Name name) {
std::unordered_set<Expression*> getBranches(Name name) const {
auto iter = inner.branches.find(name);
if (iter != inner.branches.end()) {
return iter->second;
Expand Down
8 changes: 7 additions & 1 deletion src/ir/parents.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ namespace wasm {
struct Parents {
Parents(Expression* expr) { inner.walk(expr); }

Expression* getParent(Expression* curr) { return inner.parentMap[curr]; }
Expression* getParent(Expression* curr) const {
auto iter = inner.parentMap.find(curr);
if (iter != inner.parentMap.end()) {
return iter->second;
}
return nullptr;
}

private:
struct Inner
Expand Down
Loading