summaryrefslogtreecommitdiff
path: root/src/ast/branch-utils.h
diff options
context:
space:
mode:
authorAlon Zakai (kripken) <alonzakai@gmail.com>2017-07-11 10:43:20 -0700
committerAlon Zakai (kripken) <alonzakai@gmail.com>2017-07-11 11:07:40 -0700
commit51f26947d7fe801224115abdd601d738eea8ee8d (patch)
tree825475b1e6a5cbc90a46b03d40e52b37f6466863 /src/ast/branch-utils.h
parent18e096c4940f51df50d5f7a4e9fff03cc2f3beaf (diff)
downloadbinaryen-51f26947d7fe801224115abdd601d738eea8ee8d.tar.gz
binaryen-51f26947d7fe801224115abdd601d738eea8ee8d.tar.bz2
binaryen-51f26947d7fe801224115abdd601d738eea8ee8d.zip
refactor and improve break validation. breaks names are unique, so we don't need a stack, and break targets must exist even if they are not actually taken
Diffstat (limited to 'src/ast/branch-utils.h')
-rw-r--r--src/ast/branch-utils.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ast/branch-utils.h b/src/ast/branch-utils.h
index bdf52d36a..853b998af 100644
--- a/src/ast/branch-utils.h
+++ b/src/ast/branch-utils.h
@@ -37,6 +37,15 @@ inline bool isBranchTaken(Switch* sw) {
sw->condition->type != unreachable;
}
+inline bool isBranchTaken(Expression* expr) {
+ if (auto* br = expr->dynCast<Break>()) {
+ return isBranchTaken(br);
+ } else if (auto* sw = expr->dynCast<Switch>()) {
+ return isBranchTaken(sw);
+ }
+ WASM_UNREACHABLE();
+}
+
// returns the set of targets to which we branch that are
// outside of a node
inline std::set<Name> getExitingBranches(Expression* ast) {