summaryrefslogtreecommitdiff
path: root/src/passes/Print.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-03-04 20:31:58 +0000
committerGitHub <noreply@github.com>2021-03-04 12:31:58 -0800
commit2bd5f60769506479316811da2b07913d0412abe0 (patch)
tree1477b7adda76385f219736946cf89c20307a289e /src/passes/Print.cpp
parentecd05546466494973fcc196a6661e0d5dfff6aa1 (diff)
downloadbinaryen-2bd5f60769506479316811da2b07913d0412abe0.tar.gz
binaryen-2bd5f60769506479316811da2b07913d0412abe0.tar.bz2
binaryen-2bd5f60769506479316811da2b07913d0412abe0.zip
Emit "elem declare" for functions that need it (#3653)
This adds support for reading (elem declare func $foo .. in the text and binary formats. We can simply ignore it: we don't need to represent it in IR, rather we find what needs to be declared when writing. That part takes a little more work, for which this adds a shared helper function.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r--src/passes/Print.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 0a25430cb..993eddb99 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -20,6 +20,7 @@
#include <ir/iteration.h>
#include <ir/module-utils.h>
+#include <ir/table-utils.h>
#include <pass.h>
#include <pretty_printing.h>
#include <wasm-stack.h>
@@ -2832,6 +2833,16 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
*curr, [&](Memory* memory) { visitMemory(memory); });
ModuleUtils::iterDefinedTables(*curr,
[&](Table* table) { visitTable(table); });
+ auto elemDeclareNames = TableUtils::getFunctionsNeedingElemDeclare(*curr);
+ if (!elemDeclareNames.empty()) {
+ doIndent(o, indent);
+ printMedium(o, "(elem");
+ o << " declare func";
+ for (auto name : elemDeclareNames) {
+ o << " $" << name;
+ }
+ o << ')' << maybeNewLine;
+ }
ModuleUtils::iterDefinedGlobals(
*curr, [&](Global* global) { visitGlobal(global); });
ModuleUtils::iterDefinedEvents(*curr,