summaryrefslogtreecommitdiff
path: root/src/wasm-s-parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm-s-parser.h')
-rw-r--r--src/wasm-s-parser.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index 677052984..0166d0726 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -491,6 +491,7 @@ public:
if (op[1] == 'u') return makeBinary(s, BinaryOp::Sub, type);
if (op[1] == 'q') return makeUnary(s, UnaryOp::Sqrt, type);
if (op[1] == 't') return makeStore(s, type);
+ if (op[1] == 'w') return makeSwitch(s, type);
abort_on(op);
}
case 't': {
@@ -930,6 +931,32 @@ private:
return ret;
}
+ Expression* makeSwitch(Element& s, WasmType type) {
+ abort();
+ auto ret = allocator.alloc<Switch>();
+ ret->type = type;
+ size_t i = 1;
+ if (s[i]->isStr()) {
+ ret->name = s[i]->str();
+ i++;
+ }
+ ret->value = parseExpression(s[i]);
+ i++;
+ Element& targets = *s[i];
+ i++;
+ for (size_t j = 0; j < targets.size(); j++) {
+ ret->targets.push_back(targets[i]->str());
+ }
+ Element& cases = *s[i];
+ i++;
+ for (size_t j = 0; j < cases.size(); j++) {
+ Element& curr = *cases[i];
+ ret->cases.emplace_back(curr[0]->str(), parseExpression(curr[1]));
+ }
+ ret->updateCaseMap();
+ return ret;
+ }
+
void parseMemory(Element& s) {
wasm.memory.initial = atoi(s[1]->c_str());
if (s.size() == 2) return;