Skip to content

Commit 58e0722

Browse files
committed
Added the following expression cases
- TernaryExpr - IsExpr
1 parent 8ac71b1 commit 58e0722

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4635,7 +4635,9 @@ void PrintAST::visitPostfixOperatorDecl(PostfixOperatorDecl *decl) {
46354635
});
46364636
}
46374637

4638-
void PrintAST::visitModuleDecl(ModuleDecl *decl) { }
4638+
void PrintAST::visitModuleDecl(ModuleDecl *decl) {
4639+
4640+
}
46394641

46404642
void PrintAST::visitMissingDecl(MissingDecl *missing) {
46414643
Printer << "missing_decl";
@@ -4785,12 +4787,26 @@ void PrintAST::visitErrorExpr(ErrorExpr *expr) {
47854787
Printer << "<error>";
47864788
}
47874789

4788-
void PrintAST::visitTernaryExpr(TernaryExpr *expr) {}
4790+
void PrintAST::visitTernaryExpr(TernaryExpr *expr) {
4791+
if (auto condExpr = expr->getCondExpr(); condExpr != nullptr) {
4792+
if (auto elseExpr = expr->getElseExpr(); elseExpr != nullptr) {
4793+
visit(expr->getCondExpr());
4794+
Printer << " ? ";
4795+
visit(expr->getThenExpr());
4796+
Printer << " : ";
4797+
visit(expr->getElseExpr());
4798+
}
4799+
}
4800+
}
47894801

47904802
void PrintAST::visitIsExpr(IsExpr *expr) {
4803+
visit(expr->getSubExpr());
4804+
Printer << " is ";
4805+
printType(expr->getCastType());
47914806
}
47924807

47934808
void PrintAST::visitTapExpr(TapExpr *expr) {
4809+
47944810
}
47954811

47964812
void PrintAST::visitTryExpr(TryExpr *expr) {
@@ -4871,6 +4887,7 @@ void PrintAST::visitDictionaryExpr(DictionaryExpr *expr) {
48714887
}
48724888

48734889
void PrintAST::visitArrowExpr(ArrowExpr *expr) {
4890+
48744891
}
48754892

48764893
void PrintAST::visitAwaitExpr(AwaitExpr *expr) {
@@ -4913,6 +4930,7 @@ void PrintAST::visitTupleExpr(TupleExpr *expr) {
49134930
}
49144931

49154932
void PrintAST::visitTypeJoinExpr(TypeJoinExpr *expr) {
4933+
49164934
}
49174935

49184936
void PrintAST::visitAssignExpr(AssignExpr *expr) {
@@ -4934,12 +4952,15 @@ void PrintAST::visitBinaryExpr(BinaryExpr *expr) {
49344952
}
49354953

49364954
void PrintAST::visitCoerceExpr(CoerceExpr *expr) {
4955+
49374956
}
49384957

49394958
void PrintAST::visitOneWayExpr(OneWayExpr *expr) {
4959+
49404960
}
49414961

49424962
void PrintAST::visitClosureExpr(ClosureExpr *expr) {
4963+
49434964
}
49444965

49454966
void PrintAST::visitDeclRefExpr(DeclRefExpr *expr) {
@@ -4956,6 +4977,7 @@ void PrintAST::visitErasureExpr(ErasureExpr *expr) {
49564977
}
49574978

49584979
void PrintAST::visitKeyPathExpr(KeyPathExpr *expr) {
4980+
49594981
}
49604982

49614983
void PrintAST::visitSingleValueStmtExpr(SingleValueStmtExpr *expr) {
@@ -4968,6 +4990,7 @@ void PrintAST::visitForceTryExpr(ForceTryExpr *expr) {
49684990
}
49694991

49704992
void PrintAST::visitSequenceExpr(SequenceExpr *expr) {
4993+
49714994
}
49724995

49734996
void PrintAST::visitSuperRefExpr(SuperRefExpr *expr) {

0 commit comments

Comments
 (0)