diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-08-18 18:03:05 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-09-07 09:55:02 -0700 |
commit | 9660c200eff60c10266a85aae0637b495c4cba39 (patch) | |
tree | 386e74bb16cca4c7d20939ab4786806a32e3b1b5 /src/passes/Print.cpp | |
parent | a10ca64dc04bdba4fbf4a468604c0c88f62a4a8d (diff) | |
download | binaryen-9660c200eff60c10266a85aae0637b495c4cba39.tar.gz binaryen-9660c200eff60c10266a85aae0637b495c4cba39.tar.bz2 binaryen-9660c200eff60c10266a85aae0637b495c4cba39.zip |
get_global and set_global use a Name instead of an Index, to be more consistent with refering to other global objects; e.g. this avoids ordering issues with imported vs non-imported globals
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 3e5339932..fcd155650 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -82,11 +82,6 @@ struct PrintSExpression : public Visitor<PrintSExpression> { return name; } - Name printableGlobal(Index index) { - if (currModule) return currModule->getGlobal(index)->name; - return Name::fromInt(index); - } - std::ostream& printName(Name name) { // we need to quote names if they have tricky chars if (strpbrk(name.str, "()")) { @@ -250,10 +245,12 @@ struct PrintSExpression : public Visitor<PrintSExpression> { decIndent(); } void visitGetGlobal(GetGlobal *curr) { - printOpening(o, "get_global ") << printableGlobal(curr->index) << ')'; + printOpening(o, "get_global "); + printName(curr->name) << ')'; } void visitSetGlobal(SetGlobal *curr) { - printOpening(o, "set_global ") << printableGlobal(curr->index); + printOpening(o, "set_global "); + printName(curr->name); incIndent(); printFullLine(curr->value); decIndent(); @@ -568,7 +565,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> { void visitGlobal(Global *curr) { printOpening(o, "global "); printName(curr->name) << ' ' << printWasmType(curr->type); - printFullLine(curr->init); + visit(curr->init); o << ')'; } void visitFunction(Function *curr) { |