diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-03-04 18:36:05 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-03-07 13:20:39 -0800 |
commit | 2e761e571f7b3d3df7ba7407a13b37c81ee4e9eb (patch) | |
tree | d00fe2a02847a9c78a8ed0504b44a4d9bff2d4b5 /src/asm2wasm.h | |
parent | 7ffdc335c7c899c282cb3d8216773dca1c26455b (diff) | |
download | binaryen-2e761e571f7b3d3df7ba7407a13b37c81ee4e9eb.tar.gz binaryen-2e761e571f7b3d3df7ba7407a13b37c81ee4e9eb.tar.bz2 binaryen-2e761e571f7b3d3df7ba7407a13b37c81ee4e9eb.zip |
add a finalize() method for blocks
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r-- | src/asm2wasm.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index c13c847e7..cb1998aa4 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -431,6 +431,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 +1155,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 +1238,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { block = allocator.alloc<Block>(); block->name = name; block->list.push_back(ret); + block->finalize(); ret = block; } } @@ -1279,6 +1281,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 +1316,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 +1380,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 +1394,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 +1411,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 +1516,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 |