Skip to content

Commit b15b531

Browse files
committed
Added the following expression cases
- TernaryExpr - IsExpr - TapExpr - ArrowExpr - CoerceExpr
1 parent 8ac71b1 commit b15b531

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 30 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,27 @@ 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()) {
4792+
visit(expr->getCondExpr());
4793+
}
4794+
Printer << " ? ";
4795+
visit(expr->getThenExpr());
4796+
Printer << " : ";
4797+
if (auto elseExpr = expr->getElseExpr()) {
4798+
visit(expr->getElseExpr());
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+
printType(expr->getVar()->getType());
4810+
printBraceStmt(expr->getBody());
47944811
}
47954812

47964813
void PrintAST::visitTryExpr(TryExpr *expr) {
@@ -4871,6 +4888,9 @@ void PrintAST::visitDictionaryExpr(DictionaryExpr *expr) {
48714888
}
48724889

48734890
void PrintAST::visitArrowExpr(ArrowExpr *expr) {
4891+
visit(expr->getArgsExpr());
4892+
Printer << " -> ";
4893+
visit(expr->getResultExpr());
48744894
}
48754895

48764896
void PrintAST::visitAwaitExpr(AwaitExpr *expr) {
@@ -4913,6 +4933,7 @@ void PrintAST::visitTupleExpr(TupleExpr *expr) {
49134933
}
49144934

49154935
void PrintAST::visitTypeJoinExpr(TypeJoinExpr *expr) {
4936+
49164937
}
49174938

49184939
void PrintAST::visitAssignExpr(AssignExpr *expr) {
@@ -4934,12 +4955,17 @@ void PrintAST::visitBinaryExpr(BinaryExpr *expr) {
49344955
}
49354956

49364957
void PrintAST::visitCoerceExpr(CoerceExpr *expr) {
4958+
visit(expr->getSubExpr());
4959+
Printer << " as ";
4960+
printType(expr->getCastType());
49374961
}
49384962

49394963
void PrintAST::visitOneWayExpr(OneWayExpr *expr) {
4964+
49404965
}
49414966

49424967
void PrintAST::visitClosureExpr(ClosureExpr *expr) {
4968+
49434969
}
49444970

49454971
void PrintAST::visitDeclRefExpr(DeclRefExpr *expr) {
@@ -4956,6 +4982,7 @@ void PrintAST::visitErasureExpr(ErasureExpr *expr) {
49564982
}
49574983

49584984
void PrintAST::visitKeyPathExpr(KeyPathExpr *expr) {
4985+
49594986
}
49604987

49614988
void PrintAST::visitSingleValueStmtExpr(SingleValueStmtExpr *expr) {
@@ -4968,6 +4995,7 @@ void PrintAST::visitForceTryExpr(ForceTryExpr *expr) {
49684995
}
49694996

49704997
void PrintAST::visitSequenceExpr(SequenceExpr *expr) {
4998+
49714999
}
49725000

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

0 commit comments

Comments
 (0)