summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2019-07-24 13:15:37 -0700
committerGitHub <noreply@github.com>2019-07-24 13:15:37 -0700
commit407a0ad4adead4a44f8a4421187e840bb9e37d21 (patch)
treedf0f98521560883cdae5b8428b1c466f874592f4
parent62e2d1fa038ccf96bfd61a8a5864c7a9d5d45be6 (diff)
downloadbinaryen-407a0ad4adead4a44f8a4421187e840bb9e37d21.tar.gz
binaryen-407a0ad4adead4a44f8a4421187e840bb9e37d21.tar.bz2
binaryen-407a0ad4adead4a44f8a4421187e840bb9e37d21.zip
Print events in color (#2255)
This prints events in color like other module elements such as globals. This also splits `visitEvent` into two functions to be consistent with `visitGlobals` or `visitFunctions`.
-rw-r--r--src/passes/Print.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 1f14819cf..0c71afc7b 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -1837,11 +1837,16 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
o << maybeNewLine;
}
void visitEvent(Event* curr) {
- doIndent(o, indent);
if (curr->imported()) {
- o << '(';
- emitImportHeader(curr);
+ visitImportedEvent(curr);
+ } else {
+ visitDefinedEvent(curr);
}
+ }
+ void visitImportedEvent(Event* curr) {
+ doIndent(o, indent);
+ o << '(';
+ emitImportHeader(curr);
o << "(event ";
printName(curr->name, o);
o << maybeSpace << "(attr " << curr->attribute << ')' << maybeSpace << '(';
@@ -1849,12 +1854,21 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
for (auto& param : curr->params) {
o << ' ' << printType(param);
}
- o << "))";
- if (curr->imported()) {
- o << ')';
- }
+ o << ")))";
o << maybeNewLine;
}
+ void visitDefinedEvent(Event* curr) {
+ doIndent(o, indent);
+ o << '(';
+ printMedium(o, "event ");
+ printName(curr->name, o);
+ o << maybeSpace << "(attr " << curr->attribute << ')' << maybeSpace << '(';
+ printMinor(o, "param");
+ for (auto& param : curr->params) {
+ o << ' ' << printType(param);
+ }
+ o << "))" << maybeNewLine;
+ }
void printTableHeader(Table* curr) {
o << '(';
printMedium(o, "table") << ' ';