move get{,Hash}Str from QMakeEvaluator to ProFile
this makes it possible to use these functions without an evaluator. Change-Id: I23e4ec141b427f4c3c8b647305532be179058c07 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
parent
637a0889b2
commit
df43683975
@ -485,4 +485,23 @@ ProFile::~ProFile()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProString ProFile::getStr(const ushort *&tPtr)
|
||||||
|
{
|
||||||
|
uint len = *tPtr++;
|
||||||
|
ProString ret(items(), tPtr - tokPtr(), len);
|
||||||
|
ret.setSource(this);
|
||||||
|
tPtr += len;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProKey ProFile::getHashStr(const ushort *&tPtr)
|
||||||
|
{
|
||||||
|
uint hash = *tPtr++;
|
||||||
|
hash |= (uint)*tPtr++ << 16;
|
||||||
|
uint len = *tPtr++;
|
||||||
|
ProKey ret(items(), tPtr - tokPtr(), len, hash);
|
||||||
|
tPtr += len;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -352,6 +352,9 @@ public:
|
|||||||
bool isHostBuild() const { return m_hostBuild; }
|
bool isHostBuild() const { return m_hostBuild; }
|
||||||
void setHostBuild(bool host_build) { m_hostBuild = host_build; }
|
void setHostBuild(bool host_build) { m_hostBuild = host_build; }
|
||||||
|
|
||||||
|
ProString getStr(const ushort *&tPtr);
|
||||||
|
ProKey getHashStr(const ushort *&tPtr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProItemRefCount m_refCount;
|
ProItemRefCount m_refCount;
|
||||||
QString m_proitems;
|
QString m_proitems;
|
||||||
|
@ -258,24 +258,6 @@ uint QMakeEvaluator::getBlockLen(const ushort *&tokPtr)
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProString QMakeEvaluator::getStr(const ushort *&tokPtr)
|
|
||||||
{
|
|
||||||
uint len = *tokPtr++;
|
|
||||||
ProString ret(m_current.pro->items(), tokPtr - m_current.pro->tokPtr(), len);
|
|
||||||
ret.setSource(m_current.pro);
|
|
||||||
tokPtr += len;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProKey QMakeEvaluator::getHashStr(const ushort *&tokPtr)
|
|
||||||
{
|
|
||||||
uint hash = getBlockLen(tokPtr);
|
|
||||||
uint len = *tokPtr++;
|
|
||||||
ProKey ret(m_current.pro->items(), tokPtr - m_current.pro->tokPtr(), len, hash);
|
|
||||||
tokPtr += len;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QMakeEvaluator::skipStr(const ushort *&tokPtr)
|
void QMakeEvaluator::skipStr(const ushort *&tokPtr)
|
||||||
{
|
{
|
||||||
uint len = *tokPtr++;
|
uint len = *tokPtr++;
|
||||||
@ -430,6 +412,7 @@ void QMakeEvaluator::evaluateExpression(
|
|||||||
const ushort *&tokPtr, ProStringList *ret, bool joined)
|
const ushort *&tokPtr, ProStringList *ret, bool joined)
|
||||||
{
|
{
|
||||||
debugMsg(2, joined ? "evaluating joined expression" : "evaluating expression");
|
debugMsg(2, joined ? "evaluating joined expression" : "evaluating expression");
|
||||||
|
ProFile *pro = m_current.pro;
|
||||||
if (joined)
|
if (joined)
|
||||||
*ret << ProString();
|
*ret << ProString();
|
||||||
bool pending = false;
|
bool pending = false;
|
||||||
@ -445,35 +428,35 @@ void QMakeEvaluator::evaluateExpression(
|
|||||||
m_current.line = *tokPtr++;
|
m_current.line = *tokPtr++;
|
||||||
break;
|
break;
|
||||||
case TokLiteral: {
|
case TokLiteral: {
|
||||||
const ProString &val = getStr(tokPtr);
|
const ProString &val = pro->getStr(tokPtr);
|
||||||
debugMsg(2, "literal %s", dbgStr(val));
|
debugMsg(2, "literal %s", dbgStr(val));
|
||||||
addStr(val, ret, pending, joined);
|
addStr(val, ret, pending, joined);
|
||||||
break; }
|
break; }
|
||||||
case TokHashLiteral: {
|
case TokHashLiteral: {
|
||||||
const ProKey &val = getHashStr(tokPtr);
|
const ProKey &val = pro->getHashStr(tokPtr);
|
||||||
debugMsg(2, "hashed literal %s", dbgStr(val.toString()));
|
debugMsg(2, "hashed literal %s", dbgStr(val.toString()));
|
||||||
addStr(val, ret, pending, joined);
|
addStr(val, ret, pending, joined);
|
||||||
break; }
|
break; }
|
||||||
case TokVariable: {
|
case TokVariable: {
|
||||||
const ProKey &var = getHashStr(tokPtr);
|
const ProKey &var = pro->getHashStr(tokPtr);
|
||||||
const ProStringList &val = values(map(var));
|
const ProStringList &val = values(map(var));
|
||||||
debugMsg(2, "variable %s => %s", dbgKey(var), dbgStrList(val));
|
debugMsg(2, "variable %s => %s", dbgKey(var), dbgStrList(val));
|
||||||
addStrList(val, tok, ret, pending, joined);
|
addStrList(val, tok, ret, pending, joined);
|
||||||
break; }
|
break; }
|
||||||
case TokProperty: {
|
case TokProperty: {
|
||||||
const ProKey &var = getHashStr(tokPtr);
|
const ProKey &var = pro->getHashStr(tokPtr);
|
||||||
const ProString &val = propertyValue(var);
|
const ProString &val = propertyValue(var);
|
||||||
debugMsg(2, "property %s => %s", dbgKey(var), dbgStr(val));
|
debugMsg(2, "property %s => %s", dbgKey(var), dbgStr(val));
|
||||||
addStr(val, ret, pending, joined);
|
addStr(val, ret, pending, joined);
|
||||||
break; }
|
break; }
|
||||||
case TokEnvVar: {
|
case TokEnvVar: {
|
||||||
const ProString &var = getStr(tokPtr);
|
const ProString &var = pro->getStr(tokPtr);
|
||||||
const ProString &val = ProString(m_option->getEnv(var.toQString(m_tmp1)));
|
const ProString &val = ProString(m_option->getEnv(var.toQString(m_tmp1)));
|
||||||
debugMsg(2, "env var %s => %s", dbgStr(var), dbgStr(val));
|
debugMsg(2, "env var %s => %s", dbgStr(var), dbgStr(val));
|
||||||
addStr(val, ret, pending, joined);
|
addStr(val, ret, pending, joined);
|
||||||
break; }
|
break; }
|
||||||
case TokFuncName: {
|
case TokFuncName: {
|
||||||
const ProKey &func = getHashStr(tokPtr);
|
const ProKey &func = pro->getHashStr(tokPtr);
|
||||||
debugMsg(2, "function %s", dbgKey(func));
|
debugMsg(2, "function %s", dbgKey(func));
|
||||||
addStrList(evaluateExpandFunction(func, tokPtr), tok, ret, pending, joined);
|
addStrList(evaluateExpandFunction(func, tokPtr), tok, ret, pending, joined);
|
||||||
break; }
|
break; }
|
||||||
@ -538,6 +521,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProBlock(
|
|||||||
{
|
{
|
||||||
traceMsg("entering block");
|
traceMsg("entering block");
|
||||||
ProStringList curr;
|
ProStringList curr;
|
||||||
|
ProFile *pro = m_current.pro;
|
||||||
bool okey = true, or_op = false, invert = false;
|
bool okey = true, or_op = false, invert = false;
|
||||||
uint blockLen;
|
uint blockLen;
|
||||||
while (ushort tok = *tokPtr++) {
|
while (ushort tok = *tokPtr++) {
|
||||||
@ -597,7 +581,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProBlock(
|
|||||||
blockLen = getBlockLen(tokPtr);
|
blockLen = getBlockLen(tokPtr);
|
||||||
ret = visitProBlock(tokPtr);
|
ret = visitProBlock(tokPtr);
|
||||||
} else if (okey != or_op) {
|
} else if (okey != or_op) {
|
||||||
const ProKey &variable = getHashStr(tokPtr);
|
const ProKey &variable = pro->getHashStr(tokPtr);
|
||||||
uint exprLen = getBlockLen(tokPtr);
|
uint exprLen = getBlockLen(tokPtr);
|
||||||
const ushort *exprPtr = tokPtr;
|
const ushort *exprPtr = tokPtr;
|
||||||
tokPtr += exprLen;
|
tokPtr += exprLen;
|
||||||
@ -617,7 +601,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProBlock(
|
|||||||
case TokTestDef:
|
case TokTestDef:
|
||||||
case TokReplaceDef:
|
case TokReplaceDef:
|
||||||
if (m_cumulative || okey != or_op) {
|
if (m_cumulative || okey != or_op) {
|
||||||
const ProKey &name = getHashStr(tokPtr);
|
const ProKey &name = pro->getHashStr(tokPtr);
|
||||||
blockLen = getBlockLen(tokPtr);
|
blockLen = getBlockLen(tokPtr);
|
||||||
visitProFunctionDef(tok, name, tokPtr);
|
visitProFunctionDef(tok, name, tokPtr);
|
||||||
traceMsg("defined %s function %s",
|
traceMsg("defined %s function %s",
|
||||||
|
@ -150,8 +150,6 @@ public:
|
|||||||
{ return b ? ReturnTrue : ReturnFalse; }
|
{ return b ? ReturnTrue : ReturnFalse; }
|
||||||
|
|
||||||
static ALWAYS_INLINE uint getBlockLen(const ushort *&tokPtr);
|
static ALWAYS_INLINE uint getBlockLen(const ushort *&tokPtr);
|
||||||
ProString getStr(const ushort *&tokPtr);
|
|
||||||
ProKey getHashStr(const ushort *&tokPtr);
|
|
||||||
void evaluateExpression(const ushort *&tokPtr, ProStringList *ret, bool joined);
|
void evaluateExpression(const ushort *&tokPtr, ProStringList *ret, bool joined);
|
||||||
static ALWAYS_INLINE void skipStr(const ushort *&tokPtr);
|
static ALWAYS_INLINE void skipStr(const ushort *&tokPtr);
|
||||||
static ALWAYS_INLINE void skipHashStr(const ushort *&tokPtr);
|
static ALWAYS_INLINE void skipHashStr(const ushort *&tokPtr);
|
||||||
|
Loading…
Reference in New Issue
Block a user