diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-04 13:38:47 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-04 13:38:47 -0800 |
commit | af7374115dc89eda2365778ece51e71259b24745 (patch) | |
tree | 9c967e24c48aedcb084b0c2543f96729d7a2528a | |
parent | 2cf75357101099e9bb6c59ca2688ee244286686b (diff) | |
download | binaryen-af7374115dc89eda2365778ece51e71259b24745.tar.gz binaryen-af7374115dc89eda2365778ece51e71259b24745.tar.bz2 binaryen-af7374115dc89eda2365778ece51e71259b24745.zip |
parse loop
-rw-r--r-- | src/wasm-s-parser.h | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 9f9e98a1a..9c98975e6 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -40,7 +40,7 @@ public: Element() : isList_(true) {} bool isList() { return isList_; } - bool isString() { return !isList_; } + bool isStr() { return !isList_; } // list methods @@ -367,6 +367,10 @@ private: if (str[1] == 'f') return makeIf(s); abort_on(str); } + case 'l': { + if (str[1] == 'o') return makeLoop(s); + abort_on(str); + } case 'n': { if (str[1] == 'o') return allocator.alloc<Nop>(); abort_on(str); @@ -432,7 +436,7 @@ private: Expression* makeBlock(Element& s) { auto ret = allocator.alloc<Block>(); size_t i = 1; - if (s[1]->isString()) { + if (s[1]->isStr()) { ret->name = s[1]->str(); i++; } @@ -530,6 +534,21 @@ private: return ret; } + Expression* makeLoop(Element& s) { + auto ret = allocator.alloc<Loop>(); + size_t i = 1; + if (s[i]->isStr()) { + ret->out = s[i]->str(); + i++; + } + if (s[i]->isStr()) { + ret->in = s[i]->str(); + i++; + } + ret->body = parseExpression(s[i]); + return ret; + } + Expression* makeBreak(Element& s) { auto ret = allocator.alloc<Break>(); ret->name = s[1]->str(); |