@@ -639,7 +639,6 @@ class OptionalSomePattern : public Pattern {
639
639
}
640
640
};
641
641
642
-
643
642
// / A pattern which matches a value obtained by evaluating an expression.
644
643
// / The match will be tested using user-defined '~=' operator function lookup;
645
644
// / the match succeeds if 'patternValue ~= matchedValue' produces a true value.
@@ -649,24 +648,24 @@ class ExprPattern : public Pattern {
649
648
// / An expression constructed during type-checking that produces a call to the
650
649
// / '~=' operator comparing the match expression on the left to the matched
651
650
// / value on the right.
652
- Expr *MatchExpr;
651
+ Expr *MatchExpr = nullptr ;
653
652
654
653
// / An implicit variable used to represent the RHS value of the match.
655
- VarDecl *MatchVar;
654
+ VarDecl *MatchVar = nullptr ;
655
+
656
+ ExprPattern (Expr *E, bool isResolved)
657
+ : Pattern(PatternKind::Expr), SubExprAndIsResolved(E, isResolved) {}
656
658
657
659
public:
658
- // / Construct an ExprPattern.
659
- ExprPattern (Expr *e, bool isResolved, Expr *matchExpr, VarDecl *matchVar);
660
-
661
- // / Construct an unresolved ExprPattern.
662
- ExprPattern (Expr *e)
663
- : ExprPattern(e, false , nullptr , nullptr )
664
- {}
665
-
666
- // / Construct a resolved ExprPattern.
667
- ExprPattern (Expr *e, Expr *matchExpr, VarDecl *matchVar)
668
- : ExprPattern(e, true , matchExpr, matchVar)
669
- {}
660
+ // / Create a new parsed unresolved ExprPattern.
661
+ static ExprPattern *createParsed (ASTContext &ctx, Expr *E);
662
+
663
+ // / Create a new resolved ExprPattern. This should be used in cases
664
+ // / where a user-written expression should be treated as an ExprPattern.
665
+ static ExprPattern *createResolved (ASTContext &ctx, Expr *E);
666
+
667
+ // / Create a new implicit resolved ExprPattern.
668
+ static ExprPattern *createImplicit (ASTContext &ctx, Expr *E);
670
669
671
670
Expr *getSubExpr () const { return SubExprAndIsResolved.getPointer (); }
672
671
void setSubExpr (Expr *e) { SubExprAndIsResolved.setPointer (e); }
0 commit comments