diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-11-16 09:22:57 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-16 09:22:57 -0800 |
commit | dcdaa5de3b2c63a1349faacfe921527d972fc95c (patch) | |
tree | 74c88ccd054b2c419e0c76827e566b8d08f7d5b3 /src/wasm-builder.h | |
parent | 27474b7482ad2673ef3c9aca09aa443769e7447f (diff) | |
download | binaryen-dcdaa5de3b2c63a1349faacfe921527d972fc95c.tar.gz binaryen-dcdaa5de3b2c63a1349faacfe921527d972fc95c.tar.bz2 binaryen-dcdaa5de3b2c63a1349faacfe921527d972fc95c.zip |
Fix if copying (#1278)
* fix if copying - we should preserve the forced explicit type if there is one, and not just infer it from the arms. this adds a builder method for makeIf that receives a type to apply to the if, and for blocks a method that makes a block from a list, also with a variant with a provided type
Diffstat (limited to 'src/wasm-builder.h')
-rw-r--r-- | src/wasm-builder.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/wasm-builder.h b/src/wasm-builder.h index bc670bb8f..8ab4cfec9 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -90,12 +90,44 @@ public: ret->finalize(); return ret; } + Block* makeBlock(const ExpressionList& items) { + auto* ret = allocator.alloc<Block>(); + ret->list.set(items); + ret->finalize(); + return ret; + } + Block* makeBlock(const ExpressionList& items, WasmType type) { + auto* ret = allocator.alloc<Block>(); + ret->list.set(items); + ret->finalize(type); + return ret; + } + Block* makeBlock(Name name, const ExpressionList& items) { + auto* ret = allocator.alloc<Block>(); + ret->name = name; + ret->list.set(items); + ret->finalize(); + return ret; + } + Block* makeBlock(Name name, const ExpressionList& items, WasmType type) { + auto* ret = allocator.alloc<Block>(); + ret->name = name; + ret->list.set(items); + ret->finalize(type); + 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; ret->finalize(); return ret; } + If* makeIf(Expression* condition, Expression* ifTrue, Expression* ifFalse, WasmType type) { + auto* ret = allocator.alloc<If>(); + ret->condition = condition; ret->ifTrue = ifTrue; ret->ifFalse = ifFalse; + ret->finalize(type); + return ret; + } Loop* makeLoop(Name name, Expression* body) { auto* ret = allocator.alloc<Loop>(); ret->name = name; ret->body = body; |