work save
This commit is contained in:
parent
e8644dfd0b
commit
63d0321fcf
|
@ -3360,12 +3360,61 @@ PEvalStatement CppParser::doEvalExpression(const QString& fileName,
|
||||||
bool freeScoped)
|
bool freeScoped)
|
||||||
{
|
{
|
||||||
//dummy function to easy later upgrades
|
//dummy function to easy later upgrades
|
||||||
return doEvalPointerToMembers(fileName,
|
return doEvalPointerArithmetic(fileName,
|
||||||
phraseExpression,
|
phraseExpression,
|
||||||
pos,
|
pos,
|
||||||
scope,
|
scope,
|
||||||
previousResult,
|
previousResult,
|
||||||
freeScoped);
|
freeScoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
PEvalStatement CppParser::doEvalPointerArithmetic(const QString &fileName, const QStringList &phraseExpression, int &pos, const PStatement &scope, const PEvalStatement &previousResult, bool freeScoped)
|
||||||
|
{
|
||||||
|
if (pos>=phraseExpression.length())
|
||||||
|
return PEvalStatement();
|
||||||
|
//find the start scope statement
|
||||||
|
PEvalStatement currentResult = doEvalPointerToMembers(
|
||||||
|
fileName,
|
||||||
|
phraseExpression,
|
||||||
|
pos,
|
||||||
|
scope,
|
||||||
|
previousResult,
|
||||||
|
freeScoped);
|
||||||
|
while (pos < phraseExpression.length()) {
|
||||||
|
if (!currentResult)
|
||||||
|
break;
|
||||||
|
if (currentResult &&
|
||||||
|
(phraseExpression[pos]=="+"
|
||||||
|
|| phraseExpression[pos]=="-")) {
|
||||||
|
if (currentResult->kind == EvalStatementKind::Variable) {
|
||||||
|
pos++;
|
||||||
|
PEvalStatement op2=doEvalPointerToMembers(
|
||||||
|
fileName,
|
||||||
|
phraseExpression,
|
||||||
|
pos,
|
||||||
|
scope,
|
||||||
|
currentResult,
|
||||||
|
false);
|
||||||
|
//todo operator+/- overload
|
||||||
|
} else if (currentResult->kind == EvalStatementKind::Literal
|
||||||
|
&& currentResult->baseType == "int") {
|
||||||
|
pos++;
|
||||||
|
PEvalStatement op2=doEvalPointerToMembers(
|
||||||
|
fileName,
|
||||||
|
phraseExpression,
|
||||||
|
pos,
|
||||||
|
scope,
|
||||||
|
currentResult,
|
||||||
|
false);
|
||||||
|
currentResult = op2;
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
qDebug()<<pos<<"pointer add member end";
|
||||||
|
return currentResult;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PEvalStatement CppParser::doEvalPointerToMembers(
|
PEvalStatement CppParser::doEvalPointerToMembers(
|
||||||
|
@ -3611,13 +3660,32 @@ PEvalStatement CppParser::doEvalScopeResolution(const QString &fileName,
|
||||||
if (phraseExpression[pos]=="::" ) {
|
if (phraseExpression[pos]=="::" ) {
|
||||||
pos++;
|
pos++;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
//global scope
|
//global
|
||||||
|
result = doEvalTerm(fileName,
|
||||||
|
phraseExpression,
|
||||||
|
pos,
|
||||||
|
PStatement(),
|
||||||
|
PEvalStatement(),
|
||||||
|
false);
|
||||||
} else if (result->kind == EvalStatementKind::Type) {
|
} else if (result->kind == EvalStatementKind::Type) {
|
||||||
//static member
|
//class static member
|
||||||
|
result = doEvalTerm(fileName,
|
||||||
|
phraseExpression,
|
||||||
|
pos,
|
||||||
|
scope,
|
||||||
|
result,
|
||||||
|
false);
|
||||||
} else if (result->kind == EvalStatementKind::Namespace) {
|
} else if (result->kind == EvalStatementKind::Namespace) {
|
||||||
|
//namespace
|
||||||
} else
|
result = doEvalTerm(fileName,
|
||||||
result = PEvalStatement();
|
phraseExpression,
|
||||||
|
pos,
|
||||||
|
scope,
|
||||||
|
result,
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
if (!result)
|
||||||
|
break;
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3724,15 +3792,19 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName,
|
||||||
}
|
}
|
||||||
} else if (isIntegerLiteral(phraseExpression[pos])) {
|
} else if (isIntegerLiteral(phraseExpression[pos])) {
|
||||||
result = doCreateEvalLiteral("int");
|
result = doCreateEvalLiteral("int");
|
||||||
|
pos++;
|
||||||
} else if (isFloatLiteral(phraseExpression[pos])) {
|
} else if (isFloatLiteral(phraseExpression[pos])) {
|
||||||
result = doCreateEvalLiteral("double");
|
result = doCreateEvalLiteral("double");
|
||||||
|
pos++;
|
||||||
} else if (isStringLiteral(phraseExpression[pos])) {
|
} else if (isStringLiteral(phraseExpression[pos])) {
|
||||||
result = doCreateEvalLiteral("char");
|
result = doCreateEvalLiteral("char");
|
||||||
result->pointerLevel = 1;
|
result->pointerLevel = 1;
|
||||||
|
pos++;
|
||||||
} else if (isCharLiteral(phraseExpression[pos])) {
|
} else if (isCharLiteral(phraseExpression[pos])) {
|
||||||
result = doCreateEvalLiteral("char");
|
result = doCreateEvalLiteral("char");
|
||||||
|
pos++;
|
||||||
} else
|
} else
|
||||||
result = PEvalStatement();
|
return result;
|
||||||
if (result) {
|
if (result) {
|
||||||
qDebug()<<"term kind:"<<(int)result->kind;
|
qDebug()<<"term kind:"<<(int)result->kind;
|
||||||
}
|
}
|
||||||
|
@ -3933,11 +4005,13 @@ PStatement CppParser::doParseEvalTypeInfo(
|
||||||
pointerLevel--;
|
pointerLevel--;
|
||||||
else if (highlighter.getTokenAttribute() == highlighter.identifierAttribute()) {
|
else if (highlighter.getTokenAttribute() == highlighter.identifierAttribute()) {
|
||||||
if (token!= "const")
|
if (token!= "const")
|
||||||
baseType = token;
|
baseType += token;
|
||||||
} else if (token == "[") {
|
} else if (token == "[") {
|
||||||
bracketLevel++;
|
bracketLevel++;
|
||||||
} else if (token == "<") {
|
} else if (token == "<") {
|
||||||
templateLevel++;
|
templateLevel++;
|
||||||
|
} else if (token == "::") {
|
||||||
|
baseType += token;
|
||||||
}
|
}
|
||||||
} else if (bracketLevel > 0) {
|
} else if (bracketLevel > 0) {
|
||||||
if (token == "[") {
|
if (token == "[") {
|
||||||
|
|
|
@ -227,6 +227,13 @@ private:
|
||||||
const PEvalStatement& previousResult,
|
const PEvalStatement& previousResult,
|
||||||
bool freeScoped);
|
bool freeScoped);
|
||||||
|
|
||||||
|
PEvalStatement doEvalPointerArithmetic(
|
||||||
|
const QString& fileName,
|
||||||
|
const QStringList& phraseExpression,
|
||||||
|
int &pos,
|
||||||
|
const PStatement& scope,
|
||||||
|
const PEvalStatement& previousResult,
|
||||||
|
bool freeScoped);
|
||||||
PEvalStatement doEvalPointerToMembers(
|
PEvalStatement doEvalPointerToMembers(
|
||||||
const QString& fileName,
|
const QString& fileName,
|
||||||
const QStringList& phraseExpression,
|
const QStringList& phraseExpression,
|
||||||
|
|
Loading…
Reference in New Issue