Skip to content

Commit 407a0ad

Browse files
authored
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`.
1 parent 62e2d1f commit 407a0ad

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

src/passes/Print.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,24 +1837,38 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
18371837
o << maybeNewLine;
18381838
}
18391839
void visitEvent(Event* curr) {
1840-
doIndent(o, indent);
18411840
if (curr->imported()) {
1842-
o << '(';
1843-
emitImportHeader(curr);
1841+
visitImportedEvent(curr);
1842+
} else {
1843+
visitDefinedEvent(curr);
18441844
}
1845+
}
1846+
void visitImportedEvent(Event* curr) {
1847+
doIndent(o, indent);
1848+
o << '(';
1849+
emitImportHeader(curr);
18451850
o << "(event ";
18461851
printName(curr->name, o);
18471852
o << maybeSpace << "(attr " << curr->attribute << ')' << maybeSpace << '(';
18481853
printMinor(o, "param");
18491854
for (auto& param : curr->params) {
18501855
o << ' ' << printType(param);
18511856
}
1852-
o << "))";
1853-
if (curr->imported()) {
1854-
o << ')';
1855-
}
1857+
o << ")))";
18561858
o << maybeNewLine;
18571859
}
1860+
void visitDefinedEvent(Event* curr) {
1861+
doIndent(o, indent);
1862+
o << '(';
1863+
printMedium(o, "event ");
1864+
printName(curr->name, o);
1865+
o << maybeSpace << "(attr " << curr->attribute << ')' << maybeSpace << '(';
1866+
printMinor(o, "param");
1867+
for (auto& param : curr->params) {
1868+
o << ' ' << printType(param);
1869+
}
1870+
o << "))" << maybeNewLine;
1871+
}
18581872
void printTableHeader(Table* curr) {
18591873
o << '(';
18601874
printMedium(o, "table") << ' ';

0 commit comments

Comments
 (0)