diff options
Diffstat (limited to 'src/wasm/wasm-ir-builder.cpp')
-rw-r--r-- | src/wasm/wasm-ir-builder.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/wasm/wasm-ir-builder.cpp b/src/wasm/wasm-ir-builder.cpp index 4bc80d25c..99462e9a8 100644 --- a/src/wasm/wasm-ir-builder.cpp +++ b/src/wasm/wasm-ir-builder.cpp @@ -658,6 +658,19 @@ Result<> IRBuilder::visitResume(Resume* curr) { return Ok{}; } +Result<> IRBuilder::visitSuspend(Suspend* curr) { + auto tag = wasm.getTag(curr->tag); + auto sig = tag->sig; + auto size = sig.params.size(); + curr->operands.resize(size); + for (size_t i = 0; i < size; ++i) { + auto val = pop(); + CHECK_ERR(val); + curr->operands[size - i - 1] = *val; + } + return Ok{}; +} + Result<> IRBuilder::visitTupleMake(TupleMake* curr) { assert(curr->operands.size() >= 2); for (size_t i = 0, size = curr->operands.size(); i < size; ++i) { @@ -1930,4 +1943,14 @@ Result<> IRBuilder::makeResume(HeapType ct, return Ok{}; } +Result<> IRBuilder::makeSuspend(Name tag) { + Suspend curr(wasm.allocator); + curr.tag = tag; + CHECK_ERR(visitSuspend(&curr)); + + std::vector<Expression*> operands(curr.operands.begin(), curr.operands.end()); + push(builder.makeSuspend(tag, operands)); + return Ok{}; +} + } // namespace wasm |