forked from qt-creator/qt-creator
More annotations.
This commit is contained in:
@@ -60,6 +60,20 @@
|
|||||||
CPLUSPLUS_BEGIN_HEADER
|
CPLUSPLUS_BEGIN_HEADER
|
||||||
CPLUSPLUS_BEGIN_NAMESPACE
|
CPLUSPLUS_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
template <typename _Tp>
|
||||||
|
class List: public Managed
|
||||||
|
{
|
||||||
|
List(const List &other);
|
||||||
|
void operator =(const List &other);
|
||||||
|
|
||||||
|
public:
|
||||||
|
List()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
_Tp value;
|
||||||
|
List *next;
|
||||||
|
};
|
||||||
|
|
||||||
class CPLUSPLUS_EXPORT AST: public Managed
|
class CPLUSPLUS_EXPORT AST: public Managed
|
||||||
{
|
{
|
||||||
AST(const AST &other);
|
AST(const AST &other);
|
||||||
@@ -351,6 +365,9 @@ public:
|
|||||||
DeclaratorListAST *declarators;
|
DeclaratorListAST *declarators;
|
||||||
unsigned semicolon_token;
|
unsigned semicolon_token;
|
||||||
|
|
||||||
|
public:
|
||||||
|
List<Declaration *> *symbols;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual unsigned firstToken() const;
|
virtual unsigned firstToken() const;
|
||||||
virtual unsigned lastToken() const;
|
virtual unsigned lastToken() const;
|
||||||
@@ -423,7 +440,7 @@ public:
|
|||||||
BaseSpecifierAST *next;
|
BaseSpecifierAST *next;
|
||||||
|
|
||||||
public: // annotations
|
public: // annotations
|
||||||
BaseClass *base_class_symbol;
|
BaseClass *symbol;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual unsigned firstToken() const;
|
virtual unsigned firstToken() const;
|
||||||
@@ -519,7 +536,7 @@ public:
|
|||||||
unsigned rbrace_token;
|
unsigned rbrace_token;
|
||||||
|
|
||||||
public: // annotations
|
public: // annotations
|
||||||
Class *class_symbol;
|
Class *symbol;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual unsigned firstToken() const;
|
virtual unsigned firstToken() const;
|
||||||
@@ -921,6 +938,9 @@ public:
|
|||||||
CtorInitializerAST *ctor_initializer;
|
CtorInitializerAST *ctor_initializer;
|
||||||
StatementAST *function_body;
|
StatementAST *function_body;
|
||||||
|
|
||||||
|
public: // annotations
|
||||||
|
Function *symbol;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual unsigned firstToken() const;
|
virtual unsigned firstToken() const;
|
||||||
virtual unsigned lastToken() const;
|
virtual unsigned lastToken() const;
|
||||||
@@ -1195,7 +1215,7 @@ public:
|
|||||||
DeclarationAST *linkage_body;
|
DeclarationAST *linkage_body;
|
||||||
|
|
||||||
public: // annotations
|
public: // annotations
|
||||||
Namespace *namespace_symbol;
|
Namespace *symbol;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual unsigned firstToken() const;
|
virtual unsigned firstToken() const;
|
||||||
@@ -1321,6 +1341,9 @@ public:
|
|||||||
unsigned equal_token;
|
unsigned equal_token;
|
||||||
ExpressionAST *expression;
|
ExpressionAST *expression;
|
||||||
|
|
||||||
|
public: // annotations
|
||||||
|
Argument *symbol;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual unsigned firstToken() const;
|
virtual unsigned firstToken() const;
|
||||||
virtual unsigned lastToken() const;
|
virtual unsigned lastToken() const;
|
||||||
@@ -1858,6 +1881,9 @@ public:
|
|||||||
unsigned equal_token;
|
unsigned equal_token;
|
||||||
ExpressionAST *type_id;
|
ExpressionAST *type_id;
|
||||||
|
|
||||||
|
public: // annotations
|
||||||
|
Argument *symbol;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual unsigned firstToken() const;
|
virtual unsigned firstToken() const;
|
||||||
virtual unsigned lastToken() const;
|
virtual unsigned lastToken() const;
|
||||||
@@ -1880,6 +1906,9 @@ public:
|
|||||||
unsigned equal_token;
|
unsigned equal_token;
|
||||||
ExpressionAST *type_id;
|
ExpressionAST *type_id;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Argument *symbol;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual unsigned firstToken() const;
|
virtual unsigned firstToken() const;
|
||||||
virtual unsigned lastToken() const;
|
virtual unsigned lastToken() const;
|
||||||
@@ -1914,6 +1943,9 @@ public:
|
|||||||
NameAST *name;
|
NameAST *name;
|
||||||
unsigned semicolon_token;
|
unsigned semicolon_token;
|
||||||
|
|
||||||
|
public: // annotations
|
||||||
|
UsingDeclaration *symbol;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual unsigned firstToken() const;
|
virtual unsigned firstToken() const;
|
||||||
virtual unsigned lastToken() const;
|
virtual unsigned lastToken() const;
|
||||||
@@ -1932,6 +1964,9 @@ public:
|
|||||||
NameAST *name;
|
NameAST *name;
|
||||||
unsigned semicolon_token;
|
unsigned semicolon_token;
|
||||||
|
|
||||||
|
public:
|
||||||
|
UsingNamespaceDirective *symbol;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual unsigned firstToken() const;
|
virtual unsigned firstToken() const;
|
||||||
virtual unsigned lastToken() const;
|
virtual unsigned lastToken() const;
|
||||||
|
@@ -136,6 +136,7 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Declaration *> **decl_it = &ast->symbols;
|
||||||
for (DeclaratorListAST *it = ast->declarators; it; it = it->next) {
|
for (DeclaratorListAST *it = ast->declarators; it; it = it->next) {
|
||||||
Name *name = 0;
|
Name *name = 0;
|
||||||
FullySpecifiedType declTy = semantic()->check(it->declarator, qualTy,
|
FullySpecifiedType declTy = semantic()->check(it->declarator, qualTy,
|
||||||
@@ -179,6 +180,10 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
|
|||||||
else if (ty.isTypedef())
|
else if (ty.isTypedef())
|
||||||
symbol->setStorage(Symbol::Typedef);
|
symbol->setStorage(Symbol::Typedef);
|
||||||
|
|
||||||
|
*decl_it = new (translationUnit()->memoryPool()) List<Declaration *>();
|
||||||
|
(*decl_it)->value = symbol;
|
||||||
|
decl_it = &(*decl_it)->next;
|
||||||
|
|
||||||
_scope->enterSymbol(symbol);
|
_scope->enterSymbol(symbol);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -234,6 +239,7 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast)
|
|||||||
|
|
||||||
checkFunctionArguments(fun);
|
checkFunctionArguments(fun);
|
||||||
|
|
||||||
|
ast->symbol = fun;
|
||||||
_scope->enterSymbol(fun);
|
_scope->enterSymbol(fun);
|
||||||
|
|
||||||
if (ast->ctor_initializer) {
|
if (ast->ctor_initializer) {
|
||||||
@@ -286,7 +292,7 @@ bool CheckDeclaration::visit(NamespaceAST *ast)
|
|||||||
Identifier *id = identifier(ast->identifier_token);
|
Identifier *id = identifier(ast->identifier_token);
|
||||||
Name *namespaceName = control()->nameId(id);
|
Name *namespaceName = control()->nameId(id);
|
||||||
Namespace *ns = control()->newNamespace(ast->firstToken(), namespaceName);
|
Namespace *ns = control()->newNamespace(ast->firstToken(), namespaceName);
|
||||||
ast->namespace_symbol = ns;
|
ast->symbol = ns;
|
||||||
_scope->enterSymbol(ns);
|
_scope->enterSymbol(ns);
|
||||||
semantic()->check(ast->linkage_body, ns->members()); // ### we'll do the merge later.
|
semantic()->check(ast->linkage_body, ns->members()); // ### we'll do the merge later.
|
||||||
|
|
||||||
@@ -311,6 +317,7 @@ bool CheckDeclaration::visit(ParameterDeclarationAST *ast)
|
|||||||
_scope, &argName);
|
_scope, &argName);
|
||||||
FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
|
FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
|
||||||
Argument *arg = control()->newArgument(ast->firstToken(), argName);
|
Argument *arg = control()->newArgument(ast->firstToken(), argName);
|
||||||
|
ast->symbol = arg;
|
||||||
if (ast->expression)
|
if (ast->expression)
|
||||||
arg->setInitializer(true);
|
arg->setInitializer(true);
|
||||||
arg->setType(argTy);
|
arg->setType(argTy);
|
||||||
@@ -320,15 +327,6 @@ bool CheckDeclaration::visit(ParameterDeclarationAST *ast)
|
|||||||
|
|
||||||
bool CheckDeclaration::visit(TemplateDeclarationAST *ast)
|
bool CheckDeclaration::visit(TemplateDeclarationAST *ast)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
Template *templ = control()->newTemplate(ast->firstToken());
|
|
||||||
|
|
||||||
for (DeclarationAST *param = ast->template_parameters; param;
|
|
||||||
param = param->next) {
|
|
||||||
semantic()->check(param, templ->members());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
Scope *previousScope = switchScope(new Scope(_scope->owner()));
|
Scope *previousScope = switchScope(new Scope(_scope->owner()));
|
||||||
for (DeclarationAST *param = ast->template_parameters; param;
|
for (DeclarationAST *param = ast->template_parameters; param;
|
||||||
param = param->next) {
|
param = param->next) {
|
||||||
@@ -344,6 +342,7 @@ bool CheckDeclaration::visit(TypenameTypeParameterAST *ast)
|
|||||||
{
|
{
|
||||||
Name *name = semantic()->check(ast->name, _scope);
|
Name *name = semantic()->check(ast->name, _scope);
|
||||||
Argument *arg = control()->newArgument(ast->firstToken(), name); // ### new template type
|
Argument *arg = control()->newArgument(ast->firstToken(), name); // ### new template type
|
||||||
|
ast->symbol = arg;
|
||||||
_scope->enterSymbol(arg);
|
_scope->enterSymbol(arg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -352,6 +351,7 @@ bool CheckDeclaration::visit(TemplateTypeParameterAST *ast)
|
|||||||
{
|
{
|
||||||
Name *name = semantic()->check(ast->name, _scope);
|
Name *name = semantic()->check(ast->name, _scope);
|
||||||
Argument *arg = control()->newArgument(ast->firstToken(), name); // ### new template type
|
Argument *arg = control()->newArgument(ast->firstToken(), name); // ### new template type
|
||||||
|
ast->symbol = arg;
|
||||||
_scope->enterSymbol(arg);
|
_scope->enterSymbol(arg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -360,6 +360,7 @@ bool CheckDeclaration::visit(UsingAST *ast)
|
|||||||
{
|
{
|
||||||
Name *name = semantic()->check(ast->name, _scope);
|
Name *name = semantic()->check(ast->name, _scope);
|
||||||
UsingDeclaration *u = control()->newUsingDeclaration(ast->firstToken(), name);
|
UsingDeclaration *u = control()->newUsingDeclaration(ast->firstToken(), name);
|
||||||
|
ast->symbol = u;
|
||||||
_scope->enterSymbol(u);
|
_scope->enterSymbol(u);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -368,6 +369,7 @@ bool CheckDeclaration::visit(UsingDirectiveAST *ast)
|
|||||||
{
|
{
|
||||||
Name *name = semantic()->check(ast->name, _scope);
|
Name *name = semantic()->check(ast->name, _scope);
|
||||||
UsingNamespaceDirective *u = control()->newUsingNamespaceDirective(ast->firstToken(), name);
|
UsingNamespaceDirective *u = control()->newUsingNamespaceDirective(ast->firstToken(), name);
|
||||||
|
ast->symbol = u;
|
||||||
_scope->enterSymbol(u);
|
_scope->enterSymbol(u);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -300,7 +300,7 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
|
|||||||
{
|
{
|
||||||
Name *className = semantic()->check(ast->name, _scope);
|
Name *className = semantic()->check(ast->name, _scope);
|
||||||
Class *klass = control()->newClass(ast->firstToken(), className);
|
Class *klass = control()->newClass(ast->firstToken(), className);
|
||||||
ast->class_symbol = klass;
|
ast->symbol = klass;
|
||||||
unsigned classKey = tokenKind(ast->classkey_token);
|
unsigned classKey = tokenKind(ast->classkey_token);
|
||||||
if (classKey == T_CLASS)
|
if (classKey == T_CLASS)
|
||||||
klass->setClassKey(Class::ClassKey);
|
klass->setClassKey(Class::ClassKey);
|
||||||
@@ -315,7 +315,7 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
|
|||||||
for (BaseSpecifierAST *base = ast->base_clause; base; base = base->next) {
|
for (BaseSpecifierAST *base = ast->base_clause; base; base = base->next) {
|
||||||
Name *baseClassName = semantic()->check(base->name, _scope);
|
Name *baseClassName = semantic()->check(base->name, _scope);
|
||||||
BaseClass *baseClass = control()->newBaseClass(ast->firstToken(), baseClassName);
|
BaseClass *baseClass = control()->newBaseClass(ast->firstToken(), baseClassName);
|
||||||
base->base_class_symbol = baseClass;
|
base->symbol = baseClass;
|
||||||
if (base->token_virtual)
|
if (base->token_virtual)
|
||||||
baseClass->setVirtual(true);
|
baseClass->setVirtual(true);
|
||||||
if (base->token_access_specifier) {
|
if (base->token_access_specifier) {
|
||||||
|
@@ -51,7 +51,6 @@
|
|||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include "Control.h"
|
#include "Control.h"
|
||||||
#include "MemoryPool.h"
|
|
||||||
#include "Literals.h"
|
#include "Literals.h"
|
||||||
#include "LiteralTable.h"
|
#include "LiteralTable.h"
|
||||||
#include "TranslationUnit.h"
|
#include "TranslationUnit.h"
|
||||||
|
@@ -40,7 +40,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual bool visit(ClassSpecifierAST *ast)
|
virtual bool visit(ClassSpecifierAST *ast)
|
||||||
{
|
{
|
||||||
Class *classSymbol = ast->class_symbol;
|
Class *classSymbol = ast->symbol;
|
||||||
Q_ASSERT(classSymbol != 0);
|
Q_ASSERT(classSymbol != 0);
|
||||||
|
|
||||||
insert(ast, classSymbol);
|
insert(ast, classSymbol);
|
||||||
|
Reference in New Issue
Block a user