summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorRoberto Raggi <qtc-committer@nokia.com>2009-02-09 12:19:17 +0100
committerRoberto Raggi <qtc-committer@nokia.com>2009-02-09 12:19:17 +0100
commitea981d502527376bd783a2b1ff204384ea43c381 (patch)
tree48d19d8c05c39ae62c198d537ec8a971b1e33baa /src/shared
parent3ac4e05e374fe91891d27b240b60ea91308d7184 (diff)
downloadqt-creator-ea981d502527376bd783a2b1ff204384ea43c381.tar.gz
More annotations.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/cplusplus/AST.h41
-rw-r--r--src/shared/cplusplus/CheckDeclaration.cpp22
-rw-r--r--src/shared/cplusplus/CheckSpecifier.cpp4
-rw-r--r--src/shared/cplusplus/Control.cpp1
4 files changed, 52 insertions, 16 deletions
diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h
index 0b957ede81..ac452311fa 100644
--- a/src/shared/cplusplus/AST.h
+++ b/src/shared/cplusplus/AST.h
@@ -60,6 +60,20 @@
CPLUSPLUS_BEGIN_HEADER
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
{
AST(const AST &other);
@@ -352,6 +366,9 @@ public:
unsigned semicolon_token;
public:
+ List<Declaration *> *symbols;
+
+public:
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
@@ -423,7 +440,7 @@ public:
BaseSpecifierAST *next;
public: // annotations
- BaseClass *base_class_symbol;
+ BaseClass *symbol;
public:
virtual unsigned firstToken() const;
@@ -519,7 +536,7 @@ public:
unsigned rbrace_token;
public: // annotations
- Class *class_symbol;
+ Class *symbol;
public:
virtual unsigned firstToken() const;
@@ -921,6 +938,9 @@ public:
CtorInitializerAST *ctor_initializer;
StatementAST *function_body;
+public: // annotations
+ Function *symbol;
+
public:
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
@@ -1195,7 +1215,7 @@ public:
DeclarationAST *linkage_body;
public: // annotations
- Namespace *namespace_symbol;
+ Namespace *symbol;
public:
virtual unsigned firstToken() const;
@@ -1321,6 +1341,9 @@ public:
unsigned equal_token;
ExpressionAST *expression;
+public: // annotations
+ Argument *symbol;
+
public:
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
@@ -1858,6 +1881,9 @@ public:
unsigned equal_token;
ExpressionAST *type_id;
+public: // annotations
+ Argument *symbol;
+
public:
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
@@ -1881,6 +1907,9 @@ public:
ExpressionAST *type_id;
public:
+ Argument *symbol;
+
+public:
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
@@ -1914,6 +1943,9 @@ public:
NameAST *name;
unsigned semicolon_token;
+public: // annotations
+ UsingDeclaration *symbol;
+
public:
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
@@ -1933,6 +1965,9 @@ public:
unsigned semicolon_token;
public:
+ UsingNamespaceDirective *symbol;
+
+public:
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp
index 48e6cd40fa..179dd06987 100644
--- a/src/shared/cplusplus/CheckDeclaration.cpp
+++ b/src/shared/cplusplus/CheckDeclaration.cpp
@@ -136,6 +136,7 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
}
}
+ List<Declaration *> **decl_it = &ast->symbols;
for (DeclaratorListAST *it = ast->declarators; it; it = it->next) {
Name *name = 0;
FullySpecifiedType declTy = semantic()->check(it->declarator, qualTy,
@@ -179,6 +180,10 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
else if (ty.isTypedef())
symbol->setStorage(Symbol::Typedef);
+ *decl_it = new (translationUnit()->memoryPool()) List<Declaration *>();
+ (*decl_it)->value = symbol;
+ decl_it = &(*decl_it)->next;
+
_scope->enterSymbol(symbol);
}
return false;
@@ -234,6 +239,7 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast)
checkFunctionArguments(fun);
+ ast->symbol = fun;
_scope->enterSymbol(fun);
if (ast->ctor_initializer) {
@@ -286,7 +292,7 @@ bool CheckDeclaration::visit(NamespaceAST *ast)
Identifier *id = identifier(ast->identifier_token);
Name *namespaceName = control()->nameId(id);
Namespace *ns = control()->newNamespace(ast->firstToken(), namespaceName);
- ast->namespace_symbol = ns;
+ ast->symbol = ns;
_scope->enterSymbol(ns);
semantic()->check(ast->linkage_body, ns->members()); // ### we'll do the merge later.
@@ -311,6 +317,7 @@ bool CheckDeclaration::visit(ParameterDeclarationAST *ast)
_scope, &argName);
FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
Argument *arg = control()->newArgument(ast->firstToken(), argName);
+ ast->symbol = arg;
if (ast->expression)
arg->setInitializer(true);
arg->setType(argTy);
@@ -320,15 +327,6 @@ bool CheckDeclaration::visit(ParameterDeclarationAST *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()));
for (DeclarationAST *param = ast->template_parameters; param;
param = param->next) {
@@ -344,6 +342,7 @@ bool CheckDeclaration::visit(TypenameTypeParameterAST *ast)
{
Name *name = semantic()->check(ast->name, _scope);
Argument *arg = control()->newArgument(ast->firstToken(), name); // ### new template type
+ ast->symbol = arg;
_scope->enterSymbol(arg);
return false;
}
@@ -352,6 +351,7 @@ bool CheckDeclaration::visit(TemplateTypeParameterAST *ast)
{
Name *name = semantic()->check(ast->name, _scope);
Argument *arg = control()->newArgument(ast->firstToken(), name); // ### new template type
+ ast->symbol = arg;
_scope->enterSymbol(arg);
return false;
}
@@ -360,6 +360,7 @@ bool CheckDeclaration::visit(UsingAST *ast)
{
Name *name = semantic()->check(ast->name, _scope);
UsingDeclaration *u = control()->newUsingDeclaration(ast->firstToken(), name);
+ ast->symbol = u;
_scope->enterSymbol(u);
return false;
}
@@ -368,6 +369,7 @@ bool CheckDeclaration::visit(UsingDirectiveAST *ast)
{
Name *name = semantic()->check(ast->name, _scope);
UsingNamespaceDirective *u = control()->newUsingNamespaceDirective(ast->firstToken(), name);
+ ast->symbol = u;
_scope->enterSymbol(u);
return false;
}
diff --git a/src/shared/cplusplus/CheckSpecifier.cpp b/src/shared/cplusplus/CheckSpecifier.cpp
index bee510d31d..20a3662e7b 100644
--- a/src/shared/cplusplus/CheckSpecifier.cpp
+++ b/src/shared/cplusplus/CheckSpecifier.cpp
@@ -300,7 +300,7 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
{
Name *className = semantic()->check(ast->name, _scope);
Class *klass = control()->newClass(ast->firstToken(), className);
- ast->class_symbol = klass;
+ ast->symbol = klass;
unsigned classKey = tokenKind(ast->classkey_token);
if (classKey == T_CLASS)
klass->setClassKey(Class::ClassKey);
@@ -315,7 +315,7 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
for (BaseSpecifierAST *base = ast->base_clause; base; base = base->next) {
Name *baseClassName = semantic()->check(base->name, _scope);
BaseClass *baseClass = control()->newBaseClass(ast->firstToken(), baseClassName);
- base->base_class_symbol = baseClass;
+ base->symbol = baseClass;
if (base->token_virtual)
baseClass->setVirtual(true);
if (base->token_access_specifier) {
diff --git a/src/shared/cplusplus/Control.cpp b/src/shared/cplusplus/Control.cpp
index e44d84a1ae..4d708f4340 100644
--- a/src/shared/cplusplus/Control.cpp
+++ b/src/shared/cplusplus/Control.cpp
@@ -51,7 +51,6 @@
// THE SOFTWARE.
#include "Control.h"
-#include "MemoryPool.h"
#include "Literals.h"
#include "LiteralTable.h"
#include "TranslationUnit.h"