Commit e53d23d5 authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Merged ObjCMethodDefinitionAST into ObjCMethodDeclarationAST.

parent 86ff16e5
......@@ -2398,21 +2398,9 @@ unsigned ObjCMethodDeclarationAST::lastToken() const
{
if (semicolon_token)
return semicolon_token + 1;
else
return method_prototype->lastToken();
}
unsigned ObjCMethodDefinitionAST::firstToken() const
{
return method_prototype->firstToken();
}
unsigned ObjCMethodDefinitionAST::lastToken() const
{
if (function_body)
return function_body->lastToken();
else
return method_prototype->lastToken();
return method_prototype->lastToken();
}
unsigned ObjCClassImplementationAST::firstToken() const
......
......@@ -222,7 +222,6 @@ public:
virtual ObjCMessageArgumentDeclarationListAST *asObjCMessageArgumentDeclarationList() { return 0; }
virtual ObjCMethodPrototypeAST *asObjCMethodPrototype() { return 0; }
virtual ObjCMethodDeclarationAST *asObjCMethodDeclaration() { return 0; }
virtual ObjCMethodDefinitionAST *asObjCMethodDefinition() { return 0; }
virtual ObjCClassImplementationAST *asObjCClassImplementation() { return 0; }
virtual ObjCCategoryImplementationAST *asObjCCategoryImplementation() { return 0; }
virtual ObjCSynthesizedPropertyAST *asObjCSynthesizedProperty() { return 0; }
......@@ -3040,6 +3039,7 @@ class CPLUSPLUS_EXPORT ObjCMethodDeclarationAST: public DeclarationAST
{
public:
ObjCMethodPrototypeAST *method_prototype;
StatementAST *function_body;
unsigned semicolon_token;
public:
......@@ -3055,25 +3055,6 @@ protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT ObjCMethodDefinitionAST: public DeclarationAST
{
public:
ObjCMethodPrototypeAST *method_prototype;
StatementAST *function_body;
public:
virtual ObjCMethodDefinitionAST *asObjCMethodDefinition()
{ return this; }
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual ObjCMethodDefinitionAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT ObjCClassImplementationAST: public DeclarationAST
{
public:
......
......@@ -1461,15 +1461,8 @@ ObjCMethodDeclarationAST *ObjCMethodDeclarationAST::clone(MemoryPool *pool) cons
{
ObjCMethodDeclarationAST *ast = new (pool) ObjCMethodDeclarationAST;
if (method_prototype) ast->method_prototype = method_prototype->clone(pool);
ast->semicolon_token = semicolon_token;
return ast;
}
ObjCMethodDefinitionAST *ObjCMethodDefinitionAST::clone(MemoryPool *pool) const
{
ObjCMethodDefinitionAST *ast = new (pool) ObjCMethodDefinitionAST;
if (method_prototype) ast->method_prototype = method_prototype->clone(pool);
if (function_body) ast->function_body = function_body->clone(pool);
ast->semicolon_token = semicolon_token;
return ast;
}
......
......@@ -1406,16 +1406,6 @@ void ObjCMethodDeclarationAST::accept0(ASTVisitor *visitor)
if (visitor->visit(this)) {
// visit ObjCMethodDeclarationAST
accept(method_prototype, visitor);
// visit DeclarationAST
}
visitor->endVisit(this);
}
void ObjCMethodDefinitionAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
// visit ObjCMethodDefinitionAST
accept(method_prototype, visitor);
accept(function_body, visitor);
// visit DeclarationAST
}
......
......@@ -221,7 +221,6 @@ public:
virtual bool visit(ObjCPropertyDeclarationAST *) { return true; }
virtual bool visit(ObjCMethodPrototypeAST *) { return true; }
virtual bool visit(ObjCMethodDeclarationAST *) { return true; }
virtual bool visit(ObjCMethodDefinitionAST *) { return true; }
virtual bool visit(ObjCMessageArgumentDeclarationListAST *) { return true; }
virtual bool visit(ObjCMessageArgumentDeclarationAST *) { return true; }
virtual bool visit(ObjCClassImplementationAST *) { return true; }
......@@ -363,7 +362,6 @@ public:
virtual void endVisit(ObjCPropertyDeclarationAST *) { }
virtual void endVisit(ObjCMethodPrototypeAST *) { }
virtual void endVisit(ObjCMethodDeclarationAST *) { }
virtual void endVisit(ObjCMethodDefinitionAST *) { }
virtual void endVisit(ObjCMessageArgumentDeclarationListAST *) { }
virtual void endVisit(ObjCMessageArgumentDeclarationAST *) { }
virtual void endVisit(ObjCClassImplementationAST *) { }
......
......@@ -195,7 +195,6 @@ class ObjCPropertyAttributeListAST;
class ObjCPropertyAttributeAST;
class ObjCMethodPrototypeAST;
class ObjCMethodDeclarationAST;
class ObjCMethodDefinitionAST;
class ObjCMessageArgumentDeclarationListAST;
class ObjCMessageArgumentDeclarationAST;
class ObjCCategoryImplementationAST;
......
......@@ -595,33 +595,7 @@ bool CheckDeclaration::visit(ObjCMethodDeclarationAST *ast)
_scope->enterSymbol(symbol);
return false;
}
bool CheckDeclaration::visit(ObjCMethodDefinitionAST *ast)
{
if (!ast->method_prototype)
return false;
FullySpecifiedType ty = semantic()->check(ast->method_prototype, _scope);
Function *fun = ty.type()->asFunctionType();
if (!fun)
return false;
Declaration *symbol = control()->newDeclaration(ast->firstToken(), fun->name());
symbol->setStartOffset(tokenAt(ast->firstToken()).offset);
symbol->setEndOffset(tokenAt(ast->lastToken()).offset);
symbol->setType(fun->returnType());
symbol->setVisibility(semantic()->currentVisibility());
if (semantic()->isObjCClassMethod(ast->method_prototype->method_type_token))
symbol->setStorage(Symbol::Static);
_scope->enterSymbol(symbol);
if (! semantic()->skipFunctionBodies()) {
if (ast->function_body && !semantic()->skipFunctionBodies()) {
semantic()->check(ast->function_body, fun->members());
}
......
......@@ -96,7 +96,6 @@ protected:
virtual bool visit(ObjCClassDeclarationAST *ast);
virtual bool visit(ObjCClassInterfaceDefinitionAST *ast);
virtual bool visit(ObjCMethodDeclarationAST *ast);
virtual bool visit(ObjCMethodDefinitionAST *ast);
virtual bool visit(ObjCVisibilityDeclarationAST *ast);
private:
......
......@@ -4321,20 +4321,18 @@ bool Parser::parseObjCMethodDefinition(DeclarationAST *&node)
if (! parseObjCMethodPrototype(method_prototype))
return false;
ObjCMethodDeclarationAST *ast = new (_pool) ObjCMethodDeclarationAST;
ast->method_prototype = method_prototype;
if (LA() == T_SEMICOLON) {
// method declaration:
ObjCMethodDeclarationAST *ast = new (_pool) ObjCMethodDeclarationAST;
ast->method_prototype = method_prototype;
ast->semicolon_token = consumeToken();
node = ast;
} else {
// method definition:
ObjCMethodDefinitionAST *ast = new (_pool) ObjCMethodDefinitionAST;
ast->method_prototype = method_prototype;
parseFunctionBody(ast->function_body);
node = ast;
}
node = ast;
return true;
}
......@@ -4567,10 +4565,14 @@ bool Parser::parseObjCMethodPrototype(ObjCMethodPrototypeAST *&node)
DeclarationAST *parameter_declaration = 0;
parseParameterDeclaration(parameter_declaration);
}
node = ast;
} else if (lookAtObjCSelector()) {
ObjCSelectorWithoutArgumentsAST *sel = new (_pool) ObjCSelectorWithoutArgumentsAST;
parseObjCSelector(sel->name_token);
ast->selector = sel;
node = ast;
} else {
_translationUnit->error(cursor(), "expected a selector");
}
......@@ -4579,7 +4581,6 @@ bool Parser::parseObjCMethodPrototype(ObjCMethodPrototypeAST *&node)
while (parseAttributeSpecifier(*attr))
attr = &(*attr)->next;
node = ast;
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment