summaryrefslogtreecommitdiff
path: root/src/emscripten-optimizer
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-04-26 11:07:42 -0700
committerGitHub <noreply@github.com>2019-04-26 11:07:42 -0700
commit34dd4c7893056e13cc9174db988d03e438a6af3d (patch)
tree43af249f532a9166c00b7013d67e2f63ac6ce63a /src/emscripten-optimizer
parent78a4f9ef1afd6c209a5c69a8e7906ffe33575f58 (diff)
downloadbinaryen-34dd4c7893056e13cc9174db988d03e438a6af3d.tar.gz
binaryen-34dd4c7893056e13cc9174db988d03e438a6af3d.tar.bz2
binaryen-34dd4c7893056e13cc9174db988d03e438a6af3d.zip
wasm2js: remove unneeded break/continue labels (#2058)
Diffstat (limited to 'src/emscripten-optimizer')
-rw-r--r--src/emscripten-optimizer/simple_ast.cpp61
-rw-r--r--src/emscripten-optimizer/simple_ast.h9
2 files changed, 4 insertions, 66 deletions
diff --git a/src/emscripten-optimizer/simple_ast.cpp b/src/emscripten-optimizer/simple_ast.cpp
index d6dc5e51a..7575cc6f7 100644
--- a/src/emscripten-optimizer/simple_ast.cpp
+++ b/src/emscripten-optimizer/simple_ast.cpp
@@ -183,65 +183,4 @@ void dump(const char *str, Ref node, bool pretty) {
std::cerr << std::endl;
}
-// Traversals
-
-struct TraverseInfo {
- TraverseInfo() = default;
- TraverseInfo(Ref node) : node(node) {
- assert(node.get());
- if (node->isArray()) {
- for (size_t i = 0; i < node->size(); i++) {
- maybeAdd(node[i]);
- }
- } else if (node->isAssign()) {
- auto assign = node->asAssign();
- maybeAdd(assign->target());
- maybeAdd(assign->value());
- } else if (node->isAssignName()) {
- auto assign = node->asAssignName();
- maybeAdd(assign->value());
- } else {
- // no children
- }
- }
- Ref node;
- size_t index = -1;
- std::vector<Ref> children;
-
-private:
- void maybeAdd(Ref child) {
- if (child.get()) {
- children.push_back(child);
- }
- }
-};
-
-// Traverse, calling visit after the children
-void traversePost(Ref node, std::function<void (Ref)> visit) {
- std::vector<TraverseInfo> stack;
- stack.push_back(TraverseInfo(node));
- while (!stack.empty()) {
- TraverseInfo& back = stack.back();
- if (back.index == size_t(-1)) {
- // This is the first time we see this. Push its children.
- back.index = 0;
- for (auto child : back.children) {
- stack.emplace_back(child);
- }
- continue;
- }
- if (back.index < back.children.size()) {
- // Visit this child.
- back.index++;
- visit(back.children[back.index - 1]);
- continue;
- }
- assert(back.index == back.children.size());
- // Time to visit the node itself
- auto node = back.node;
- stack.pop_back();
- visit(node);
- }
-}
-
} // namespace cashew
diff --git a/src/emscripten-optimizer/simple_ast.h b/src/emscripten-optimizer/simple_ast.h
index 30ef42711..81d20e612 100644
--- a/src/emscripten-optimizer/simple_ast.h
+++ b/src/emscripten-optimizer/simple_ast.h
@@ -394,6 +394,10 @@ struct Value {
return arr->size();
}
+ bool empty() {
+ return size() == 0;
+ }
+
void setSize(size_t size) {
assert(isArray());
auto old = arr->size();
@@ -525,11 +529,6 @@ struct AssignName : public Value {
}
};
-// AST traversals
-
-// Traverse, calling visit after the children
-void traversePost(Ref node, std::function<void (Ref)> visit);
-
// JS printing support
struct JSPrinter {