diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-04-21 19:01:47 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-04-21 19:01:47 -0700 |
commit | a180c863ac4b6882f47e5e05ceeebe94b1208a7d (patch) | |
tree | d1e5591a6075f67359f792438f848cd15e834bc9 /src/wasm-builder.h | |
parent | 7b180b286a3df1a231454399869516ae8571d9bb (diff) | |
parent | 171668684ad91dc8d397ef411ce5fd337bc7a976 (diff) | |
download | binaryen-a180c863ac4b6882f47e5e05ceeebe94b1208a7d.tar.gz binaryen-a180c863ac4b6882f47e5e05ceeebe94b1208a7d.tar.bz2 binaryen-a180c863ac4b6882f47e5e05ceeebe94b1208a7d.zip |
Merge pull request #377 from WebAssembly/zero_x_b
More 0xb work
Diffstat (limited to 'src/wasm-builder.h')
-rw-r--r-- | src/wasm-builder.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/wasm-builder.h b/src/wasm-builder.h index 336a90e0d..6e342771b 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -65,7 +65,14 @@ public: } // Nop TODO: add all the rest - // Block + Block* makeBlock(Expression* first = nullptr) { + auto* ret = allocator.alloc<Block>(); + if (first) { + ret->list.push_back(first); + ret->finalize(); + } + return ret; + } If* makeIf(Expression* condition, Expression* ifTrue, Expression* ifFalse=nullptr) { auto* ret = allocator.alloc<If>(); ret->condition = condition; ret->ifTrue = ifTrue; ret->ifFalse = ifFalse; @@ -192,6 +199,12 @@ public: func->localNames.clear(); func->localIndices.clear(); } + + // ensure a node is a block, if it isn't already + Block* blockify(Expression* any) { + if (any->is<Block>()) return any->cast<Block>(); + return makeBlock(any); + } }; } // namespace wasm |