summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus/Control.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@nokia.com>2009-07-31 16:03:48 +0200
committerErik Verbruggen <erik.verbruggen@nokia.com>2009-07-31 16:03:48 +0200
commit4a0da2c6f2663d9469bfd929fa682b6df7d42ab7 (patch)
treed8fb1fbbeacaadad06024ecd5ce8e84c8f30d547 /src/shared/cplusplus/Control.cpp
parentb713f1772a4de8330bcdd96a00b9cf103541e008 (diff)
downloadqt-creator-4a0da2c6f2663d9469bfd929fa682b6df7d42ab7.tar.gz
Added Semantic checks for ObjC methods.
Diffstat (limited to 'src/shared/cplusplus/Control.cpp')
-rw-r--r--src/shared/cplusplus/Control.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/shared/cplusplus/Control.cpp b/src/shared/cplusplus/Control.cpp
index 49f965f7da..96a6719611 100644
--- a/src/shared/cplusplus/Control.cpp
+++ b/src/shared/cplusplus/Control.cpp
@@ -196,6 +196,15 @@ public:
return it->second;
}
+ SelectorNameId *findOrInsertSelectorNameId(const std::vector<Name *> &names, bool hasArguments)
+ {
+ const SelectorNameIdKey key(names, hasArguments);
+ std::map<SelectorNameIdKey, SelectorNameId *>::iterator it = selectorNameIds.lower_bound(key);
+ if (it == selectorNameIds.end() || it->first != key)
+ it = selectorNameIds.insert(it, std::make_pair(key, new SelectorNameId(&names[0], names.size(), hasArguments)));
+ return it->second;
+ }
+
IntegerType *findOrInsertIntegerType(int kind)
{
const int key = int(kind);
@@ -423,6 +432,27 @@ public:
}
};
+ struct SelectorNameIdKey {
+ std::vector<Name *> _names;
+ bool _hasArguments;
+
+ SelectorNameIdKey(const std::vector<Name *> &names, bool hasArguments): _names(names), _hasArguments(hasArguments) {}
+
+ bool operator==(const SelectorNameIdKey &other) const
+ { return _names == other._names && _hasArguments == other._hasArguments; }
+
+ bool operator!=(const SelectorNameIdKey &other) const
+ { return !operator==(other); }
+
+ bool operator<(const SelectorNameIdKey &other) const
+ {
+ if (_hasArguments == other._hasArguments)
+ return std::lexicographical_compare(_names.begin(), _names.end(), other._names.begin(), other._names.end());
+ else
+ return _hasArguments < other._hasArguments;
+ }
+ };
+
struct ArrayKey {
FullySpecifiedType type;
size_t size;
@@ -491,6 +521,7 @@ public:
std::map<FullySpecifiedType, ConversionNameId *> conversionNameIds;
std::map<TemplateNameIdKey, TemplateNameId *> templateNameIds;
std::map<QualifiedNameIdKey, QualifiedNameId *> qualifiedNameIds;
+ std::map<SelectorNameIdKey, SelectorNameId *> selectorNameIds;
// types
VoidType voidType;
@@ -615,6 +646,15 @@ QualifiedNameId *Control::qualifiedNameId(Name *const *names,
return d->findOrInsertQualifiedNameId(classOrNamespaceNames, isGlobal);
}
+SelectorNameId *Control::selectorNameId(Name *const *names,
+ unsigned nameCount,
+ bool hasArguments)
+{
+ std::vector<Name *> selectorNames(names, names + nameCount);
+ return d->findOrInsertSelectorNameId(selectorNames, hasArguments);
+}
+
+
VoidType *Control::voidType()
{ return &d->voidType; }