diff options
Diffstat (limited to 'src/wasm-builder.h')
-rw-r--r-- | src/wasm-builder.h | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/src/wasm-builder.h b/src/wasm-builder.h index 923effb76..a0a43bc07 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -453,7 +453,6 @@ public: return ret; } Const* makeConst(Literal value) { - assert(isConcreteType(value.type)); auto* ret = allocator.alloc<Const>(); ret->value = value; ret->type = value.type; @@ -497,6 +496,53 @@ public: ret->finalize(); return ret; } + Try* makeTry(Expression* body, Expression* catchBody) { + auto* ret = allocator.alloc<Try>(); + ret->body = body; + ret->catchBody = catchBody; + ret->finalize(); + return ret; + } + Try* makeTry(Expression* body, Expression* catchBody, Type type) { + auto* ret = allocator.alloc<Try>(); + ret->body = body; + ret->catchBody = catchBody; + ret->finalize(type); + return ret; + } + Throw* makeThrow(Event* event, const std::vector<Expression*>& args) { + return makeThrow(event->name, args); + } + Throw* makeThrow(Name event, const std::vector<Expression*>& args) { + auto* ret = allocator.alloc<Throw>(); + ret->event = event; + ret->operands.set(args); + ret->finalize(); + return ret; + } + Rethrow* makeRethrow(Expression* exnref) { + auto* ret = allocator.alloc<Rethrow>(); + ret->exnref = exnref; + ret->finalize(); + return ret; + } + BrOnExn* makeBrOnExn(Name name, Event* event, Expression* exnref) { + return makeBrOnExn(name, event->name, exnref, event->params); + } + BrOnExn* makeBrOnExn(Name name, + Name event, + Expression* exnref, + std::vector<Type>& eventParams) { + auto* ret = allocator.alloc<BrOnExn>(); + ret->name = name; + ret->event = event; + ret->exnref = exnref; + // Copy params info into BrOnExn, because it is necessary when BrOnExn is + // refinalized without the module. + ret->eventParams = eventParams; + ret->finalize(); + return ret; + } Unreachable* makeUnreachable() { return allocator.alloc<Unreachable>(); } Push* makePush(Expression* value) { auto* ret = allocator.alloc<Push>(); |