summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-12-21 13:02:35 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-12-21 13:02:35 -0800
commitfab26d37f7e107596bd733d70d2330410eae24cf (patch)
treeb7aade7bb3747343483b49839bcf69c052f2c637 /src
parentc0dcfbc09887ed3bfaa978fc64d9293946ff7aad (diff)
downloadbinaryen-fab26d37f7e107596bd733d70d2330410eae24cf.tar.gz
binaryen-fab26d37f7e107596bd733d70d2330410eae24cf.tar.bz2
binaryen-fab26d37f7e107596bd733d70d2330410eae24cf.zip
parse imports early, as they may be at the end
Diffstat (limited to 'src')
-rw-r--r--src/wasm-s-parser.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index 6061dacc5..1a4b96be4 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -222,6 +222,7 @@ public:
functionCounter = 0;
for (unsigned i = 1; i < module.size(); i++) {
preParseFunctionType(*module[i]);
+ preParseImports(*module[i]);
}
functionCounter = 0;
for (unsigned i = 1; i < module.size(); i++) {
@@ -263,12 +264,17 @@ private:
functionTypes[name] = none;
}
+ void preParseImports(Element& curr) {
+ IString id = curr[0]->str();
+ if (id == IMPORT) parseImport(curr);
+ }
+
void parseModuleElement(Element& curr) {
IString id = curr[0]->str();
if (id == FUNC) return parseFunction(curr);
if (id == MEMORY) return parseMemory(curr);
if (id == EXPORT) return parseExport(curr);
- if (id == IMPORT) return parseImport(curr);
+ if (id == IMPORT) return; // already done
if (id == TABLE) return parseTable(curr);
if (id == TYPE) return; // already done
std::cerr << "bad module element " << id.str << '\n';