forked from qt-creator/qt-creator
merge ProFunction into ProCondition
there is no point in the split, given that there is nothing virtual any more.
This commit is contained in:
@@ -224,9 +224,8 @@ public:
|
|||||||
ProItem::ProItemReturn visitProLoopIteration();
|
ProItem::ProItemReturn visitProLoopIteration();
|
||||||
void visitProLoopCleanup();
|
void visitProLoopCleanup();
|
||||||
void visitProVariable(ProVariable *variable);
|
void visitProVariable(ProVariable *variable);
|
||||||
ProItem::ProItemReturn visitProFunction(ProFunction *function);
|
|
||||||
void visitProOperator(ProOperator *oper);
|
void visitProOperator(ProOperator *oper);
|
||||||
void visitProCondition(ProCondition *condition);
|
ProItem::ProItemReturn visitProCondition(ProCondition *condition);
|
||||||
|
|
||||||
static inline QString map(const QString &var);
|
static inline QString map(const QString &var);
|
||||||
QHash<QString, QStringList> *findValues(const QString &variableName,
|
QHash<QString, QStringList> *findValues(const QString &variableName,
|
||||||
@@ -899,14 +898,7 @@ void ProFileEvaluator::Private::updateItem(ushort *uc, ushort *ptr)
|
|||||||
if (ptr == uc)
|
if (ptr == uc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString proItem = QString((QChar*)uc, ptr - uc);
|
ProItem *item = new ProCondition(QString((QChar*)uc, ptr - uc));;
|
||||||
|
|
||||||
ProItem *item;
|
|
||||||
if (proItem.endsWith(QLatin1Char(')'))) {
|
|
||||||
item = new ProFunction(proItem);
|
|
||||||
} else {
|
|
||||||
item = new ProCondition(proItem);
|
|
||||||
}
|
|
||||||
item->setLineNumber(m_lineNo);
|
item->setLineNumber(m_lineNo);
|
||||||
currentBlock().append(item);
|
currentBlock().append(item);
|
||||||
}
|
}
|
||||||
@@ -1033,10 +1025,7 @@ ProItem::ProItemReturn ProFileEvaluator::Private::visitProItem(ProItem *item)
|
|||||||
visitProVariable(static_cast<ProVariable*>(item));
|
visitProVariable(static_cast<ProVariable*>(item));
|
||||||
break;
|
break;
|
||||||
case ProItem::ConditionKind:
|
case ProItem::ConditionKind:
|
||||||
visitProCondition(static_cast<ProCondition*>(item));
|
return visitProCondition(static_cast<ProCondition*>(item));
|
||||||
break;
|
|
||||||
case ProItem::FunctionKind:
|
|
||||||
return visitProFunction(static_cast<ProFunction*>(item));
|
|
||||||
case ProItem::OperatorKind:
|
case ProItem::OperatorKind:
|
||||||
visitProOperator(static_cast<ProOperator*>(item));
|
visitProOperator(static_cast<ProOperator*>(item));
|
||||||
break;
|
break;
|
||||||
@@ -1234,19 +1223,40 @@ void ProFileEvaluator::Private::visitProOperator(ProOperator *oper)
|
|||||||
m_invertNext = (oper->operatorKind() == ProOperator::NotOperator);
|
m_invertNext = (oper->operatorKind() == ProOperator::NotOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProFileEvaluator::Private::visitProCondition(ProCondition *cond)
|
ProItem::ProItemReturn ProFileEvaluator::Private::visitProCondition(ProCondition *cond)
|
||||||
{
|
{
|
||||||
|
// Make sure that called subblocks don't inherit & destroy the state
|
||||||
|
bool invertThis = m_invertNext;
|
||||||
|
m_invertNext = false;
|
||||||
|
if (cond->text().endsWith(QLatin1Char(')'))) {
|
||||||
|
if (!m_skipLevel) {
|
||||||
|
m_hadCondition = true;
|
||||||
|
m_sts.prevCondition = false;
|
||||||
|
}
|
||||||
|
if (m_cumulative || !m_sts.condition) {
|
||||||
|
int lparen = cond->text().indexOf(QLatin1Char('('));
|
||||||
|
QString arguments = cond->text().mid(lparen + 1, cond->text().length() - lparen - 2);
|
||||||
|
QString funcName = cond->text().left(lparen).trimmed();
|
||||||
|
m_lineNo = cond->lineNumber();
|
||||||
|
ProItem::ProItemReturn result = evaluateConditionalFunction(funcName, arguments);
|
||||||
|
if (result != ProItem::ReturnFalse && result != ProItem::ReturnTrue)
|
||||||
|
return result;
|
||||||
|
if (!m_skipLevel && ((result == ProItem::ReturnTrue) ^ invertThis))
|
||||||
|
m_sts.condition = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (!m_skipLevel) {
|
if (!m_skipLevel) {
|
||||||
m_hadCondition = true;
|
m_hadCondition = true;
|
||||||
if (!cond->text().compare(statics.strelse, Qt::CaseInsensitive)) {
|
if (!cond->text().compare(statics.strelse, Qt::CaseInsensitive)) {
|
||||||
m_sts.condition = !m_sts.prevCondition;
|
m_sts.condition = !m_sts.prevCondition;
|
||||||
} else {
|
} else {
|
||||||
m_sts.prevCondition = false;
|
m_sts.prevCondition = false;
|
||||||
if (!m_sts.condition && isActiveConfig(cond->text(), true) ^ m_invertNext)
|
if (!m_sts.condition && isActiveConfig(cond->text(), true) ^ invertThis)
|
||||||
m_sts.condition = true;
|
m_sts.condition = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_invertNext = false;
|
}
|
||||||
|
return ProItem::ReturnTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProItem::ProItemReturn ProFileEvaluator::Private::visitProFile(ProFile *pro)
|
ProItem::ProItemReturn ProFileEvaluator::Private::visitProFile(ProFile *pro)
|
||||||
@@ -1420,32 +1430,6 @@ ProItem::ProItemReturn ProFileEvaluator::Private::visitProFile(ProFile *pro)
|
|||||||
return ProItem::ReturnTrue;
|
return ProItem::ReturnTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProItem::ProItemReturn ProFileEvaluator::Private::visitProFunction(ProFunction *func)
|
|
||||||
{
|
|
||||||
// Make sure that called subblocks don't inherit & destroy the state
|
|
||||||
bool invertThis = m_invertNext;
|
|
||||||
m_invertNext = false;
|
|
||||||
if (!m_skipLevel) {
|
|
||||||
m_hadCondition = true;
|
|
||||||
m_sts.prevCondition = false;
|
|
||||||
}
|
|
||||||
if (m_cumulative || !m_sts.condition) {
|
|
||||||
QString text = func->text();
|
|
||||||
int lparen = text.indexOf(QLatin1Char('('));
|
|
||||||
int rparen = text.lastIndexOf(QLatin1Char(')'));
|
|
||||||
Q_ASSERT(lparen < rparen);
|
|
||||||
QString arguments = text.mid(lparen + 1, rparen - lparen - 1);
|
|
||||||
QString funcName = text.left(lparen);
|
|
||||||
m_lineNo = func->lineNumber();
|
|
||||||
ProItem::ProItemReturn result = evaluateConditionalFunction(funcName.trimmed(), arguments);
|
|
||||||
if (result != ProItem::ReturnFalse && result != ProItem::ReturnTrue)
|
|
||||||
return result;
|
|
||||||
if (!m_skipLevel && ((result == ProItem::ReturnTrue) ^ invertThis))
|
|
||||||
m_sts.condition = true;
|
|
||||||
}
|
|
||||||
return ProItem::ReturnTrue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QStringList ProFileEvaluator::Private::qmakeMkspecPaths() const
|
QStringList ProFileEvaluator::Private::qmakeMkspecPaths() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ ProBlock::~ProBlock()
|
|||||||
nitm = itm->m_next;
|
nitm = itm->m_next;
|
||||||
switch (itm->kind()) {
|
switch (itm->kind()) {
|
||||||
case BlockKind: static_cast<ProBlock *>(itm)->deref(); break;
|
case BlockKind: static_cast<ProBlock *>(itm)->deref(); break;
|
||||||
case FunctionKind: delete static_cast<ProFunction *>(itm); break;
|
|
||||||
case ConditionKind: delete static_cast<ProCondition *>(itm); break;
|
case ConditionKind: delete static_cast<ProCondition *>(itm); break;
|
||||||
case OperatorKind: delete static_cast<ProOperator *>(itm); break;
|
case OperatorKind: delete static_cast<ProOperator *>(itm); break;
|
||||||
case VariableKind: delete static_cast<ProVariable *>(itm); break;
|
case VariableKind: delete static_cast<ProVariable *>(itm); break;
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ class ProItem
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum ProItemKind {
|
enum ProItemKind {
|
||||||
FunctionKind,
|
|
||||||
ConditionKind,
|
ConditionKind,
|
||||||
OperatorKind,
|
OperatorKind,
|
||||||
VariableKind,
|
VariableKind,
|
||||||
@@ -144,17 +143,6 @@ private:
|
|||||||
QString m_value;
|
QString m_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProFunction : public ProItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ProFunction(const QString &text) : ProItem(FunctionKind), m_text(text) {}
|
|
||||||
void setText(const QString &text) { m_text = text; }
|
|
||||||
QString text() const { return m_text; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_text;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ProCondition : public ProItem
|
class ProCondition : public ProItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user