summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r--src/shared/cplusplus/AST.h4
-rw-r--r--src/shared/cplusplus/CheckDeclarator.cpp21
-rw-r--r--src/shared/cplusplus/CheckDeclarator.h1
-rw-r--r--src/shared/cplusplus/CheckName.cpp34
-rw-r--r--src/shared/cplusplus/CheckName.h2
-rw-r--r--src/shared/cplusplus/CheckSpecifier.cpp18
-rw-r--r--src/shared/cplusplus/CheckSpecifier.h3
-rw-r--r--src/shared/cplusplus/Semantic.cpp6
-rw-r--r--src/shared/cplusplus/Semantic.h3
9 files changed, 83 insertions, 9 deletions
diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h
index ee22f1a453..d9e5413028 100644
--- a/src/shared/cplusplus/AST.h
+++ b/src/shared/cplusplus/AST.h
@@ -2970,7 +2970,7 @@ protected:
virtual void accept0(ASTVisitor *visitor);
};
-class CPLUSPLUS_EXPORT ObjCMessageArgumentDeclarationAST: public AST
+class CPLUSPLUS_EXPORT ObjCMessageArgumentDeclarationAST: public NameAST
{
public:
ObjCTypeNameAST* type_name;
@@ -2978,7 +2978,7 @@ public:
unsigned param_name_token;
public: // annotations
- Name *param_name;
+ Argument *argument;
public:
virtual ObjCMessageArgumentDeclarationAST *asObjCMessageArgumentDeclaration()
diff --git a/src/shared/cplusplus/CheckDeclarator.cpp b/src/shared/cplusplus/CheckDeclarator.cpp
index 27a0a03fc3..6ff3b923a3 100644
--- a/src/shared/cplusplus/CheckDeclarator.cpp
+++ b/src/shared/cplusplus/CheckDeclarator.cpp
@@ -248,6 +248,8 @@ bool CheckDeclarator::visit(ReferenceAST *ast)
bool CheckDeclarator::visit(ObjCMethodPrototypeAST *ast)
{
+ FullySpecifiedType returnType = semantic()->check(ast->type_name, _scope);
+
unsigned location = ast->firstToken();
Name *name = semantic()->check(ast->selector, _scope);
@@ -259,15 +261,20 @@ bool CheckDeclarator::visit(ObjCMethodPrototypeAST *ast)
fun->setMethodKey(Function::NormalMethod);
fun->setVisibility(semantic()->currentVisibility());
fun->setPureVirtual(false);
+ fun->setReturnType(returnType);
+
+ if (ast->selector->asObjCSelectorWithArguments()) {
+ // TODO: check the parameters (EV)
+ // fun->setVariadic(...);
+ // TODO: add arguments (EV)
+ for (ObjCMessageArgumentDeclarationListAST *it = ast->arguments; it; it = it->next) {
+ ObjCMessageArgumentDeclarationAST *argDecl = it->argument_declaration;
- // TODO: check return type (EV)
-// fun->setReturnType(semantic()->check(ast->type_name, _scope));
- // TODO: check the parameters (EV)
- // fun->setVariadic(...);
- // TODO: add arguments (EV)
+ semantic()->check(argDecl, fun->arguments());
+ }
+ }
- FullySpecifiedType mTy(fun);
- _fullySpecifiedType = mTy;
+ _fullySpecifiedType = FullySpecifiedType(fun);
// TODO: check which specifiers are allowed here (EV)
diff --git a/src/shared/cplusplus/CheckDeclarator.h b/src/shared/cplusplus/CheckDeclarator.h
index 1903c6e26a..d706169bed 100644
--- a/src/shared/cplusplus/CheckDeclarator.h
+++ b/src/shared/cplusplus/CheckDeclarator.h
@@ -96,6 +96,7 @@ protected:
// ObjC
virtual bool visit(ObjCMethodPrototypeAST *ast);
+ void checkMessageArgument(ObjCMessageArgumentDeclarationAST *arg);
void applyCvQualifiers(SpecifierAST *cv);
private:
diff --git a/src/shared/cplusplus/CheckName.cpp b/src/shared/cplusplus/CheckName.cpp
index c18a9f3400..48ab067f03 100644
--- a/src/shared/cplusplus/CheckName.cpp
+++ b/src/shared/cplusplus/CheckName.cpp
@@ -55,6 +55,7 @@
#include "Names.h"
#include "CoreTypes.h"
#include "Symbols.h"
+#include "Scope.h"
#include <cassert>
CPLUSPLUS_BEGIN_NAMESPACE
@@ -108,6 +109,17 @@ Name *CheckName::check(ObjCSelectorAST *args, Scope *scope)
return switchName(previousName);
}
+void CheckName::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope)
+{
+ Name *previousName = switchName(0);
+ Scope *previousScope = switchScope(scope);
+
+ accept(arg);
+
+ (void) switchScope(previousScope);
+ (void) switchName(previousName);
+}
+
Name *CheckName::switchName(Name *name)
{
Name *previousName = _name;
@@ -386,4 +398,26 @@ bool CheckName::visit(ObjCSelectorWithArgumentsAST *ast)
return false;
}
+bool CheckName::visit(ObjCMessageArgumentDeclarationAST *ast)
+{
+ FullySpecifiedType type;
+
+ if (ast->type_name)
+ type = semantic()->check(ast->type_name, _scope);
+
+ if (ast->param_name_token) {
+ Identifier *id = identifier(ast->param_name_token);
+ _name = control()->nameId(id);
+ ast->name = _name;
+
+ Argument *arg = control()->newArgument(ast->firstToken(), _name);
+ ast->argument = arg;
+ arg->setType(type);
+ arg->setInitializer(false);
+ _scope->enterSymbol(arg);
+ }
+
+ return false;
+}
+
CPLUSPLUS_END_NAMESPACE
diff --git a/src/shared/cplusplus/CheckName.h b/src/shared/cplusplus/CheckName.h
index 21bd550a7c..ba877e44af 100644
--- a/src/shared/cplusplus/CheckName.h
+++ b/src/shared/cplusplus/CheckName.h
@@ -64,6 +64,7 @@ public:
Name *check(NameAST *name, Scope *scope);
Name *check(NestedNameSpecifierAST *name, Scope *scope);
Name *check(ObjCSelectorAST *args, Scope *scope);
+ void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope);
protected:
Name *switchName(Name *name);
@@ -81,6 +82,7 @@ protected:
// ObjC
virtual bool visit(ObjCSelectorWithoutArgumentsAST *ast);
virtual bool visit(ObjCSelectorWithArgumentsAST *ast);
+ virtual bool visit(ObjCMessageArgumentDeclarationAST *ast);
private:
Name *_name;
diff --git a/src/shared/cplusplus/CheckSpecifier.cpp b/src/shared/cplusplus/CheckSpecifier.cpp
index c112561f16..103357c5a6 100644
--- a/src/shared/cplusplus/CheckSpecifier.cpp
+++ b/src/shared/cplusplus/CheckSpecifier.cpp
@@ -80,6 +80,17 @@ FullySpecifiedType CheckSpecifier::check(SpecifierAST *specifier, Scope *scope)
return switchFullySpecifiedType(previousType);
}
+FullySpecifiedType CheckSpecifier::check(ObjCTypeNameAST *typeName, Scope *scope)
+{
+ FullySpecifiedType previousType = switchFullySpecifiedType(FullySpecifiedType());
+ Scope *previousScope = switchScope(scope);
+
+ accept(typeName);
+
+ (void) switchScope(previousScope);
+ return switchFullySpecifiedType(previousType);
+}
+
SpecifierAST *CheckSpecifier::switchSpecifier(SpecifierAST *specifier)
{
SpecifierAST *previousSpecifier = _specifier;
@@ -402,4 +413,11 @@ bool CheckSpecifier::visit(AttributeSpecifierAST *ast)
return false;
}
+bool CheckSpecifier::visit(ObjCTypeNameAST * /*ast*/)
+{
+ // TODO: implement this (EV)
+ _fullySpecifiedType = FullySpecifiedType();
+ return false;
+}
+
CPLUSPLUS_END_NAMESPACE
diff --git a/src/shared/cplusplus/CheckSpecifier.h b/src/shared/cplusplus/CheckSpecifier.h
index 0da151f0ff..80fcbbbf6f 100644
--- a/src/shared/cplusplus/CheckSpecifier.h
+++ b/src/shared/cplusplus/CheckSpecifier.h
@@ -63,6 +63,7 @@ public:
virtual ~CheckSpecifier();
FullySpecifiedType check(SpecifierAST *specifier, Scope *scope);
+ FullySpecifiedType check(ObjCTypeNameAST *typeName, Scope *scope);
protected:
SpecifierAST *switchSpecifier(SpecifierAST *specifier);
@@ -79,6 +80,8 @@ protected:
virtual bool visit(TypeofSpecifierAST *ast);
virtual bool visit(AttributeSpecifierAST *ast);
+ virtual bool visit(ObjCTypeNameAST *ast);
+
private:
SpecifierAST *_specifier;
FullySpecifiedType _fullySpecifiedType;
diff --git a/src/shared/cplusplus/Semantic.cpp b/src/shared/cplusplus/Semantic.cpp
index 23e69decd0..f15c33752a 100644
--- a/src/shared/cplusplus/Semantic.cpp
+++ b/src/shared/cplusplus/Semantic.cpp
@@ -137,6 +137,12 @@ FullySpecifiedType Semantic::check(PtrOperatorAST *ptrOperators, FullySpecifiedT
FullySpecifiedType Semantic::check(ObjCMethodPrototypeAST *methodPrototype, Scope *scope)
{ return d->checkDeclarator->check(methodPrototype, scope); }
+FullySpecifiedType Semantic::check(ObjCTypeNameAST *typeName, Scope *scope)
+{ return d->checkSpecifier->check(typeName, scope); }
+
+void Semantic::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope)
+{ return d->checkName->check(arg, scope); }
+
FullySpecifiedType Semantic::check(ExpressionAST *expression, Scope *scope)
{ return d->checkExpression->check(expression, scope); }
diff --git a/src/shared/cplusplus/Semantic.h b/src/shared/cplusplus/Semantic.h
index 113796bafb..70f0e2f5d5 100644
--- a/src/shared/cplusplus/Semantic.h
+++ b/src/shared/cplusplus/Semantic.h
@@ -87,6 +87,9 @@ public:
Name *check(NestedNameSpecifierAST *name, Scope *scope);
Name *check(ObjCSelectorAST *args, Scope *scope);
+ FullySpecifiedType check(ObjCTypeNameAST *typeName, Scope *scope);
+
+ void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope);
bool skipFunctionBodies() const;
void setSkipFunctionBodies(bool skipFunctionBodies);