diff --git a/src/shared/cplusplus/Bind.cpp b/src/shared/cplusplus/Bind.cpp index 8de3b779cb305bc7c716827a79be9360890638a1..e24f93d419e0be453557cfc05e4c291ff097b7e3 100644 --- a/src/shared/cplusplus/Bind.cpp +++ b/src/shared/cplusplus/Bind.cpp @@ -66,20 +66,28 @@ Bind::Bind(TranslationUnit *unit) _scope(0), _expression(0), _name(0), - _declaratorId(0) + _declaratorId(0), + _visibility(Symbol::Public), + _methodKey(Function::NormalMethod) { } -Scope *Bind::currentScope() const +Scope *Bind::switchScope(Scope *scope) { - return _scope; + std::swap(_scope, scope); + return scope; } -Scope *Bind::switchScope(Scope *scope) +int Bind::switchVisibility(int visibility) +{ + std::swap(_visibility, visibility); + return visibility; +} + +int Bind::switchMethodKey(int methodKey) { - Scope *previousScope = _scope; - _scope = scope; - return previousScope; + std::swap(_methodKey, methodKey); + return methodKey; } void Bind::operator()(TranslationUnitAST *ast, Namespace *globalNamespace) @@ -1502,6 +1510,17 @@ bool Bind::visit(AccessDeclarationAST *ast) // unsigned access_specifier_token = ast->access_specifier_token; // unsigned slots_token = ast->slots_token; // unsigned colon_token = ast->colon_token; + + const int accessSpecifier = tokenKind(ast->access_specifier_token); + _visibility = visibilityForAccessSpecifier(accessSpecifier); + + if (ast->slots_token) + _methodKey = Function::SlotMethod; + else if (accessSpecifier == T_Q_SIGNALS) + _methodKey = Function::SignalMethod; + else + _methodKey = Function::NormalMethod; + return false; } @@ -2170,6 +2189,8 @@ bool Bind::visit(ClassSpecifierAST *ast) _type.setType(klass); Scope *previousScope = switchScope(klass); + const int previousVisibility = switchVisibility(Symbol::Public); + const int previousMethodKey = switchMethodKey(Function::NormalMethod); for (BaseSpecifierListAST *it = ast->base_clause_list; it; it = it->next) { this->baseSpecifier(it->value, ast->colon_token, klass); @@ -2178,7 +2199,11 @@ bool Bind::visit(ClassSpecifierAST *ast) for (DeclarationListAST *it = ast->member_specifier_list; it; it = it->next) { this->declaration(it->value); } + + (void) switchMethodKey(previousMethodKey); + (void) switchVisibility(previousVisibility); (void) switchScope(previousScope); + ast->symbol = klass; return false; } diff --git a/src/shared/cplusplus/Bind.h b/src/shared/cplusplus/Bind.h index a323bc00b5ebec7b89b504fd62578cced9da406d..e9b5c77b6dc1bcd69161a534d447fdf845fac21c 100644 --- a/src/shared/cplusplus/Bind.h +++ b/src/shared/cplusplus/Bind.h @@ -79,8 +79,9 @@ protected: FullySpecifiedType coreDeclarator(CoreDeclaratorAST *ast, const FullySpecifiedType &init); FullySpecifiedType postfixDeclarator(PostfixDeclaratorAST *ast, const FullySpecifiedType &init); - Scope *currentScope() const; Scope *switchScope(Scope *scope); + int switchVisibility(int visibility); + int switchMethodKey(int methodKey); const Name *objCSelectorArgument(ObjCSelectorArgumentAST *ast, bool *hasArg); void attribute(AttributeAST *ast); @@ -278,6 +279,8 @@ private: const Name *_name; FullySpecifiedType _type; DeclaratorIdAST **_declaratorId; + int _visibility; + int _methodKey; }; } // end of namespace CPlusPlus