Skip to content

Commit 3707e49

Browse files
authored
Merge pull request swiftlang#76808 from slavapestov/cstrail-part-2
Continue migration from SolverScope to SolverTrail
2 parents 4a069c9 + 3dc16a9 commit 3707e49

File tree

8 files changed

+646
-177
lines changed

8 files changed

+646
-177
lines changed

include/swift/Sema/CSTrail.h

Lines changed: 88 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SolverTrail {
3636
public:
3737

3838
/// The kind of change made to the graph.
39-
enum class ChangeKind {
39+
enum class ChangeKind: unsigned {
4040
/// Added a new vertex to the constraint graph.
4141
AddedTypeVariable,
4242
/// Added a new constraint to the constraint graph.
@@ -53,6 +53,31 @@ class SolverTrail {
5353
RetractedBindings,
5454
/// Set the fixed type or parent and flags for a type variable.
5555
UpdatedTypeVariable,
56+
/// Recorded a conversion restriction kind.
57+
AddedConversionRestriction,
58+
/// Recorded a fix.
59+
AddedFix,
60+
/// Recorded a fixed requirement.
61+
AddedFixedRequirement,
62+
/// Recorded a disjunction choice.
63+
RecordedDisjunctionChoice,
64+
/// Recorded an applied disjunction.
65+
RecordedAppliedDisjunction,
66+
/// Recorded an argument matching choice.
67+
RecordedMatchCallArgumentResult,
68+
/// Recorded a list of opened types at a locator.
69+
RecordedOpenedTypes,
70+
/// Recorded the opening of an existential type at a locator.
71+
RecordedOpenedExistentialType,
72+
/// Recorded the opening of a pack existential type.
73+
RecordedOpenedPackExpansionType,
74+
/// Recorded the creation of a generic environment for a pack expansion expression.
75+
RecordedPackExpansionEnvironment,
76+
/// Recorded the mapping from a pack element expression to its parent
77+
/// pack expansion expression.
78+
RecordedPackEnvironment,
79+
/// Record a defaulted constraint at a locator.
80+
RecordedDefaultedConstraint,
5681
};
5782

5883
/// A change made to the constraint system.
@@ -64,6 +89,9 @@ class SolverTrail {
6489
/// The kind of change.
6590
ChangeKind Kind;
6691

92+
/// Extra storage.
93+
unsigned Options;
94+
6795
union {
6896
TypeVariableType *TypeVar;
6997

@@ -97,10 +125,26 @@ class SolverTrail {
97125

98126
/// The representative of the equivalence class, or the fixed type.
99127
llvm::PointerUnion<TypeVariableType *, TypeBase *> ParentOrFixed;
100-
101-
/// The saved value of TypeVariableType::Implementation::getRawOptions().
102-
unsigned Options;
103128
} Update;
129+
130+
struct {
131+
/// The source type.
132+
Type SrcType;
133+
134+
/// The destination type.
135+
Type DstType;
136+
} Restriction;
137+
138+
ConstraintFix *Fix;
139+
140+
struct {
141+
GenericTypeParamType *GP;
142+
Type ReqTy;
143+
} FixedRequirement;
144+
145+
ConstraintLocator *Locator;
146+
PackExpansionType *ExpansionTy;
147+
PackElementExpr *ElementExpr;
104148
};
105149

106150
Change() : Kind(ChangeKind::AddedTypeVariable), TypeVar(nullptr) { }
@@ -137,6 +181,46 @@ class SolverTrail {
137181
llvm::PointerUnion<TypeVariableType *, TypeBase *> parentOrFixed,
138182
unsigned options);
139183

184+
/// Create a change that recorded a restriction.
185+
static Change addedConversionRestriction(Type srcType, Type dstType);
186+
187+
/// Create a change that recorded a fix.
188+
static Change addedFix(ConstraintFix *fix);
189+
190+
/// Create a change that recorded a fixed requirement.
191+
static Change addedFixedRequirement(GenericTypeParamType *GP,
192+
unsigned reqKind,
193+
Type requirementTy);
194+
195+
/// Create a change that recorded a disjunction choice.
196+
static Change recordedDisjunctionChoice(ConstraintLocator *locator,
197+
unsigned index);
198+
199+
/// Create a change that recorded an applied disjunction.
200+
static Change recordedAppliedDisjunction(ConstraintLocator *locator);
201+
202+
/// Create a change that recorded an applied disjunction.
203+
static Change recordedMatchCallArgumentResult(ConstraintLocator *locator);
204+
205+
/// Create a change that recorded a list of opened types.
206+
static Change recordedOpenedTypes(ConstraintLocator *locator);
207+
208+
/// Create a change that recorded the opening of an existential type.
209+
static Change recordedOpenedExistentialType(ConstraintLocator *locator);
210+
211+
/// Create a change that recorded the opening of a pack expansion type.
212+
static Change recordedOpenedPackExpansionType(PackExpansionType *expansion);
213+
214+
/// Create a change that recorded the opening of a pack expansion type.
215+
static Change recordedPackExpansionEnvironment(ConstraintLocator *locator);
216+
217+
/// Create a change that recorded a mapping from a pack element expression
218+
/// to its parent expansion expression.
219+
static Change recordedPackEnvironment(PackElementExpr *packElement);
220+
221+
/// Create a change that recorded a defaulted constraint at a locator.
222+
static Change recordedDefaultedConstraint(ConstraintLocator *locator);
223+
140224
/// Undo this change, reverting the constraint graph to the state it
141225
/// had prior to this change.
142226
///

0 commit comments

Comments
 (0)