@@ -1141,6 +1141,8 @@ class PrintAST : public ASTVisitor<PrintAST> {
1141
1141
1142
1142
void printArgumentList (ArgumentList *args, bool forSubscript = false );
1143
1143
1144
+ void printAvailabilitySpec (AvailabilitySpec *spec);
1145
+
1144
1146
void printStmtCondition (StmtCondition stmt);
1145
1147
1146
1148
#define DECL (Name,Parent ) void visit##Name##Decl(Name##Decl *decl);
@@ -5697,19 +5699,58 @@ void PrintAST::visitRepeatWhileStmt(RepeatWhileStmt *stmt) {
5697
5699
visit (stmt->getCond ());
5698
5700
}
5699
5701
5702
+ void PrintAST::printAvailabilitySpec (AvailabilitySpec *spec) {
5703
+ auto domainOrIdentifier = spec->getDomainOrIdentifier ();
5704
+ if (auto domain = domainOrIdentifier.getAsDomain ()) {
5705
+ Printer << domain->getNameForAttributePrinting ();
5706
+ } else {
5707
+ Printer << domainOrIdentifier.getAsIdentifier ().value ();
5708
+ }
5709
+
5710
+ if (!spec->getRawVersion ().empty ())
5711
+ Printer << " " << spec->getRawVersion ().getAsString ();
5712
+ }
5713
+
5700
5714
void PrintAST::printStmtCondition (StmtCondition condition) {
5701
5715
interleave (
5702
5716
condition,
5703
5717
[&](StmtConditionElement &elt) {
5704
- if (auto pattern = elt.getPatternOrNull ()) {
5705
- printPattern (pattern);
5706
- auto initializer = elt.getInitializer ();
5707
- if (initializer) {
5718
+ switch (elt.getKind ()) {
5719
+ case StmtConditionElement::ConditionKind::CK_Boolean:
5720
+ visit (elt.getBoolean ());
5721
+ break ;
5722
+
5723
+ case StmtConditionElement::ConditionKind::CK_PatternBinding:
5724
+ printPattern (elt.getPattern ());
5725
+ if (auto initializer = elt.getInitializer ()) {
5708
5726
Printer << " = " ;
5709
5727
visit (initializer);
5710
5728
}
5711
- } else if (auto boolean = elt.getBooleanOrNull ()) {
5712
- visit (boolean);
5729
+ break ;
5730
+
5731
+ case StmtConditionElement::ConditionKind::CK_Availability:
5732
+ if (auto availability = elt.getAvailability ()) {
5733
+ Printer << (availability->isUnavailability ()
5734
+ ? tok::pound_unavailable
5735
+ : tok::pound_available)
5736
+ << " (" ;
5737
+
5738
+ interleave (
5739
+ availability->getQueries (),
5740
+ [&](AvailabilitySpec *spec) { printAvailabilitySpec (spec); },
5741
+ [&] { Printer << " , " ; });
5742
+
5743
+ Printer << " )" ;
5744
+ }
5745
+ break ;
5746
+
5747
+ case StmtConditionElement::ConditionKind::CK_HasSymbol:
5748
+ if (auto hasSymbolInfo = elt.getHasSymbolInfo ()) {
5749
+ Printer << tok::pound__hasSymbol << " (" ;
5750
+ visit (hasSymbolInfo->getSymbolExpr ());
5751
+ Printer << " )" ;
5752
+ }
5753
+ break ;
5713
5754
}
5714
5755
},
5715
5756
[&] { Printer << " , " ; });
0 commit comments