diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-08-31 16:53:12 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-09-07 09:55:58 -0700 |
commit | e62f54d9d38e8f6b999d5f18f052424b7d603b6b (patch) | |
tree | 6e9af7b90a6563cfe15db6ab6325e8eb345a9e4c /src/passes/Print.cpp | |
parent | f1c74afc64d9f195729e1ad7e203f27566248e26 (diff) | |
download | binaryen-e62f54d9d38e8f6b999d5f18f052424b7d603b6b.tar.gz binaryen-e62f54d9d38e8f6b999d5f18f052424b7d603b6b.tar.bz2 binaryen-e62f54d9d38e8f6b999d5f18f052424b7d603b6b.zip |
new import syntax in spec repo
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 0071ede38..d25b64886 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -514,11 +514,9 @@ struct PrintSExpression : public Visitor<PrintSExpression> { printMinorOpening(o, "unreachable") << ')'; } // Module-level visitors - void visitFunctionType(FunctionType *curr, bool full=false) { - if (full) { - printOpening(o, "type") << ' '; - printName(curr->name) << " (func"; - } + void visitFunctionType(FunctionType *curr, Name* internalName = nullptr) { + o << "(func"; + if (internalName) o << ' ' << *internalName; if (curr->params.size() > 0) { o << maybeSpace; printMinorOpening(o, "param"); @@ -531,27 +529,17 @@ struct PrintSExpression : public Visitor<PrintSExpression> { o << maybeSpace; printMinorOpening(o, "result ") << printWasmType(curr->result) << ')'; } - if (full) { - o << "))"; - } + o << ")"; } void visitImport(Import *curr) { printOpening(o, "import "); - printName(curr->name) << ' '; - switch (curr->kind) { - case Export::Function: break; - case Export::Table: o << "table "; break; - case Export::Memory: o << "memory "; break; - case Export::Global: o << "global "; break; - default: WASM_UNREACHABLE(); - } printText(o, curr->module.str) << ' '; - printText(o, curr->base.str); + printText(o, curr->base.str) << ' '; switch (curr->kind) { - case Export::Function: if (curr->functionType) visitFunctionType(curr->functionType); break; - case Export::Table: break; - case Export::Memory: break; - case Export::Global: o << ' ' << printWasmType(curr->globalType); break; + case Export::Function: if (curr->functionType) visitFunctionType(curr->functionType, &curr->name); break; + case Export::Table: o << "(table " << curr->name << ")"; break; + case Export::Memory: o << "(memory " << curr->name << ")"; break; + case Export::Global: o << "(global " << curr->name << ' ' << printWasmType(curr->globalType) << ")"; break; default: WASM_UNREACHABLE(); } o << ')'; @@ -666,8 +654,10 @@ struct PrintSExpression : public Visitor<PrintSExpression> { } for (auto& child : curr->functionTypes) { doIndent(o, indent); - visitFunctionType(child.get(), true); - o << maybeNewLine; + printOpening(o, "type") << ' '; + printName(child->name) << ' '; + visitFunctionType(child.get()); + o << ")" << maybeNewLine; } for (auto& child : curr->imports) { doIndent(o, indent); |