summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-09-16 17:10:06 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-09-16 17:51:01 -0700
commitf0546a0c8322a4e2f1777c8a749207a70cdca681 (patch)
treec785a62550a278ca1dbd626e35504296a04484b8 /src
parent8ff678788ada565d15273ca6ca872946f14584d6 (diff)
downloadbinaryen-f0546a0c8322a4e2f1777c8a749207a70cdca681.tar.gz
binaryen-f0546a0c8322a4e2f1777c8a749207a70cdca681.tar.bz2
binaryen-f0546a0c8322a4e2f1777c8a749207a70cdca681.zip
block signatures
Diffstat (limited to 'src')
-rw-r--r--src/passes/Print.cpp3
-rw-r--r--src/wasm-s-parser.h31
2 files changed, 26 insertions, 8 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index e0fab9901..4cb363e66 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -109,6 +109,9 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
o << ' ';
printName(curr->name);
}
+ if (isConcreteWasmType(curr->type)) {
+ o << ' ' << printWasmType(curr->type);
+ }
incIndent();
if (curr->list.size() > 0 && curr->list[0]->is<Block>()) {
// recurse into the first element
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index 3f80f6f9e..a39eb59dc 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -991,13 +991,23 @@ private:
auto& s = *sp;
size_t i = 1;
if (i < s.size() && s[i]->isStr()) {
- curr->name = s[i]->str();
- i++;
+ // could be a name or a type
+ if (s[i]->dollared() || stringToWasmType(s[i]->str(), true /* allowError */) == none) {
+ curr->name = s[i]->str();
+ i++;
+ } else {
+ curr->name = getPrefixedName("block");
+ }
} else {
curr->name = getPrefixedName("block");
}
labelStack.push_back(curr->name);
- if (i >= s.size()) break; // labeled empty block
+ if (i >= s.size()) break; // empty block
+ if (s[i]->isStr()) {
+ // block signature
+ i++; // TODO: parse the signature
+ if (i >= s.size()) break; // empty block
+ }
auto& first = *s[i];
if (first[0]->str() == BLOCK) {
// recurse
@@ -1014,7 +1024,7 @@ private:
auto& s = *sp;
size_t i = 1;
if (i < s.size()) {
- if (s[i]->isStr()) {
+ while (i < s.size() && s[i]->isStr()) {
i++;
}
if (t < int(stack.size()) - 1) {
@@ -1132,7 +1142,12 @@ private:
Expression* makeIf(Element& s) {
auto ret = allocator.alloc<If>();
- ret->condition = parseExpression(s[1]);
+ Index i = 1;
+ if (s[i]->isStr()) {
+ // if type
+ i++;
+ }
+ ret->condition = parseExpression(s[i++]);
// ifTrue and ifFalse may get implicit blocks
auto handle = [&](const char* title, Element& s) {
@@ -1162,9 +1177,9 @@ private:
return ret;
};
- ret->ifTrue = handle("if-true", *s[2]);
- if (s.size() == 4) {
- ret->ifFalse = handle("if-else", *s[3]);
+ ret->ifTrue = handle("if-true", *s[i++]);
+ if (i < s.size()) {
+ ret->ifFalse = handle("if-else", *s[i++]);
ret->finalize();
}
return ret;