Commit fd74944d authored by Oswald Buddenhagen's avatar Oswald Buddenhagen Committed by Oswald Buddenhagen
Browse files

don't allow overloading of built-in functions



the functions are not versioned or scoped, so user-defined overloads would
mess up qmake's own feature files. it seems safer to break user projects
than to allow the user to break qmake.

Change-Id: I020a2e6416bbb6e2fd2ece339629d848c00c8398
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@digia.com>
Reviewed-by: default avatarOswald Buddenhagen <oswald.buddenhagen@digia.com>
(cherry picked from qtbase/849f1f9efda601bcfd3760256205a2014e0bc936)
parent 6a0a13f6
......@@ -389,13 +389,12 @@ void QMakeEvaluator::populateDeps(
}
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:
......@@ -1015,10 +1014,6 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
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;
......@@ -1028,11 +1023,10 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
}
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) {
......@@ -1624,10 +1618,6 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
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;
......
......@@ -1647,6 +1647,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBoolFunction(
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()) {
......@@ -1655,13 +1660,19 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditionalFunction(
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()) {
......@@ -1670,8 +1681,9 @@ ProStringList QMakeEvaluator::evaluateExpandFunction(
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)
......
......@@ -191,8 +191,8 @@ public:
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment