- enhancement: Auto type induction for new / temp class object.
This commit is contained in:
parent
0405a51206
commit
13e0393c8e
|
@ -4078,7 +4078,6 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic,
|
||||||
PEvalStatement(),
|
PEvalStatement(),
|
||||||
true,false);
|
true,false);
|
||||||
if(aliasStatement) {
|
if(aliasStatement) {
|
||||||
qDebug()<<phraseExpression<<aliasStatement->pointerLevel;
|
|
||||||
if (aliasStatement->effectiveTypeStatement) {
|
if (aliasStatement->effectiveTypeStatement) {
|
||||||
addedVar->type = aliasStatement->effectiveTypeStatement->fullName;
|
addedVar->type = aliasStatement->effectiveTypeStatement->fullName;
|
||||||
if (!addedVar->type.endsWith(">"))
|
if (!addedVar->type.endsWith(">"))
|
||||||
|
@ -4618,12 +4617,37 @@ PEvalStatement CppParser::doEvalExpression(const QString& fileName,
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return doEvalPointerArithmetic(fileName,
|
|
||||||
phraseExpression,
|
if (phraseExpression[pos] == "new") {
|
||||||
pos,
|
pos++;
|
||||||
scope,
|
if (pos>=phraseExpression.length())
|
||||||
previousResult,
|
return PEvalStatement();
|
||||||
freeScoped);
|
PEvalStatement result = doEvalExpression(
|
||||||
|
fileName,
|
||||||
|
phraseExpression,
|
||||||
|
pos,
|
||||||
|
scope,
|
||||||
|
previousResult,
|
||||||
|
freeScoped,
|
||||||
|
false);
|
||||||
|
if (result) {
|
||||||
|
if (pos < phraseExpression.length())
|
||||||
|
result = PEvalStatement();
|
||||||
|
else if (result->kind != EvalStatementKind::Variable) {
|
||||||
|
result = PEvalStatement();
|
||||||
|
} else {
|
||||||
|
result->pointerLevel++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} else
|
||||||
|
return doEvalPointerArithmetic(
|
||||||
|
fileName,
|
||||||
|
phraseExpression,
|
||||||
|
pos,
|
||||||
|
scope,
|
||||||
|
previousResult,
|
||||||
|
freeScoped);
|
||||||
}
|
}
|
||||||
|
|
||||||
PEvalStatement CppParser::doEvalPointerArithmetic(const QString &fileName, const QStringList &phraseExpression, int &pos, const PStatement &scope, const PEvalStatement &previousResult, bool freeScoped) const
|
PEvalStatement CppParser::doEvalPointerArithmetic(const QString &fileName, const QStringList &phraseExpression, int &pos, const PStatement &scope, const PEvalStatement &previousResult, bool freeScoped) const
|
||||||
|
@ -5170,11 +5194,8 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName,
|
||||||
if (token=="*") // for expression like (const * char)?
|
if (token=="*") // for expression like (const * char)?
|
||||||
pointerLevel++;
|
pointerLevel++;
|
||||||
else if (mCppTypeKeywords.contains(token)
|
else if (mCppTypeKeywords.contains(token)
|
||||||
|| !mCppKeywords.contains(token)) {
|
|| !mCppKeywords.contains(token))
|
||||||
break;
|
break;
|
||||||
} else if (token=="new") {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
if (pos>=phraseExpression.length() || phraseExpression[pos]==")")
|
if (pos>=phraseExpression.length() || phraseExpression[pos]==")")
|
||||||
|
@ -5183,12 +5204,6 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName,
|
||||||
result = doCreateEvalType(phraseExpression[pos]);
|
result = doCreateEvalType(phraseExpression[pos]);
|
||||||
pos++;
|
pos++;
|
||||||
} else if (isIdentifier(phraseExpression[pos])) {
|
} else if (isIdentifier(phraseExpression[pos])) {
|
||||||
bool isNew = (phraseExpression[pos] == "new");
|
|
||||||
if (isNew) {
|
|
||||||
pos++;
|
|
||||||
if (pos>=phraseExpression.length())
|
|
||||||
return PEvalStatement();
|
|
||||||
}
|
|
||||||
PStatement statement;
|
PStatement statement;
|
||||||
if (freeScoped) {
|
if (freeScoped) {
|
||||||
if (!previousResult) {
|
if (!previousResult) {
|
||||||
|
@ -5277,22 +5292,6 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (result && isNew) {
|
|
||||||
if (result->kind != EvalStatementKind::Type) {
|
|
||||||
return PEvalStatement();
|
|
||||||
} else {
|
|
||||||
if (pos >= phraseExpression.length())
|
|
||||||
return PEvalStatement();
|
|
||||||
if (phraseExpression[pos]=='{')
|
|
||||||
doSkipInExpression(phraseExpression,pos,"{","}");
|
|
||||||
else if (phraseExpression[pos]=='(')
|
|
||||||
doSkipInExpression(phraseExpression,pos,"(",")");
|
|
||||||
else
|
|
||||||
return PEvalStatement();
|
|
||||||
result->kind = EvalStatementKind::Variable;
|
|
||||||
result->pointerLevel++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (isIntegerLiteral(phraseExpression[pos])) {
|
} else if (isIntegerLiteral(phraseExpression[pos])) {
|
||||||
result = doCreateEvalLiteral("int");
|
result = doCreateEvalLiteral("int");
|
||||||
pos++;
|
pos++;
|
||||||
|
|
Loading…
Reference in New Issue