From 4a0da2c6f2663d9469bfd929fa682b6df7d42ab7 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Fri, 31 Jul 2009 16:03:48 +0200 Subject: Added Semantic checks for ObjC methods. --- src/shared/cplusplus/Control.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/shared/cplusplus/Control.cpp') 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 &names, bool hasArguments) + { + const SelectorNameIdKey key(names, hasArguments); + std::map::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 _names; + bool _hasArguments; + + SelectorNameIdKey(const std::vector &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 conversionNameIds; std::map templateNameIds; std::map qualifiedNameIds; + std::map 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 selectorNames(names, names + nameCount); + return d->findOrInsertSelectorNameId(selectorNames, hasArguments); +} + + VoidType *Control::voidType() { return &d->voidType; } -- cgit v1.2.1