diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-10-20 19:38:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-20 19:38:31 -0700 |
commit | 1005b1267f70a5a7cf7a8774af6c12d813464720 (patch) | |
tree | 04b27ca5a8fddcef4941681ec81d680c4351c74a /src/passes/Print.cpp | |
parent | 71dc0791361a79e4346eb84ebadf77a324767e32 (diff) | |
download | binaryen-1005b1267f70a5a7cf7a8774af6c12d813464720.tar.gz binaryen-1005b1267f70a5a7cf7a8774af6c12d813464720.tar.bz2 binaryen-1005b1267f70a5a7cf7a8774af6c12d813464720.zip |
Emit binary function index in comment in text format, for convenience (#1232)
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 << ')'; } |