diff options
Diffstat (limited to 'src/wasm-s-parser.h')
-rw-r--r-- | src/wasm-s-parser.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index fdf44a5a2..db70a69b7 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -348,12 +348,21 @@ private: switch (str[0]) { case 'b': { if (str[1] == 'l') return makeBlock(s); + if (str[1] == 'r') return makeBreak(s); abort_on(str); } case 'g': { if (str[1] == 'e') return makeGetLocal(s); abort_on(str); } + case 'i': { + if (str[1] == 'f') return makeIf(s); + abort_on(str); + } + case 'n': { + if (str[1] == 'o') return allocator.alloc<Nop>(); + abort_on(str); + } case 's': { if (str[1] == 'e') return makeSetLocal(s); abort_on(str); @@ -503,6 +512,25 @@ private: return ret; } + Expression* makeIf(Element& s) { + auto ret = allocator.alloc<If>(); + ret->condition = parseExpression(s[1]); + ret->ifTrue = parseExpression(s[2]); + if (s.size() == 4) { + ret->ifFalse = parseExpression(s[3]); + } + return ret; + } + + Expression* makeBreak(Element& s) { + auto ret = allocator.alloc<Break>(); + ret->name = s[1]->str(); + if (s.size() == 3) { + ret->value = parseExpression(s[2]); + } + return ret; + } + void parseMemory(Element& s) { wasm.memorySize = atoi(s[1]->c_str()); } |