summaryrefslogtreecommitdiff
path: root/src/asm2wasm.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-03-07 17:03:23 -0800
committerAlon Zakai <alonzakai@gmail.com>2016-03-07 17:03:23 -0800
commit8efa11fbb9ff8cfd8bacc9d16642e13e2bbac9b4 (patch)
tree22050fa4bbdfa87d367030d88f5af3c4f11eb7fd /src/asm2wasm.h
parentb65a994c24e83694f27cb835845b3b281207fc2f (diff)
parenta94f9938701920fe11c4f21a875ed3174ff7e9ba (diff)
downloadbinaryen-8efa11fbb9ff8cfd8bacc9d16642e13e2bbac9b4.tar.gz
binaryen-8efa11fbb9ff8cfd8bacc9d16642e13e2bbac9b4.tar.bz2
binaryen-8efa11fbb9ff8cfd8bacc9d16642e13e2bbac9b4.zip
Merge pull request #224 from WebAssembly/spec-updates
Spec updates
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r--src/asm2wasm.h23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index c13c847e7..be11344b2 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -28,6 +28,7 @@
#include "shared-constants.h"
#include "asm_v_wasm.h"
#include "pass.h"
+#include "ast_utils.h"
namespace wasm {
@@ -66,17 +67,6 @@ struct AstStackHelper {
std::vector<Ref> AstStackHelper::astStack;
-struct BreakSeeker : public WasmWalker<BreakSeeker> {
- IString target; // look for this one
- size_t found;
-
- BreakSeeker(IString target) : target(target), found(false) {}
-
- void visitBreak(Break *curr) {
- if (curr->name == target) found++;
- }
-};
-
//
// Asm2WasmPreProcessor - does some initial parsing/processing
// of asm.js code.
@@ -431,6 +421,7 @@ private:
if (expression->is<Block>()) return expression->dyn_cast<Block>();
auto ret = allocator.alloc<Block>();
ret->list.push_back(expression);
+ ret->finalize();
return ret;
}
@@ -1154,7 +1145,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
select->condition = isNegative;
select->type = i32;
block->list.push_back(select);
- block->type = i32;
+ block->finalize();
return block;
} else if (value->type == f32 || value->type == f64) {
auto ret = allocator.alloc<Unary>();
@@ -1237,6 +1228,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
block = allocator.alloc<Block>();
block->name = name;
block->list.push_back(ret);
+ block->finalize();
ret = block;
}
}
@@ -1279,6 +1271,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
auto body = allocator.alloc<Block>();
body->list.push_back(condition);
body->list.push_back(process(ast[2]));
+ body->finalize();
ret->body = body;
}
// loops do not automatically loop, add a branch back
@@ -1313,6 +1306,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
auto block = allocator.alloc<Block>();
block->list.push_back(child);
block->name = stop;
+ block->finalize();
return block;
} else {
auto loop = allocator.alloc<Loop>();
@@ -1376,6 +1370,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
body->list.push_back(condition);
body->list.push_back(process(fbody));
body->list.push_back(process(finc));
+ body->finalize();
ret->body = body;
// loops do not automatically loop, add a branch back
Block* block = blockify(ret->body);
@@ -1389,6 +1384,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
// add an outer block for the init as well
outer->list.push_back(process(finit));
outer->list.push_back(ret);
+ outer->finalize();
return outer;
} else if (what == LABEL) {
assert(parentLabel.isNull());
@@ -1405,7 +1401,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
auto ret = allocator.alloc<Block>();
ret->list.push_back(process(ast[1]));
ret->list.push_back(process(ast[2]));
- ret->type = ret->list[1]->type;
+ ret->finalize();
return ret;
} else if (what == SWITCH) {
IString name;
@@ -1510,6 +1506,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
for (unsigned i = from; i < ast->size(); i++) {
block->list.push_back(process(ast[i]));
}
+ block->finalize();
return block;
};
// body