From 48823c099b0418b975c9a7c0c3ea042cd5077a94 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 24 Nov 2015 22:08:56 -0800 Subject: wasm2asm progress --- src/wasm2asm.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/wasm2asm.h b/src/wasm2asm.h index ff99add1a..09f492686 100644 --- a/src/wasm2asm.h +++ b/src/wasm2asm.h @@ -21,9 +21,6 @@ IString ASM_FUNC("asmFunc"); class Wasm2AsmBuilder { MixedArena& allocator; - // How many temp vars we need - int i32s = 0, f32s = 0, f64s = 0; - public: Asm2WasmBuilder(MixedArena& allocator) : allocator(allocator) {} @@ -65,6 +62,11 @@ public: } private: + // How many temp vars we need + int i32s = 0, f32s = 0, f64s = 0; + // Which are currently free to use + std::vector i32sFree, f32sFree, f64sFree; + std::vector breakStack; std::vector continueStack; }; @@ -94,6 +96,9 @@ Ref Wasm2AsmBuilder::processFunction(Function* func) { // locals, including new temp locals XXX // checks assert(breakStack.empty() && continueStack.empty()); + assert(i32sFree.size() == i32s); // all temp vars should be free at the end + assert(f32sFree.size() == f32s); + assert(f64sFree.size() == f64s); return ret; } @@ -229,8 +234,22 @@ Ref Wasm2AsmBuilder::processExpression(Expression* curr) { return condition; } void visitSwitch(Switch *curr) override { + abort(); } void visitCall(Call *curr) override { + std::vector operands; + bool hasStatement = false; + for (auto operand : curr->operands) { + Ref temp = processTypedExpression(curr->value); + temp = temp || isStatement(temp) + operands.push_back(temp); + } + // if any is statement, we must statementize them all + if (hasStatement) { + for (auto& operand : operands) { + operand = blockifyWithTemp(// XXX); + } + } } void visitCallImport(CallImport *curr) override { } -- cgit v1.2.3