forked from qt-creator/qt-creator
Merge commit 'origin/1.3'
Conflicts: src/plugins/cpptools/cppcodecompletion.h src/plugins/debugger/gdb/gdbengine.cpp src/plugins/qmleditor/QmlEditor.pluginspec
This commit is contained in:
@@ -64,6 +64,7 @@ class List: public Managed
|
||||
|
||||
public:
|
||||
List()
|
||||
: value(_Tp()), next(0)
|
||||
{ }
|
||||
|
||||
_Tp value;
|
||||
|
||||
@@ -175,8 +175,6 @@ protected:
|
||||
}
|
||||
|
||||
protected:
|
||||
MemoryPool *_pool;
|
||||
|
||||
_Literal **_literals;
|
||||
int _allocatedLiterals;
|
||||
int _literalCount;
|
||||
|
||||
@@ -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()
|
||||
{ }
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user