diff --git a/NEWS.md b/NEWS.md index 09b168cf..da86628b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +Version 0.8.6 For Dev-C++ 7 Beta + - enhancement: greatly reduces memory usage for symbol parsing ( memory needed for bits/stdc++.h reduced from 150m+ to 50m+) + - fix: currect compiler set not correctly updated when switch between normal file and project file + Version 0.8.5 For Dev-C++ 7 Beta - enhancement: use lighter color to draw menu seperators - enhancement: differentiate selected and unselected tab bars diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 396f7314..f9e93de8 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -91,7 +91,7 @@ MainWindow::MainWindow(QWidget *parent) ui->toolbarCompilerSet->addWidget(mCompilerSet); connect(mCompilerSet,QOverload::of(&QComboBox::currentIndexChanged), this, &MainWindow::onCompilerSetChanged); - updateCompilerSet(); + //updateCompilerSet(); mCompilerManager = new CompilerManager(this); mDebugger = new Debugger(this); @@ -399,7 +399,7 @@ void MainWindow::updateEditorActions() } updateCompileActions(); - + updateCompilerSet(); } void MainWindow::updateProjectActions() diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 23a2194c..a1be379e 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -61,9 +61,9 @@ void CppParser::addHardDefineByLine(const QString &line) { QMutexLocker locker(&mMutex); if (line.startsWith('#')) { - mPreprocessor.addDefineByLine(line.mid(1).trimmed(), true); + mPreprocessor.addHardDefineByLine(line.mid(1).trimmed()); } else { - mPreprocessor.addDefineByLine(line, true); + mPreprocessor.addHardDefineByLine(line); } } @@ -3127,9 +3127,16 @@ void CppParser::internalParse(const QString &fileName) mPreprocessor.setScanOptions(mParseGlobalHeaders, mParseLocalHeaders); mPreprocessor.preprocess(fileName, buffer); + QStringList prerocessResult = mPreprocessor.result(); + mPreprocessor.clearResult(); +#ifdef QT_DEBUG +// StringsToFile(mPreprocessor.result(),"f:\\preprocess.txt"); +// mPreprocessor.dumpDefinesTo("f:\\defines.txt"); +// mPreprocessor.dumpIncludesListTo("f:\\includes.txt"); +#endif // Tokenize the preprocessed buffer file - mTokenizer.tokenize(mPreprocessor.result()); + mTokenizer.tokenize(prerocessResult); if (mTokenizer.tokenCount() == 0) return; @@ -3147,13 +3154,11 @@ void CppParser::internalParse(const QString &fileName) break; } #ifdef QT_DEBUG -// StringsToFile(mPreprocessor.result(),"f:\\preprocess.txt"); -// mPreprocessor.dumpDefinesTo("f:\\defines.txt"); -// mPreprocessor.dumpIncludesListTo("f:\\includes.txt"); -// mStatementList.dump("f:\\stats.txt"); // mTokenizer.dumpTokens("f:\\tokens.txt"); +// mStatementList.dump("f:\\stats.txt"); // mStatementList.dumpAll("f:\\all-stats.txt"); #endif + mTokenizer.reset(); } } diff --git a/RedPandaIDE/parser/cpppreprocessor.cpp b/RedPandaIDE/parser/cpppreprocessor.cpp index 6967394b..b45b1fbb 100644 --- a/RedPandaIDE/parser/cpppreprocessor.cpp +++ b/RedPandaIDE/parser/cpppreprocessor.cpp @@ -22,6 +22,18 @@ void CppPreprocessor::clear() mCurrentIncludes.reset(); } +void CppPreprocessor::clearResult() +{ + mFileName.clear(); + mBuffer.clear(); + mResult.clear(); + mCurrentIncludes = nullptr; + mIncludes.clear(); // stack of files we've stepped into. last one is current file, first one is source file + mBranchResults.clear();// stack of branch results (boolean). last one is current branch, first one is outermost branch + mDefines.clear(); // working set, editable + mProcessed.clear(); // dictionary to save filename already processed +} + void CppPreprocessor::addDefineByParts(const QString &name, const QString &args, const QString &value, bool hardCoded) { // Check for duplicates @@ -91,6 +103,11 @@ void CppPreprocessor::getDefineParts(const QString &input, QString &name, QStrin value = removeGCCAttributes(s.mid(i+1).trimmed()); } +void CppPreprocessor::addHardDefineByLine(const QString &line) +{ + addDefineByLine(line,true); +} + void CppPreprocessor::addDefineByLine(const QString &line, bool hardCoded) { // Remove define diff --git a/RedPandaIDE/parser/cpppreprocessor.h b/RedPandaIDE/parser/cpppreprocessor.h index 2526bb07..1addf7ba 100644 --- a/RedPandaIDE/parser/cpppreprocessor.h +++ b/RedPandaIDE/parser/cpppreprocessor.h @@ -46,17 +46,12 @@ public: explicit CppPreprocessor(); void clear(); - void addDefineByParts(const QString& name, const QString& args, - const QString& value, bool hardCoded); + void clearResult(); void getDefineParts(const QString& input, QString &name, QString &args, QString &value); - void addDefineByLine(const QString& line, bool hardCoded); - PDefine getDefine(const QString& name); - PDefine getHardDefine(const QString& name); + void addHardDefineByLine(const QString& line); void reset(); //reset but don't clear generated defines - void resetDefines(); void setScanOptions(bool parseSystem, bool parseLocal); void preprocess(const QString& fileName, QStringList buffer = QStringList()); - void invalidDefinesInFile(const QString& fileName); void dumpDefinesTo(const QString& fileName) const; void dumpIncludesListTo(const QString& fileName) const; @@ -97,7 +92,7 @@ private: void expandMacro(const QString& line, QString& newLine, QString& word, int& i, int depth); QString removeGCCAttributes(const QString& line); void removeGCCAttribute(const QString&line, QString& newLine, int &i, const QString& word); - + PDefine getDefine(const QString& name); // current file stuff PParsedFile getInclude(int index); void openInclude(const QString& fileName, QStringList bufferedText=QStringList()); @@ -110,6 +105,12 @@ private: // include stuff PFileIncludes getFileIncludesEntry(const QString& FileName); void addDefinesInFile(const QString& fileName); + void resetDefines(); + void addDefineByParts(const QString& name, const QString& args, + const QString& value, bool hardCoded); + void addDefineByLine(const QString& line, bool hardCoded); + PDefine getHardDefine(const QString& name); + void invalidDefinesInFile(const QString& fileName); void parseArgs(PDefine define); QList tokenizeValue(const QString& value); @@ -181,24 +182,26 @@ private: QStringList mResult; PFileIncludes mCurrentIncludes; int mPreProcIndex; - QHash mIncludesList; - DefineMap mHardDefines; // set by "cpp -dM -E -xc NUL" - DefineMap mDefines; // working set, editable - QHash mFileDefines; //dictionary to save defines for each headerfile; QList mIncludes; // stack of files we've stepped into. last one is current file, first one is source file QList mBranchResults;// stack of branch results (boolean). last one is current branch, first one is outermost branch - //{ List of current compiler set's include path} - QSet mIncludePaths; + DefineMap mDefines; // working set, editable + QSet mProcessed; // dictionary to save filename already processed + + //used by parser even preprocess finished + DefineMap mHardDefines; // set by "cpp -dM -E -xc NUL" + QHash mIncludesList; + QHash mFileDefines; //dictionary to save defines for each headerfile; //{ List of current project's include path } QSet mProjectIncludePaths; //we also need include paths in order (for #include_next) QList mIncludePathList; QList mProjectIncludePathList; + //{ List of current compiler set's include path} + QSet mIncludePaths; bool mParseSystem; bool mParseLocal; QSet mScannedFiles; - QSet mProcessed; // dictionary to save filename already processed }; #endif // CPPPREPROCESSOR_H