Files
qt-creator/src/libs/cplusplus/LookupItem.cpp

70 lines
1.6 KiB
C++
Raw Normal View History

// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
2010-05-05 09:54:19 +02:00
#include "LookupItem.h"
#include <cplusplus/FullySpecifiedType.h>
#include <cplusplus/Symbol.h>
#include <cplusplus/Control.h>
2010-05-05 09:54:19 +02:00
#include <QDebug>
2010-05-05 09:54:19 +02:00
using namespace CPlusPlus;
size_t CPlusPlus::qHash(const LookupItem &key)
2010-05-05 09:54:19 +02:00
{
const size_t h1 = QT_PREPEND_NAMESPACE(qHash)(key.type().type());
const size_t h2 = QT_PREPEND_NAMESPACE(qHash)(key.scope());
2010-05-05 09:54:19 +02:00
return ((h1 << 16) | (h1 >> 16)) ^ h2;
}
LookupItem::LookupItem()
: _scope(nullptr), _declaration(nullptr), _binding(nullptr)
2010-05-05 09:54:19 +02:00
{ }
FullySpecifiedType LookupItem::type() const
{
if (! _type && _declaration)
return _declaration->type();
return _type;
}
2010-05-05 09:54:19 +02:00
void LookupItem::setType(const FullySpecifiedType &type)
{ _type = type; }
Symbol *LookupItem::declaration() const
{ return _declaration; }
void LookupItem::setDeclaration(Symbol *declaration)
{ _declaration = declaration; }
Scope *LookupItem::scope() const
{
if (! _scope && _declaration)
return _declaration->enclosingScope();
return _scope;
}
2010-05-05 09:54:19 +02:00
void LookupItem::setScope(Scope *scope)
{ _scope = scope; }
2010-05-05 09:54:19 +02:00
ClassOrNamespace *LookupItem::binding() const
{ return _binding; }
void LookupItem::setBinding(ClassOrNamespace *binding)
{ _binding = binding; }
2010-05-05 09:54:19 +02:00
bool LookupItem::operator == (const LookupItem &other) const
{
if (_type == other._type && _declaration == other._declaration && _scope == other._scope
&& _binding == other._binding)
return true;
2010-05-05 09:54:19 +02:00
return false;
}
bool LookupItem::operator != (const LookupItem &result) const
{ return ! operator == (result); }