@@ -1124,6 +1124,15 @@ class ConstraintSystem {
1124
1124
// / \brief Depth of the solution stack.
1125
1125
unsigned depth = 0 ;
1126
1126
1127
+ // / \brief Maximum depth reached so far in exploring solutions.
1128
+ unsigned maxDepth = 0 ;
1129
+
1130
+ // / \brief Count of the number of leaf scopes we've created. These
1131
+ // / either result in a failure to solve, or in a solution, unlike
1132
+ // / all the intermediate scopes. They are interesting to track as
1133
+ // / part of a metric of whether an expression is too complex.
1134
+ unsigned leafScopes = 0 ;
1135
+
1127
1136
// / \brief Whether to record failures or not.
1128
1137
bool recordFixes = false ;
1129
1138
@@ -1198,7 +1207,8 @@ class ConstraintSystem {
1198
1207
// / \param scope The scope to associate with current solver state.
1199
1208
void registerScope (SolverScope *scope) {
1200
1209
++depth;
1201
- ++NumStatesExplored;
1210
+ maxDepth = std::max (maxDepth, depth);
1211
+ scope->scopeNumber = NumStatesExplored++;
1202
1212
1203
1213
CS.incrementScopeCounter ();
1204
1214
auto scopeInfo =
@@ -1217,6 +1227,10 @@ class ConstraintSystem {
1217
1227
void rollback (SolverScope *scope) {
1218
1228
--depth;
1219
1229
1230
+ unsigned countScopesExplored = NumStatesExplored - scope->scopeNumber ;
1231
+ if (countScopesExplored == 1 )
1232
+ ++leafScopes;
1233
+
1220
1234
SolverScope *savedScope;
1221
1235
// The position of last retired constraint before given scope.
1222
1236
ConstraintList::iterator lastRetiredPos;
@@ -1445,6 +1459,9 @@ class ConstraintSystem {
1445
1459
// / The previous score.
1446
1460
Score PreviousScore;
1447
1461
1462
+ // / The scope number of this scope. Set when the scope is registered.
1463
+ unsigned scopeNumber = 0 ;
1464
+
1448
1465
// / Time in fractional seconds at which we entered this scope.
1449
1466
double startTime;
1450
1467
0 commit comments