@@ -4723,7 +4723,9 @@ void PrintAST::visitPostfixOperatorDecl(PostfixOperatorDecl *decl) {
4723
4723
});
4724
4724
}
4725
4725
4726
- void PrintAST::visitModuleDecl (ModuleDecl *decl) { }
4726
+ void PrintAST::visitModuleDecl (ModuleDecl *decl) {
4727
+
4728
+ }
4727
4729
4728
4730
void PrintAST::visitMissingDecl (MissingDecl *missing) {
4729
4731
Printer << " missing_decl" ;
@@ -4879,12 +4881,27 @@ void PrintAST::visitErrorExpr(ErrorExpr *expr) {
4879
4881
Printer << " <error>" ;
4880
4882
}
4881
4883
4882
- void PrintAST::visitTernaryExpr (TernaryExpr *expr) {}
4884
+ void PrintAST::visitTernaryExpr (TernaryExpr *expr) {
4885
+ if (auto condExpr = expr->getCondExpr ()) {
4886
+ visit (expr->getCondExpr ());
4887
+ }
4888
+ Printer << " ? " ;
4889
+ visit (expr->getThenExpr ());
4890
+ Printer << " : " ;
4891
+ if (auto elseExpr = expr->getElseExpr ()) {
4892
+ visit (expr->getElseExpr ());
4893
+ }
4894
+ }
4883
4895
4884
4896
void PrintAST::visitIsExpr (IsExpr *expr) {
4897
+ visit (expr->getSubExpr ());
4898
+ Printer << " is " ;
4899
+ printType (expr->getCastType ());
4885
4900
}
4886
4901
4887
4902
void PrintAST::visitTapExpr (TapExpr *expr) {
4903
+ printType (expr->getVar ()->getType ());
4904
+ printBraceStmt (expr->getBody ());
4888
4905
}
4889
4906
4890
4907
void PrintAST::visitTryExpr (TryExpr *expr) {
@@ -4965,6 +4982,15 @@ void PrintAST::visitDictionaryExpr(DictionaryExpr *expr) {
4965
4982
}
4966
4983
4967
4984
void PrintAST::visitArrowExpr (ArrowExpr *expr) {
4985
+ visit (expr->getArgsExpr ());
4986
+ if (auto isAsync = expr->getAsyncLoc ()) {
4987
+ Printer << " async" ;
4988
+ }
4989
+ if (auto doesThrow = expr->getThrowsLoc ()) {
4990
+ Printer << " throws" ;
4991
+ }
4992
+ Printer << " -> " ;
4993
+ visit (expr->getResultExpr ());
4968
4994
}
4969
4995
4970
4996
void PrintAST::visitAwaitExpr (AwaitExpr *expr) {
@@ -5006,8 +5032,7 @@ void PrintAST::visitTupleExpr(TupleExpr *expr) {
5006
5032
Printer << " )" ;
5007
5033
}
5008
5034
5009
- void PrintAST::visitTypeJoinExpr (TypeJoinExpr *expr) {
5010
- }
5035
+ void PrintAST::visitTypeJoinExpr (TypeJoinExpr *expr) { }
5011
5036
5012
5037
void PrintAST::visitAssignExpr (AssignExpr *expr) {
5013
5038
visit (expr->getDest ());
@@ -5028,12 +5053,35 @@ void PrintAST::visitBinaryExpr(BinaryExpr *expr) {
5028
5053
}
5029
5054
5030
5055
void PrintAST::visitCoerceExpr (CoerceExpr *expr) {
5056
+ visit (expr->getSubExpr ());
5057
+ Printer << " as " ;
5058
+ printType (expr->getCastType ());
5031
5059
}
5032
5060
5033
- void PrintAST::visitOneWayExpr (OneWayExpr *expr) {
5034
- }
5061
+ void PrintAST::visitOneWayExpr (OneWayExpr *expr) { }
5035
5062
5036
5063
void PrintAST::visitClosureExpr (ClosureExpr *expr) {
5064
+ Printer << " { " ;
5065
+ if (auto parameters = expr->getParameters ()) {
5066
+ if (expr->hasExplicitResultType ()) {
5067
+ Printer << " (" ;
5068
+ }
5069
+ bool isFirst = true ;
5070
+ for (auto & parameter: *parameters) {
5071
+ if (!isFirst) {
5072
+ Printer << " , " ;
5073
+ }
5074
+ visit (parameter);
5075
+ isFirst = true ;
5076
+ }
5077
+ if (expr->hasExplicitResultType ()) {
5078
+ Printer << " ) -> " ;
5079
+ printType (expr->getExplicitResultType ());
5080
+ }
5081
+ }
5082
+ auto body = expr->getBody ();
5083
+ printBraceStmt (body);
5084
+ Printer << " }" ;
5037
5085
}
5038
5086
5039
5087
void PrintAST::visitDeclRefExpr (DeclRefExpr *expr) {
@@ -5050,6 +5098,7 @@ void PrintAST::visitErasureExpr(ErasureExpr *expr) {
5050
5098
}
5051
5099
5052
5100
void PrintAST::visitKeyPathExpr (KeyPathExpr *expr) {
5101
+
5053
5102
}
5054
5103
5055
5104
void PrintAST::visitSingleValueStmtExpr (SingleValueStmtExpr *expr) {
@@ -5062,6 +5111,7 @@ void PrintAST::visitForceTryExpr(ForceTryExpr *expr) {
5062
5111
}
5063
5112
5064
5113
void PrintAST::visitSequenceExpr (SequenceExpr *expr) {
5114
+
5065
5115
}
5066
5116
5067
5117
void PrintAST::visitSuperRefExpr (SuperRefExpr *expr) {
0 commit comments