From 1f6ef884e6de79e21f456e8b8f5dc2bb0fb4e857 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 2 Jun 2024 18:57:52 +0800 Subject: [PATCH] - enhancement: Support operator() overload. --- NEWS.md | 1 + RedPandaIDE/parser/cppparser.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/NEWS.md b/NEWS.md index 82bbedba..f522bab5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,6 +15,7 @@ Red Panda C++ Version 3.1 - fix: Mingw32-make doesn't work correctly if there are bash in the path. - fix: All color scheme names are incorrectly displayed as bold, if the current one is a customed one. - fix: Variables defined by using alias can't show completion info. + - enhancement: Support operator() overload. Red Panda C++ Version 3.0 diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 84bea986..66da1f92 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -5127,6 +5127,24 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName, // if (result->effectiveTypeStatement) // qDebug()<<"typeStatement"<effectiveTypeStatement->fullName; result->kind = EvalStatementKind::Variable; + } else if(result->kind == EvalStatementKind::Variable + && result->effectiveTypeStatement + && result->effectiveTypeStatement->kind == StatementKind::Class) { + //overload of operator () + const StatementMap& statementMap = mStatementList.childrenStatements(result->effectiveTypeStatement); + if (statementMap.isEmpty()) + result = PEvalStatement(); + else { + PStatement operStatement = statementMap.value("operator()"); + if (operStatement) { + doSkipInExpression(phraseExpression,pos,"(",")"); + PEvalStatement temp = doCreateEvalFunction(fileName,operStatement); + result->effectiveTypeStatement = temp->effectiveTypeStatement; + result->kind = EvalStatementKind::Variable; + } else { + result = PEvalStatement(); + } + } } else { result = PEvalStatement(); }