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/passes/Print.cpp | |
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/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 0a2026f25..33b5f5d16 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -620,19 +620,12 @@ struct PrintSExpression : public Visitor<PrintSExpression> { } void visitTable(Table *curr) { // if table wasn't imported, declare it - bool found = false; - for (auto& import : currModule->imports) { - if (import->kind == ExternalKind::Table) { - found = true; - break; - } - } - if (!found) { + if (!curr->imported) { doIndent(o, indent); printTableHeader(curr); + o << maybeNewLine; } if (curr->segments.empty()) return; - if (!found) o << '\n'; doIndent(o, indent); for (auto& segment : curr->segments) { // Don't print empty segments @@ -645,6 +638,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> { } o << ')'; } + o << maybeNewLine; } void printMemoryHeader(Memory* curr) { printOpening(o, "memory") << ' '; @@ -712,8 +706,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> { o << maybeNewLine; } if (curr->table.exists) { - visitTable(&curr->table); - o << maybeNewLine; + visitTable(&curr->table); // Prints its own newlines } visitMemory(&curr->memory); for (auto& child : curr->globals) { |