forked from qt-creator/qt-creator
put condition state variables into a structure
to enable cleaner save/restore - for later
This commit is contained in:
@@ -193,11 +193,13 @@ public:
|
|||||||
|
|
||||||
QStringList qmakeFeaturePaths();
|
QStringList qmakeFeaturePaths();
|
||||||
|
|
||||||
enum { ConditionTrue, ConditionFalse, ConditionElse };
|
enum Condition { ConditionFalse, ConditionTrue, ConditionElse };
|
||||||
int m_condition;
|
struct State {
|
||||||
int m_prevCondition;
|
Condition condition;
|
||||||
bool m_updateCondition;
|
Condition prevCondition;
|
||||||
bool m_invertNext;
|
bool updateCondition; // == !(enclosingBlock()->kind() & ScopeContents)
|
||||||
|
} m_sts;
|
||||||
|
bool m_invertNext; // Short-lived, so not in State
|
||||||
int m_skipLevel;
|
int m_skipLevel;
|
||||||
bool m_cumulative;
|
bool m_cumulative;
|
||||||
bool m_isFirstVariableValue;
|
bool m_isFirstVariableValue;
|
||||||
@@ -224,6 +226,8 @@ public:
|
|||||||
bool m_parsePreAndPostFiles;
|
bool m_parsePreAndPostFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_TYPEINFO(ProFileEvaluator::Private::State, Q_PRIMITIVE_TYPE);
|
||||||
|
|
||||||
ProFileEvaluator::Private::Private(ProFileEvaluator *q_)
|
ProFileEvaluator::Private::Private(ProFileEvaluator *q_)
|
||||||
: q(q_)
|
: q(q_)
|
||||||
{
|
{
|
||||||
@@ -236,8 +240,8 @@ ProFileEvaluator::Private::Private(ProFileEvaluator *q_)
|
|||||||
m_cumulative = true;
|
m_cumulative = true;
|
||||||
|
|
||||||
// Evaluator state
|
// Evaluator state
|
||||||
m_updateCondition = false;
|
m_sts.updateCondition = false;
|
||||||
m_condition = ConditionFalse;
|
m_sts.condition = ConditionFalse;
|
||||||
m_invertNext = false;
|
m_invertNext = false;
|
||||||
m_skipLevel = 0;
|
m_skipLevel = 0;
|
||||||
m_isFirstVariableValue = true;
|
m_isFirstVariableValue = true;
|
||||||
@@ -556,16 +560,16 @@ void ProFileEvaluator::Private::updateItem()
|
|||||||
bool ProFileEvaluator::Private::visitBeginProBlock(ProBlock *block)
|
bool ProFileEvaluator::Private::visitBeginProBlock(ProBlock *block)
|
||||||
{
|
{
|
||||||
if (block->blockKind() == ProBlock::ScopeKind) {
|
if (block->blockKind() == ProBlock::ScopeKind) {
|
||||||
m_updateCondition = true;
|
m_sts.updateCondition = true;
|
||||||
if (!m_skipLevel) {
|
if (!m_skipLevel) {
|
||||||
m_prevCondition = m_condition;
|
m_sts.prevCondition = m_sts.condition;
|
||||||
m_condition = ConditionFalse;
|
m_sts.condition = ConditionFalse;
|
||||||
} else {
|
} else {
|
||||||
Q_ASSERT(m_condition != ConditionTrue);
|
Q_ASSERT(m_sts.condition != ConditionTrue);
|
||||||
}
|
}
|
||||||
} else if (block->blockKind() & ProBlock::ScopeContentsKind) {
|
} else if (block->blockKind() & ProBlock::ScopeContentsKind) {
|
||||||
m_updateCondition = false;
|
m_sts.updateCondition = false;
|
||||||
if (m_condition != ConditionTrue)
|
if (m_sts.condition != ConditionTrue)
|
||||||
++m_skipLevel;
|
++m_skipLevel;
|
||||||
else
|
else
|
||||||
Q_ASSERT(!m_skipLevel);
|
Q_ASSERT(!m_skipLevel);
|
||||||
@@ -577,12 +581,12 @@ bool ProFileEvaluator::Private::visitEndProBlock(ProBlock *block)
|
|||||||
{
|
{
|
||||||
if (block->blockKind() & ProBlock::ScopeContentsKind) {
|
if (block->blockKind() & ProBlock::ScopeContentsKind) {
|
||||||
if (m_skipLevel) {
|
if (m_skipLevel) {
|
||||||
Q_ASSERT(m_condition != ConditionTrue);
|
Q_ASSERT(m_sts.condition != ConditionTrue);
|
||||||
--m_skipLevel;
|
--m_skipLevel;
|
||||||
} else {
|
} else {
|
||||||
// Conditionals contained inside this block may have changed the state.
|
// Conditionals contained inside this block may have changed the state.
|
||||||
// So we reset it here to make an else following us do the right thing.
|
// So we reset it here to make an else following us do the right thing.
|
||||||
m_condition = ConditionTrue;
|
m_sts.condition = ConditionTrue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -619,13 +623,13 @@ bool ProFileEvaluator::Private::visitProCondition(ProCondition *cond)
|
|||||||
if (cond->text().toLower() == QLatin1String("else")) {
|
if (cond->text().toLower() == QLatin1String("else")) {
|
||||||
// The state ConditionElse makes sure that subsequential elses are ignored.
|
// The state ConditionElse makes sure that subsequential elses are ignored.
|
||||||
// That's braindead, but qmake is like that.
|
// That's braindead, but qmake is like that.
|
||||||
if (m_prevCondition == ConditionTrue)
|
if (m_sts.prevCondition == ConditionTrue)
|
||||||
m_condition = ConditionElse;
|
m_sts.condition = ConditionElse;
|
||||||
else if (m_prevCondition == ConditionFalse)
|
else if (m_sts.prevCondition == ConditionFalse)
|
||||||
m_condition = ConditionTrue;
|
m_sts.condition = ConditionTrue;
|
||||||
} else if (m_condition == ConditionFalse) {
|
} else if (m_sts.condition == ConditionFalse) {
|
||||||
if (isActiveConfig(cond->text(), true) ^ m_invertNext)
|
if (isActiveConfig(cond->text(), true) ^ m_invertNext)
|
||||||
m_condition = ConditionTrue;
|
m_sts.condition = ConditionTrue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_invertNext = false;
|
m_invertNext = false;
|
||||||
@@ -865,7 +869,7 @@ bool ProFileEvaluator::Private::visitProValue(ProValue *value)
|
|||||||
|
|
||||||
bool ProFileEvaluator::Private::visitProFunction(ProFunction *func)
|
bool ProFileEvaluator::Private::visitProFunction(ProFunction *func)
|
||||||
{
|
{
|
||||||
if (!m_updateCondition || m_condition == ConditionFalse) {
|
if (!m_sts.updateCondition || m_sts.condition == ConditionFalse) {
|
||||||
QString text = func->text();
|
QString text = func->text();
|
||||||
int lparen = text.indexOf(QLatin1Char('('));
|
int lparen = text.indexOf(QLatin1Char('('));
|
||||||
int rparen = text.lastIndexOf(QLatin1Char(')'));
|
int rparen = text.lastIndexOf(QLatin1Char(')'));
|
||||||
@@ -875,7 +879,7 @@ bool ProFileEvaluator::Private::visitProFunction(ProFunction *func)
|
|||||||
m_lineNo = func->lineNumber();
|
m_lineNo = func->lineNumber();
|
||||||
bool result = evaluateConditionalFunction(funcName.trimmed(), arguments);
|
bool result = evaluateConditionalFunction(funcName.trimmed(), arguments);
|
||||||
if (!m_skipLevel && (result ^ m_invertNext))
|
if (!m_skipLevel && (result ^ m_invertNext))
|
||||||
m_condition = ConditionTrue;
|
m_sts.condition = ConditionTrue;
|
||||||
}
|
}
|
||||||
m_invertNext = false;
|
m_invertNext = false;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
Private *d;
|
Private *d;
|
||||||
|
|
||||||
|
template<typename T> friend class QTypeInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
Reference in New Issue
Block a user