summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus/Scope.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/cplusplus/Scope.cpp')
-rw-r--r--src/shared/cplusplus/Scope.cpp46
1 files changed, 30 insertions, 16 deletions
diff --git a/src/shared/cplusplus/Scope.cpp b/src/shared/cplusplus/Scope.cpp
index 16026f8060..9743e98e44 100644
--- a/src/shared/cplusplus/Scope.cpp
+++ b/src/shared/cplusplus/Scope.cpp
@@ -50,12 +50,8 @@
#include "Symbols.h"
#include "Names.h"
#include "Literals.h"
-#include <cstdlib>
#include <cassert>
#include <cstring>
-#include <iostream>
-
-using namespace std;
using namespace CPlusPlus;
@@ -176,6 +172,13 @@ bool Scope::isPrototypeScope() const
return false;
}
+bool Scope::isObjCClassScope() const
+{
+ if (_owner)
+ return _owner->isObjCClass();
+ return false;
+}
+
bool Scope::isFunctionScope() const
{
Function *f = 0;
@@ -184,6 +187,14 @@ bool Scope::isFunctionScope() const
return false;
}
+bool Scope::isObjCMethodScope() const
+{
+ ObjCMethod *m = 0;
+ if (_owner && 0 != (m = _owner->asObjCMethod()))
+ return m->arguments() != this;
+ return false;
+}
+
void Scope::enterSymbol(Symbol *symbol)
{
if (++_symbolCount == _allocatedSymbols) {
@@ -208,22 +219,22 @@ void Scope::enterSymbol(Symbol *symbol)
}
}
-Symbol *Scope::lookat(Name *name) const
+Symbol *Scope::lookat(const Name *name) const
{
if (! name)
return 0;
- else if (OperatorNameId *opId = name->asOperatorNameId())
+ else if (const OperatorNameId *opId = name->asOperatorNameId())
return lookat(opId->kind());
- else if (Identifier *id = name->identifier())
+ else if (const Identifier *id = name->identifier())
return lookat(id);
else
return 0;
}
-Symbol *Scope::lookat(Identifier *id) const
+Symbol *Scope::lookat(const Identifier *id) const
{
if (! _hash || ! id)
return 0;
@@ -231,20 +242,23 @@ Symbol *Scope::lookat(Identifier *id) const
const unsigned h = id->hashCode() % _hashSize;
Symbol *symbol = _hash[h];
for (; symbol; symbol = symbol->_next) {
- Name *identity = symbol->identity();
+ const Name *identity = symbol->identity();
if (! identity) {
continue;
- } else if (NameId *nameId = identity->asNameId()) {
+ } else if (const NameId *nameId = identity->asNameId()) {
if (nameId->identifier()->isEqualTo(id))
break;
- } else if (TemplateNameId *t = identity->asTemplateNameId()) {
+ } else if (const TemplateNameId *t = identity->asTemplateNameId()) {
if (t->identifier()->isEqualTo(id))
break;
- } else if (DestructorNameId *d = identity->asDestructorNameId()) {
+ } else if (const DestructorNameId *d = identity->asDestructorNameId()) {
if (d->identifier()->isEqualTo(id))
break;
} else if (identity->isQualifiedNameId()) {
- assert(0);
+ return 0;
+ } else if (const SelectorNameId *selectorNameId = identity->asSelectorNameId()) {
+ if (selectorNameId->identifier()->isEqualTo(id))
+ break;
}
}
return symbol;
@@ -258,8 +272,8 @@ Symbol *Scope::lookat(int operatorId) const
const unsigned h = operatorId % _hashSize;
Symbol *symbol = _hash[h];
for (; symbol; symbol = symbol->_next) {
- Name *identity = symbol->identity();
- if (OperatorNameId *op = identity->asOperatorNameId()) {
+ const Name *identity = symbol->identity();
+ if (const OperatorNameId *op = identity->asOperatorNameId()) {
if (op->kind() == operatorId)
break;
}
@@ -275,7 +289,7 @@ void Scope::rehash()
_hashSize = DefaultInitialSize;
_hash = reinterpret_cast<Symbol **>(realloc(_hash, sizeof(Symbol *) * _hashSize));
- memset(_hash, 0, sizeof(Symbol *) * _hashSize);
+ std::memset(_hash, 0, sizeof(Symbol *) * _hashSize);
for (int index = 0; index < _symbolCount + 1; ++index) {
Symbol *symbol = _symbols[index];