1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #include "LookupItem.h"
34 #include <FullySpecifiedType.h>
40 using namespace CPlusPlus;
42 uint CPlusPlus::qHash(const CPlusPlus::LookupItem &key)
44 const uint h1 = QT_PREPEND_NAMESPACE(qHash)(key.type().type());
45 const uint h2 = QT_PREPEND_NAMESPACE(qHash)(key.scope());
46 return ((h1 << 16) | (h1 >> 16)) ^ h2;
49 LookupItem::LookupItem()
50 : _scope(0), _declaration(0), _binding(0)
53 FullySpecifiedType LookupItem::type() const
55 if (! _type && _declaration)
56 return _declaration->type();
61 void LookupItem::setType(const FullySpecifiedType &type)
64 Symbol *LookupItem::declaration() const
65 { return _declaration; }
67 void LookupItem::setDeclaration(Symbol *declaration)
68 { _declaration = declaration; }
70 Scope *LookupItem::scope() const
72 if (! _scope && _declaration)
73 return _declaration->enclosingScope();
78 void LookupItem::setScope(Scope *scope)
81 ClassOrNamespace *LookupItem::binding() const
84 void LookupItem::setBinding(ClassOrNamespace *binding)
85 { _binding = binding; }
87 bool LookupItem::operator == (const LookupItem &other) const
89 if (_type == other._type && _declaration == other._declaration && _scope == other._scope
90 && _binding == other._binding)
96 bool LookupItem::operator != (const LookupItem &result) const
97 { return ! operator == (result); }