From 9c6476efe9403658bb69851bfa3aa30f67a32868 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 9 Nov 2015 18:59:05 -0800 Subject: update spec tests, use a proper label stack, and start to update control flow changes from spec --- src/wasm-s-parser.h | 52 +++++++++++++++++++++++++++++++++------------------- src/wasm.h | 10 +++++----- 2 files changed, 38 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 672880fe0..f92aeed43 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -261,23 +261,15 @@ private: Function *currFunction = nullptr; std::map currLocalTypes; size_t localIndex; // params and locals - size_t labelIndex; size_t otherIndex; + std::vector labelStack; IString getName(size_t index) { return IString(std::to_string(index).c_str(), false); } - IString getPrefixedName(size_t index, std::string prefix) { - return IString((prefix + std::to_string(index)).c_str(), false); - } - - IString getNameWhenNextNotString(Element& s, size_t& i, size_t& index) { - if (s[i]->isStr()) { - index++; - return s[i++]->str(); - } - return getName(index++); + IString getPrefixedName(std::string prefix) { + return IString((prefix + std::to_string(otherIndex++)).c_str(), false); } void parseFunction(Element& s) { @@ -292,7 +284,6 @@ private: } func->body = nullptr; localIndex = 0; - labelIndex = 0; otherIndex = 0; std::vector typeParams; // we may have both params and a type. store the type info here for (;i < s.size(); i++) { @@ -359,6 +350,7 @@ private: if (!func->body) func->body = allocator.alloc(); wasm.addFunction(func); currLocalTypes.clear(); + labelStack.clear(); currFunction = nullptr; } @@ -902,8 +894,15 @@ private: Expression* makeLabel(Element& s) { auto ret = allocator.alloc