forked from qt-creator/qt-creator
factor out evaluateBuiltin{Expand,Conditional} (again)
will need a second entry path, so it's better to have them separate Change-Id: I52bce5de536fd0ef5d6773d8177550b8d6202d1d Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
@@ -387,16 +387,12 @@ void QMakeEvaluator::populateDeps(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProStringList QMakeEvaluator::evaluateExpandFunction(
|
ProStringList QMakeEvaluator::evaluateBuiltinExpand(
|
||||||
const ProKey &func, const ushort *&tokPtr)
|
const ProKey &func, const ProStringList &args)
|
||||||
{
|
{
|
||||||
QHash<ProKey, ProFunctionDef>::ConstIterator it =
|
ProStringList ret;
|
||||||
m_functionDefs.replaceFunctions.constFind(func);
|
|
||||||
if (it != m_functionDefs.replaceFunctions.constEnd()) {
|
traceMsg("calling built-in $$%s(%s)", dbgKey(func), dbgSepStrList(args));
|
||||||
const QList<ProStringList> args = prepareFunctionArgs(tokPtr);
|
|
||||||
traceMsg("calling $$%s(%s)", dbgKey(func), dbgStrListList(args));
|
|
||||||
return evaluateFunction(*it, args, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
ExpandFunc func_t = ExpandFunc(statics.expands.value(func));
|
ExpandFunc func_t = ExpandFunc(statics.expands.value(func));
|
||||||
if (func_t == 0) {
|
if (func_t == 0) {
|
||||||
@@ -408,12 +404,6 @@ ProStringList QMakeEvaluator::evaluateExpandFunction(
|
|||||||
deprecationWarning(fL1S("Using uppercased builtin functions is deprecated."));
|
deprecationWarning(fL1S("Using uppercased builtin functions is deprecated."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//why don't the builtin functions just use args_list? --Sam
|
|
||||||
const ProStringList &args = expandVariableReferences(tokPtr, 5, true);
|
|
||||||
traceMsg("calling built-in $$%s(%s)", dbgKey(func), dbgSepStrList(args));
|
|
||||||
ProStringList ret;
|
|
||||||
|
|
||||||
switch (func_t) {
|
switch (func_t) {
|
||||||
case E_BASENAME:
|
case E_BASENAME:
|
||||||
case E_DIRNAME:
|
case E_DIRNAME:
|
||||||
@@ -1052,23 +1042,12 @@ ProStringList QMakeEvaluator::evaluateExpandFunction(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditionalFunction(
|
QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
|
||||||
const ProKey &function, const ushort *&tokPtr)
|
const ProKey &function, const ProStringList &args)
|
||||||
{
|
{
|
||||||
QHash<ProKey, ProFunctionDef>::ConstIterator it =
|
|
||||||
m_functionDefs.testFunctions.constFind(function);
|
|
||||||
if (it != m_functionDefs.testFunctions.constEnd()) {
|
|
||||||
const QList<ProStringList> args = prepareFunctionArgs(tokPtr);
|
|
||||||
traceMsg("calling %s(%s)", dbgKey(function), dbgStrListList(args));
|
|
||||||
return evaluateBoolFunction(*it, args, function);
|
|
||||||
}
|
|
||||||
|
|
||||||
TestFunc func_t = (TestFunc)statics.functions.value(function);
|
|
||||||
|
|
||||||
//why don't the builtin functions just use args_list? --Sam
|
|
||||||
const ProStringList &args = expandVariableReferences(tokPtr, 5, true);
|
|
||||||
traceMsg("calling built-in %s(%s)", dbgKey(function), dbgSepStrList(args));
|
traceMsg("calling built-in %s(%s)", dbgKey(function), dbgSepStrList(args));
|
||||||
|
|
||||||
|
TestFunc func_t = (TestFunc)statics.functions.value(function);
|
||||||
switch (func_t) {
|
switch (func_t) {
|
||||||
case T_DEFINED: {
|
case T_DEFINED: {
|
||||||
if (args.count() < 1 || args.count() > 2) {
|
if (args.count() < 1 || args.count() > 2) {
|
||||||
|
@@ -1616,6 +1616,36 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBoolFunction(
|
|||||||
return ReturnFalse;
|
return ReturnFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditionalFunction(
|
||||||
|
const ProKey &func, const ushort *&tokPtr)
|
||||||
|
{
|
||||||
|
QHash<ProKey, ProFunctionDef>::ConstIterator it =
|
||||||
|
m_functionDefs.testFunctions.constFind(func);
|
||||||
|
if (it != m_functionDefs.testFunctions.constEnd()) {
|
||||||
|
const QList<ProStringList> args = prepareFunctionArgs(tokPtr);
|
||||||
|
traceMsg("calling %s(%s)", dbgKey(func), dbgStrListList(args));
|
||||||
|
return evaluateBoolFunction(*it, args, func);
|
||||||
|
}
|
||||||
|
|
||||||
|
//why don't the builtin functions just use args_list? --Sam
|
||||||
|
return evaluateBuiltinConditional(func, expandVariableReferences(tokPtr, 5, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
ProStringList QMakeEvaluator::evaluateExpandFunction(
|
||||||
|
const ProKey &func, const ushort *&tokPtr)
|
||||||
|
{
|
||||||
|
QHash<ProKey, ProFunctionDef>::ConstIterator it =
|
||||||
|
m_functionDefs.replaceFunctions.constFind(func);
|
||||||
|
if (it != m_functionDefs.replaceFunctions.constEnd()) {
|
||||||
|
const QList<ProStringList> args = prepareFunctionArgs(tokPtr);
|
||||||
|
traceMsg("calling $$%s(%s)", dbgKey(func), dbgStrListList(args));
|
||||||
|
return evaluateFunction(*it, args, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//why don't the builtin functions just use args_list? --Sam
|
||||||
|
return evaluateBuiltinExpand(func, expandVariableReferences(tokPtr, 5, true));
|
||||||
|
}
|
||||||
|
|
||||||
bool QMakeEvaluator::evaluateConditional(const QString &cond, const QString &where, int line)
|
bool QMakeEvaluator::evaluateConditional(const QString &cond, const QString &where, int line)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
@@ -178,6 +178,9 @@ public:
|
|||||||
ProStringList evaluateExpandFunction(const ProKey &function, const ushort *&tokPtr);
|
ProStringList evaluateExpandFunction(const ProKey &function, const ushort *&tokPtr);
|
||||||
VisitReturn evaluateConditionalFunction(const ProKey &function, const ushort *&tokPtr);
|
VisitReturn evaluateConditionalFunction(const ProKey &function, const ushort *&tokPtr);
|
||||||
|
|
||||||
|
ProStringList evaluateBuiltinExpand(const ProKey &function, const ProStringList &args);
|
||||||
|
VisitReturn evaluateBuiltinConditional(const ProKey &function, const ProStringList &args);
|
||||||
|
|
||||||
bool evaluateConditional(const QString &cond, const QString &where, int line = -1);
|
bool evaluateConditional(const QString &cond, const QString &where, int line = -1);
|
||||||
#ifdef PROEVALUATOR_FULL
|
#ifdef PROEVALUATOR_FULL
|
||||||
void checkRequirements(const ProStringList &deps);
|
void checkRequirements(const ProStringList &deps);
|
||||||
|
Reference in New Issue
Block a user