summaryrefslogtreecommitdiff
path: root/src/wasm-s-parser.h
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@chromium.org>2016-10-03 21:41:43 -0700
committerGitHub <noreply@github.com>2016-10-03 21:41:43 -0700
commitc4e70a04c42cdad380707d2e4b4f6f9503462414 (patch)
tree5c221b431b75e1729689a47857153756bc9e5c08 /src/wasm-s-parser.h
parent5046a524d506add48cb3779b39b4983e78292410 (diff)
downloadbinaryen-c4e70a04c42cdad380707d2e4b4f6f9503462414.tar.gz
binaryen-c4e70a04c42cdad380707d2e4b4f6f9503462414.tar.bz2
binaryen-c4e70a04c42cdad380707d2e4b4f6f9503462414.zip
More binary updates for 0xc (#733)
Refine tables to explicitly exist or not. Previously they were printed or encoded if it had any segments, or an initial or max size. However tables can be defined but empty, so we had a special hack that defined an empty segment when we really just wanted an empty table. Now, just make the existence explicit. Update Function table encoding for 0xc (Table and Element sections) Add end opcodes after function bodies (these are consumed by getMaybeBlock with the same behavior that it had before when it reached the function end, so no explicit decode) Update call_indirect encoding for 0xc (no arity, call target is last)
Diffstat (limited to 'src/wasm-s-parser.h')
-rw-r--r--src/wasm-s-parser.h13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index 90f5a2ea3..72949eb2b 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -1346,7 +1346,7 @@ private:
}
Expression* makeCallIndirect(Element& s) {
- if (!seenTable) throw ParseException("no table");
+ if (!wasm.table.exists) throw ParseException("no table");
auto ret = allocator.alloc<CallIndirect>();
IString type = s[1]->str();
auto* fullType = wasm.checkFunctionType(type);
@@ -1609,8 +1609,8 @@ private:
hasMemory = true;
} else if ((*s[3])[0]->str() == TABLE) {
im->kind = ExternalKind::Table;
- if (seenTable) throw ParseException("more than one table");
- seenTable = true;
+ if (wasm.table.exists) throw ParseException("more than one table");
+ wasm.table.exists = true;
} else if ((*s[3])[0]->str() == GLOBAL) {
im->kind = ExternalKind::Global;
} else {
@@ -1781,11 +1781,10 @@ private:
wasm.addGlobal(global.release());
}
- bool seenTable = false;
void parseTable(Element& s, bool preParseImport = false) {
- if (seenTable) throw ParseException("more than one table");
- seenTable = true;
+ if (wasm.table.exists) throw ParseException("more than one table");
+ wasm.table.exists = true;
Index i = 1;
if (i == s.size()) return; // empty table in old notation
if (s[i]->dollared()) {
@@ -1855,7 +1854,7 @@ private:
}
void parseInnerElem(Element& s, Index i = 1, Expression* offset = nullptr) {
- if (!seenTable) throw ParseException("elem without table", s.line, s.col);
+ if (!wasm.table.exists) throw ParseException("elem without table", s.line, s.col);
if (!offset) {
offset = allocator.alloc<Const>()->set(Literal(int32_t(0)));
}