}
ProStringList QMakeEvaluator::evaluateBuiltinExpand(
- const ProKey &func, const ProStringList &args)
+ int func_t, const ProKey &func, const ProStringList &args)
{
ProStringList ret;
traceMsg("calling built-in $$%s(%s)", dbgKey(func), dbgSepStrList(args));
- ExpandFunc func_t = ExpandFunc(statics.expands.value(func));
switch (func_t) {
case E_BASENAME:
case E_DIRNAME:
ret << (rstr.isSharedWith(m_tmp1) ? args.at(0) : ProString(rstr).setSource(args.at(0)));
}
break;
- case E_INVALID:
- evalError(fL1S("'%1' is not a recognized replace function.")
- .arg(func.toQString(m_tmp1)));
- break;
default:
evalError(fL1S("Function '%1' is not implemented.").arg(func.toQString(m_tmp1)));
break;
}
QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
- const ProKey &function, const ProStringList &args)
+ int func_t, const ProKey &function, const ProStringList &args)
{
traceMsg("calling built-in %s(%s)", dbgKey(function), dbgSepStrList(args));
- TestFunc func_t = (TestFunc)statics.functions.value(function);
switch (func_t) {
case T_DEFINED: {
if (args.count() < 1 || args.count() > 2) {
return writeFile(fL1S("cache "), fn, QIODevice::Append, varstr);
}
#endif
- case T_INVALID:
- evalError(fL1S("'%1' is not a recognized test function.")
- .arg(function.toQString(m_tmp1)));
- return ReturnFalse;
default:
evalError(fL1S("Function '%1' is not implemented.").arg(function.toQString(m_tmp1)));
return ReturnFalse;
QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditionalFunction(
const ProKey &func, const ushort *&tokPtr)
{
+ if (int func_t = statics.functions.value(func)) {
+ //why don't the builtin functions just use args_list? --Sam
+ return evaluateBuiltinConditional(func_t, func, expandVariableReferences(tokPtr, 5, true));
+ }
+
QHash<ProKey, ProFunctionDef>::ConstIterator it =
m_functionDefs.testFunctions.constFind(func);
if (it != m_functionDefs.testFunctions.constEnd()) {
return evaluateBoolFunction(*it, args, func);
}
- //why don't the builtin functions just use args_list? --Sam
- return evaluateBuiltinConditional(func, expandVariableReferences(tokPtr, 5, true));
+ skipExpression(tokPtr);
+ evalError(fL1S("'%1' is not a recognized test function.").arg(func.toQString(m_tmp1)));
+ return ReturnFalse;
}
ProStringList QMakeEvaluator::evaluateExpandFunction(
const ProKey &func, const ushort *&tokPtr)
{
+ if (int func_t = statics.expands.value(func)) {
+ //why don't the builtin functions just use args_list? --Sam
+ return evaluateBuiltinExpand(func_t, func, expandVariableReferences(tokPtr, 5, true));
+ }
+
QHash<ProKey, ProFunctionDef>::ConstIterator it =
m_functionDefs.replaceFunctions.constFind(func);
if (it != m_functionDefs.replaceFunctions.constEnd()) {
return evaluateFunction(*it, args, 0);
}
- //why don't the builtin functions just use args_list? --Sam
- return evaluateBuiltinExpand(func, expandVariableReferences(tokPtr, 5, true));
+ skipExpression(tokPtr);
+ evalError(fL1S("'%1' is not a recognized replace function.").arg(func.toQString(m_tmp1)));
+ return ProStringList();
}
bool QMakeEvaluator::evaluateConditional(const QString &cond, const QString &where, int line)
ProStringList evaluateExpandFunction(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);
+ ProStringList evaluateBuiltinExpand(int func_t, const ProKey &function, const ProStringList &args);
+ VisitReturn evaluateBuiltinConditional(int func_t, const ProKey &function, const ProStringList &args);
bool evaluateConditional(const QString &cond, const QString &where, int line = -1);
#ifdef PROEVALUATOR_FULL
#include "project.h"
#include "option.h"
+#include <qmakeevaluator_p.h>
#include <qdir.h>
#include <stdio.h>
+using namespace QMakeInternal;
+
QT_BEGIN_NAMESPACE
QMakeProject::QMakeProject()
{
m_current.clear();
+ if (int func_t = statics.functions.value(func))
+ return evaluateBuiltinConditional(func_t, func, prepareBuiltinArgs(args)) == ReturnTrue;
+
QHash<ProKey, ProFunctionDef>::ConstIterator it =
m_functionDefs.testFunctions.constFind(func);
if (it != m_functionDefs.testFunctions.constEnd())
return evaluateBoolFunction(*it, args, func) == ReturnTrue;
- return evaluateBuiltinConditional(func, prepareBuiltinArgs(args)) == ReturnTrue;
+ evalError(QStringLiteral("'%1' is not a recognized test function.")
+ .arg(func.toQString(m_tmp1)));
+ return false;
}
QStringList QMakeProject::expand(const ProKey &func, const QList<ProStringList> &args)
{
m_current.clear();
+ if (int func_t = statics.expands.value(func))
+ return evaluateBuiltinExpand(func_t, func, prepareBuiltinArgs(args)).toQStringList();
+
QHash<ProKey, ProFunctionDef>::ConstIterator it =
m_functionDefs.replaceFunctions.constFind(func);
if (it != m_functionDefs.replaceFunctions.constEnd())
return evaluateFunction(*it, args, 0).toQStringList();
- return evaluateBuiltinExpand(func, prepareBuiltinArgs(args)).toQStringList();
+ evalError(QStringLiteral("'%1' is not a recognized replace function.")
+ .arg(func.toQString(m_tmp1)));
+ return QStringList();
}
ProString QMakeProject::expand(const QString &expr, const QString &where, int line)