diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-11-01 13:34:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-01 13:34:53 -0700 |
commit | 77c66027f0dcbd7160f78c5de4943372836ab142 (patch) | |
tree | 582c3f937247c14b773e9364d5a901d9db9bcfdd /src/passes/Print.cpp | |
parent | 7d3ddd09d5f68945160cda3f3749a217a13928bf (diff) | |
download | binaryen-77c66027f0dcbd7160f78c5de4943372836ab142.tar.gz binaryen-77c66027f0dcbd7160f78c5de4943372836ab142.tar.bz2 binaryen-77c66027f0dcbd7160f78c5de4943372836ab142.zip |
Emit imports before defined things in text format (#1715)
That is the correct order in the text format, wabt errors otherwise.
See AssemblyScript/assemblyscript#310
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 3ab1cc75d..3062ed0ee 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -957,6 +957,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> { void printTableHeader(Table* curr) { o << '('; printMedium(o, "table") << ' '; + printName(curr->name, o) << ' '; o << curr->initial; if (curr->hasMax()) o << ' ' << curr->max; o << " anyfunc)"; @@ -1056,16 +1057,24 @@ struct PrintSExpression : public Visitor<PrintSExpression> { visitFunctionType(child.get()); o << ")" << maybeNewLine; } - visitMemory(&curr->memory); - if (curr->table.exists) { - visitTable(&curr->table); // Prints its own newlines - } + ModuleUtils::iterImportedMemories(*curr, [&](Memory* memory) { + visitMemory(memory); + }); + ModuleUtils::iterImportedTables(*curr, [&](Table* table) { + visitTable(table); + }); ModuleUtils::iterImportedGlobals(*curr, [&](Global* global) { visitGlobal(global); }); ModuleUtils::iterImportedFunctions(*curr, [&](Function* func) { visitFunction(func); }); + ModuleUtils::iterDefinedMemories(*curr, [&](Memory* memory) { + visitMemory(memory); + }); + ModuleUtils::iterDefinedTables(*curr, [&](Table* table) { + visitTable(table); + }); ModuleUtils::iterDefinedGlobals(*curr, [&](Global* global) { visitGlobal(global); }); |