diff options
author | Derek Schuff <dschuff@chromium.org> | 2016-10-11 09:15:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-11 09:15:05 -0700 |
commit | 56c6ca407f3232ede398b78e7f284f6ed80c9f00 (patch) | |
tree | 8ecc9eac4788d085a798678cba81ef0a5c11dbe7 /src/wasm-s-parser.h | |
parent | 2a8fea01444dac7d95eea64c2d49b86bb58713d3 (diff) | |
download | binaryen-56c6ca407f3232ede398b78e7f284f6ed80c9f00.tar.gz binaryen-56c6ca407f3232ede398b78e7f284f6ed80c9f00.tar.bz2 binaryen-56c6ca407f3232ede398b78e7f284f6ed80c9f00.zip |
Don't create table sections for imported tables (#756)
Previously the Print pass searched the imports for a table import and skipped printing a local table declaration if found. Instead this refactors to make importation explicit, and also create importation records (previously we were inconsistent about whether such records were created in the IR depending on the wast syntax).
Diffstat (limited to 'src/wasm-s-parser.h')
-rw-r--r-- | src/wasm-s-parser.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 7f5afe8f7..3e09d4f6f 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -1591,6 +1591,7 @@ private: im->kind = ExternalKind::Table; if (wasm.table.exists) throw ParseException("more than one table"); wasm.table.exists = true; + wasm.table.imported = true; } else if ((*s[3])[0]->str() == GLOBAL) { im->kind = ExternalKind::Global; } else { @@ -1765,6 +1766,7 @@ private: void parseTable(Element& s, bool preParseImport = false) { if (wasm.table.exists) throw ParseException("more than one table"); wasm.table.exists = true; + wasm.table.imported = preParseImport; Index i = 1; if (i == s.size()) return; // empty table in old notation if (s[i]->dollared()) { @@ -1785,6 +1787,13 @@ private: } else if (inner[0]->str() == IMPORT) { importModule = inner[1]->str(); importBase = inner[2]->str(); + assert(preParseImport); + auto im = make_unique<Import>(); + im->kind = ExternalKind::Table; + im->module = importModule; + im->base = importBase; + im->name = importModule;// + "." + importBase; + wasm.addImport(im.release()); i++; } else { WASM_UNREACHABLE(); |