@@ -40,59 +40,11 @@ class SolverTrail {
40
40
41
41
// / The kind of change made to the graph.
42
42
enum class ChangeKind : unsigned {
43
- // / Added a new vertex to the constraint graph.
44
- AddedTypeVariable,
45
- // / Added a new constraint to the constraint graph.
46
- AddedConstraint,
47
- // / Removed an existing constraint from the constraint graph.
48
- RemovedConstraint,
49
- // / Extended the equivalence class of a type variable in the constraint graph.
50
- ExtendedEquivalenceClass,
51
- // / Added a new edge in the constraint graph.
52
- RelatedTypeVariables,
53
- // / Inferred potential bindings from a constraint.
54
- InferredBindings,
55
- // / Retracted potential bindings from a constraint.
56
- RetractedBindings,
57
- // / Set the fixed type or parent and flags for a type variable.
58
- UpdatedTypeVariable,
59
- // / Recorded a conversion restriction kind.
60
- AddedConversionRestriction,
61
- // / Recorded a fix.
62
- AddedFix,
63
- // / Recorded a fixed requirement.
64
- AddedFixedRequirement,
65
- // / Recorded a disjunction choice.
66
- RecordedDisjunctionChoice,
67
- // / Recorded an applied disjunction.
68
- RecordedAppliedDisjunction,
69
- // / Recorded an argument matching choice.
70
- RecordedMatchCallArgumentResult,
71
- // / Recorded a list of opened types at a locator.
72
- RecordedOpenedTypes,
73
- // / Recorded the opening of an existential type at a locator.
74
- RecordedOpenedExistentialType,
75
- // / Recorded the opening of a pack existential type.
76
- RecordedOpenedPackExpansionType,
77
- // / Recorded the creation of a generic environment for a pack expansion expression.
78
- RecordedPackExpansionEnvironment,
79
- // / Recorded the mapping from a pack element expression to its parent
80
- // / pack expansion expression.
81
- RecordedPackEnvironment,
82
- // / Recorded a defaulted constraint at a locator.
83
- RecordedDefaultedConstraint,
84
- // / Recorded an assignment of a type to an AST node.
85
- RecordedNodeType,
86
- // / Recorded an assignment of a type to a keypath component.
87
- RecordedKeyPathComponentType,
88
- // / Disabled a constraint.
89
- DisabledConstraint,
90
- // / Favored a constraint.
91
- FavoredConstraint,
92
- // / Recorded a result builder transform.
93
- RecordedResultBuilderTransform,
94
- // / Applied a property wrapper.
95
- AppliedPropertyWrapper,
43
+ #define CHANGE (Name ) Name,
44
+ #define LAST_CHANGE (Name ) Last = Name
45
+ #include " CSTrail.def"
46
+ #undef CHANGE
47
+ #undef LAST_CHANGE
96
48
};
97
49
98
50
// / A change made to the constraint system.
@@ -176,97 +128,82 @@ class SolverTrail {
176
128
177
129
Change () : Kind(ChangeKind::AddedTypeVariable), TypeVar(nullptr ) { }
178
130
131
+ #define LOCATOR_CHANGE (Name ) static Change Name (ConstraintLocator *locator);
132
+ #include " swift/Sema/CSTrail.def"
133
+
179
134
// / Create a change that added a type variable.
180
- static Change addedTypeVariable (TypeVariableType *typeVar);
135
+ static Change AddedTypeVariable (TypeVariableType *typeVar);
181
136
182
137
// / Create a change that added a constraint.
183
- static Change addedConstraint (TypeVariableType *typeVar, Constraint *constraint);
138
+ static Change AddedConstraint (TypeVariableType *typeVar, Constraint *constraint);
184
139
185
140
// / Create a change that removed a constraint.
186
- static Change removedConstraint (TypeVariableType *typeVar, Constraint *constraint);
141
+ static Change RemovedConstraint (TypeVariableType *typeVar, Constraint *constraint);
187
142
188
143
// / Create a change that extended an equivalence class.
189
- static Change extendedEquivalenceClass (TypeVariableType *typeVar,
144
+ static Change ExtendedEquivalenceClass (TypeVariableType *typeVar,
190
145
unsigned prevSize);
191
146
192
147
// / Create a change that updated the references/referenced by sets of
193
148
// / a type variable pair.
194
- static Change relatedTypeVariables (TypeVariableType *typeVar,
149
+ static Change RelatedTypeVariables (TypeVariableType *typeVar,
195
150
TypeVariableType *otherTypeVar);
196
151
197
152
// / Create a change that inferred bindings from a constraint.
198
- static Change inferredBindings (TypeVariableType *typeVar,
153
+ static Change InferredBindings (TypeVariableType *typeVar,
199
154
Constraint *constraint);
200
155
201
156
// / Create a change that retracted bindings from a constraint.
202
- static Change retractedBindings (TypeVariableType *typeVar,
157
+ static Change RetractedBindings (TypeVariableType *typeVar,
203
158
Constraint *constraint);
204
159
205
160
// / Create a change that updated a type variable.
206
- static Change updatedTypeVariable (
161
+ static Change UpdatedTypeVariable (
207
162
TypeVariableType *typeVar,
208
163
llvm::PointerUnion<TypeVariableType *, TypeBase *> parentOrFixed,
209
164
unsigned options);
210
165
211
166
// / Create a change that recorded a restriction.
212
- static Change addedConversionRestriction (Type srcType, Type dstType);
167
+ static Change AddedConversionRestriction (Type srcType, Type dstType);
213
168
214
169
// / Create a change that recorded a fix.
215
- static Change addedFix (ConstraintFix *fix);
170
+ static Change AddedFix (ConstraintFix *fix);
216
171
217
172
// / Create a change that recorded a fixed requirement.
218
- static Change addedFixedRequirement (GenericTypeParamType *GP,
173
+ static Change AddedFixedRequirement (GenericTypeParamType *GP,
219
174
unsigned reqKind,
220
175
Type requirementTy);
221
176
222
177
// / Create a change that recorded a disjunction choice.
223
- static Change recordedDisjunctionChoice (ConstraintLocator *locator,
178
+ static Change RecordedDisjunctionChoice (ConstraintLocator *locator,
224
179
unsigned index);
225
180
226
- // / Create a change that recorded an applied disjunction.
227
- static Change recordedAppliedDisjunction (ConstraintLocator *locator);
228
-
229
- // / Create a change that recorded an applied disjunction.
230
- static Change recordedMatchCallArgumentResult (ConstraintLocator *locator);
231
-
232
- // / Create a change that recorded a list of opened types.
233
- static Change recordedOpenedTypes (ConstraintLocator *locator);
234
-
235
- // / Create a change that recorded the opening of an existential type.
236
- static Change recordedOpenedExistentialType (ConstraintLocator *locator);
237
-
238
181
// / Create a change that recorded the opening of a pack expansion type.
239
- static Change recordedOpenedPackExpansionType (PackExpansionType *expansion);
240
-
241
- // / Create a change that recorded the opening of a pack expansion type.
242
- static Change recordedPackExpansionEnvironment (ConstraintLocator *locator);
182
+ static Change RecordedOpenedPackExpansionType (PackExpansionType *expansion);
243
183
244
184
// / Create a change that recorded a mapping from a pack element expression
245
185
// / to its parent expansion expression.
246
- static Change recordedPackEnvironment (PackElementExpr *packElement);
247
-
248
- // / Create a change that recorded a defaulted constraint at a locator.
249
- static Change recordedDefaultedConstraint (ConstraintLocator *locator);
186
+ static Change RecordedPackEnvironment (PackElementExpr *packElement);
250
187
251
188
// / Create a change that recorded an assignment of a type to an AST node.
252
- static Change recordedNodeType (ASTNode node, Type oldType);
189
+ static Change RecordedNodeType (ASTNode node, Type oldType);
253
190
254
191
// / Create a change that recorded an assignment of a type to an AST node.
255
- static Change recordedKeyPathComponentType (const KeyPathExpr *expr,
192
+ static Change RecordedKeyPathComponentType (const KeyPathExpr *expr,
256
193
unsigned component,
257
194
Type oldType);
258
195
259
196
// / Create a change that disabled a constraint.
260
- static Change disabledConstraint (Constraint *constraint);
197
+ static Change DisabledConstraint (Constraint *constraint);
261
198
262
199
// / Create a change that favored a constraint.
263
- static Change favoredConstraint (Constraint *constraint);
200
+ static Change FavoredConstraint (Constraint *constraint);
264
201
265
202
// / Create a change that recorded a result builder transform.
266
- static Change recordedResultBuilderTransform (AnyFunctionRef fn);
203
+ static Change RecordedResultBuilderTransform (AnyFunctionRef fn);
267
204
268
205
// / Create a change that recorded a result builder transform.
269
- static Change appliedPropertyWrapper (Expr *anchor);
206
+ static Change AppliedPropertyWrapper (Expr *anchor);
270
207
271
208
// / Undo this change, reverting the constraint graph to the state it
272
209
// / had prior to this change.
@@ -278,7 +215,7 @@ class SolverTrail {
278
215
unsigned indent = 0 ) const ;
279
216
};
280
217
281
- SolverTrail (ConstraintSystem &cs) : CS(cs) {}
218
+ SolverTrail (ConstraintSystem &cs);
282
219
283
220
~SolverTrail ();
284
221
@@ -305,6 +242,8 @@ class SolverTrail {
305
242
// / The list of changes made to this constraint system.
306
243
std::vector<Change> Changes;
307
244
245
+ uint64_t Profile[unsigned (ChangeKind::Last) + 1 ];
246
+
308
247
bool UndoActive = false ;
309
248
unsigned Total = 0 ;
310
249
unsigned Max = 0 ;
0 commit comments