diff options
author | con <qtc-committer@nokia.com> | 2009-10-26 13:51:56 +0100 |
---|---|---|
committer | con <qtc-committer@nokia.com> | 2009-10-26 13:51:56 +0100 |
commit | 441ece365aba579eeb66acb509df466f5029c580 (patch) | |
tree | b4f8ac51e0203bad62c301f0c891b9246a15ad6a /src/shared/cplusplus | |
parent | 4504aec7deb2f0abcd6a71e094bbcfb4edd5154d (diff) | |
parent | 3c0ca8c18881bc26fd8946bc2651fa89b10a1329 (diff) | |
download | qt-creator-441ece365aba579eeb66acb509df466f5029c580.tar.gz |
Merge commit 'origin/1.3'
Conflicts:
src/plugins/cpptools/cppcodecompletion.h
src/plugins/debugger/gdb/gdbengine.cpp
src/plugins/qmleditor/QmlEditor.pluginspec
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r-- | src/shared/cplusplus/AST.h | 1 | ||||
-rw-r--r-- | src/shared/cplusplus/LiteralTable.h | 2 | ||||
-rw-r--r-- | src/shared/cplusplus/MemoryPool.cpp | 13 | ||||
-rw-r--r-- | src/shared/cplusplus/MemoryPool.h | 16 | ||||
-rw-r--r-- | src/shared/cplusplus/Parser.cpp | 55 | ||||
-rw-r--r-- | src/shared/cplusplus/Parser.h | 17 | ||||
-rw-r--r-- | src/shared/cplusplus/Symbols.cpp | 1 |
7 files changed, 102 insertions, 3 deletions
diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h index 05a78b0832..6dced425a7 100644 --- a/src/shared/cplusplus/AST.h +++ b/src/shared/cplusplus/AST.h @@ -64,6 +64,7 @@ class List: public Managed public: List() + : value(_Tp()), next(0) { } _Tp value; diff --git a/src/shared/cplusplus/LiteralTable.h b/src/shared/cplusplus/LiteralTable.h index 29de643002..52816a5682 100644 --- a/src/shared/cplusplus/LiteralTable.h +++ b/src/shared/cplusplus/LiteralTable.h @@ -175,8 +175,6 @@ protected: } protected: - MemoryPool *_pool; - _Literal **_literals; int _allocatedLiterals; int _literalCount; diff --git a/src/shared/cplusplus/MemoryPool.cpp b/src/shared/cplusplus/MemoryPool.cpp index 2002a65435..1453c62cd6 100644 --- a/src/shared/cplusplus/MemoryPool.cpp +++ b/src/shared/cplusplus/MemoryPool.cpp @@ -110,6 +110,19 @@ void *MemoryPool::allocate_helper(size_t size) return addr; } +MemoryPool::State MemoryPool::state() const +{ return State(ptr, _blockCount); } + +void MemoryPool::rewind(const State &state) +{ + if (_blockCount == state.blockCount && state.ptr < ptr) { + if (_initializeAllocatedMemory) + memset(state.ptr, '\0', ptr - state.ptr); + + ptr = state.ptr; + } +} + Managed::Managed() { } diff --git a/src/shared/cplusplus/MemoryPool.h b/src/shared/cplusplus/MemoryPool.h index e0f1ff8701..5b6fae925f 100644 --- a/src/shared/cplusplus/MemoryPool.h +++ b/src/shared/cplusplus/MemoryPool.h @@ -79,6 +79,22 @@ public: return allocate_helper(size); } + struct State + { + char *ptr; + char *end; + int blockCount; + + inline bool isValid() const + { return ptr != 0; } + + inline State(char *ptr = 0, int blockCount = 0) + : ptr(ptr), blockCount(blockCount) {} + }; + + State state() const; + void rewind(const State &state); + private: void *allocate_helper(size_t size); diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index 8f3bd549ce..835b2c11c8 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -88,6 +88,30 @@ int DebugRule::depth = 0; # define DEBUG_THIS_RULE() do {} while (0) #endif +class Parser::Rewind +{ + Parser *_parser; + MemoryPool::State _state; + +public: + inline Rewind(Parser *parser) + : _parser(parser) {} + + inline void operator()(unsigned tokenIndex) + { rewind(tokenIndex); } + + inline void mark() + { _state = _parser->_pool->state(); } + + inline void rewind(unsigned tokenIndex) + { + _parser->rewind(tokenIndex); + + if (_state.isValid()) + _parser->_pool->rewind(_state); + } +}; + Parser::Parser(TranslationUnit *unit) : _translationUnit(unit), _control(_translationUnit->control()), @@ -302,6 +326,9 @@ bool Parser::parseClassOrNamespaceName(NameAST *&node) bool Parser::parseTemplateId(NameAST *&node) { DEBUG_THIS_RULE(); + + const unsigned start = cursor(); + if (LA() == T_IDENTIFIER && LA(2) == T_LESS) { TemplateIdAST *ast = new (_pool) TemplateIdAST; ast->identifier_token = consumeToken(); @@ -315,6 +342,9 @@ bool Parser::parseTemplateId(NameAST *&node) } } } + + rewind(start); + return false; } @@ -660,8 +690,27 @@ bool Parser::parseOperatorFunctionId(NameAST *&node) return true; } +Parser::TemplateArgumentListEntry *Parser::templateArgumentListEntry(unsigned tokenIndex) +{ + for (unsigned i = 0; i < _templateArgumentList.size(); ++i) { + TemplateArgumentListEntry *entry = &_templateArgumentList[i]; + if (entry->index == tokenIndex) + return entry; + } + + return 0; +} + bool Parser::parseTemplateArgumentList(TemplateArgumentListAST *&node) { + if (TemplateArgumentListEntry *entry = templateArgumentListEntry(cursor())) { + rewind(entry->cursor); + node = entry->ast; + return entry->ast != 0; + } + + unsigned start = cursor(); + DEBUG_THIS_RULE(); TemplateArgumentListAST **template_argument_ptr = &node; ExpressionAST *template_argument = 0; @@ -679,8 +728,13 @@ bool Parser::parseTemplateArgumentList(TemplateArgumentListAST *&node) template_argument_ptr = &(*template_argument_ptr)->next; } } + + _templateArgumentList.push_back(TemplateArgumentListEntry(start, cursor(), node)); return true; } + + _templateArgumentList.push_back(TemplateArgumentListEntry(start, cursor(), 0)); + return false; } @@ -4541,6 +4595,7 @@ bool Parser::parseObjCMethodDefinitionList(DeclarationListAST *&node) last->next = new (_pool) ObjCSynthesizedPropertyListAST; last = last->next; + last->synthesized_property = new (_pool) ObjCSynthesizedPropertyAST; match(T_IDENTIFIER, &(last->synthesized_property->property_identifier)); if (LA() == T_EQUAL) { diff --git a/src/shared/cplusplus/Parser.h b/src/shared/cplusplus/Parser.h index 3ca3371d81..d9ccf6ab49 100644 --- a/src/shared/cplusplus/Parser.h +++ b/src/shared/cplusplus/Parser.h @@ -54,7 +54,6 @@ #include "Token.h" #include "TranslationUnit.h" - namespace CPlusPlus { class CPLUSPLUS_EXPORT Parser @@ -287,6 +286,17 @@ private: inline void rewind(unsigned cursor) { _tokenIndex = cursor; } + struct TemplateArgumentListEntry { + unsigned index; + unsigned cursor; + TemplateArgumentListAST *ast; + + TemplateArgumentListEntry(unsigned index = 0, unsigned cursor = 0, TemplateArgumentListAST *ast = 0) + : index(index), cursor(cursor), ast(ast) {} + }; + + TemplateArgumentListEntry *templateArgumentListEntry(unsigned tokenIndex); + private: TranslationUnit *_translationUnit; Control *_control; @@ -298,6 +308,11 @@ private: bool _inFunctionBody: 1; bool _inObjCImplementationContext: 1; + Array<TemplateArgumentListEntry> _templateArgumentList; + + class Rewind; + friend class Rewind; + private: Parser(const Parser& source); void operator =(const Parser& source); diff --git a/src/shared/cplusplus/Symbols.cpp b/src/shared/cplusplus/Symbols.cpp index aa15735410..8ddaf3ef5d 100644 --- a/src/shared/cplusplus/Symbols.cpp +++ b/src/shared/cplusplus/Symbols.cpp @@ -589,6 +589,7 @@ void ObjCBaseProtocol::visitSymbol0(SymbolVisitor *visitor) ObjCClass::ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name): ScopedSymbol(translationUnit, sourceLocation, name), + _isInterface(false), _categoryName(0), _baseClass(0) { |