diff options
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 6d40034fc..beae693d9 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -22,6 +22,7 @@ #include <wasm-printing.h> #include <pass.h> #include <pretty_printing.h> +#include <ast/module-utils.h> namespace wasm { @@ -47,6 +48,8 @@ struct PrintSExpression : public Visitor<PrintSExpression> { Function* currFunction = nullptr; Function::DebugLocation lastPrintedLocation; + std::unordered_map<Name, Index> functionIndexes; + PrintSExpression(std::ostream& o) : o(o) { setMinify(false); if (!full) full = isFullForced(); @@ -686,6 +689,14 @@ struct PrintSExpression : public Visitor<PrintSExpression> { lastPrintedLocation = { 0, 0, 0 }; printOpening(o, "func ", true); printName(curr->name); + if (currModule && !minify) { + // emit the function index in a comment + if (functionIndexes.empty()) { + ModuleUtils::BinaryIndexes indexes(*currModule); + functionIndexes = std::move(indexes.functionIndexes); + } + o << " (; " << functionIndexes[curr->name] << " ;)"; + } if (curr->type.is()) { o << maybeSpace << "(type " << curr->type << ')'; } |