2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2023-01-04 08:52:22 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2010-05-05 09:54:19 +02:00
|
|
|
|
|
|
|
|
#include "LookupItem.h"
|
2013-03-27 18:54:03 +01:00
|
|
|
|
|
|
|
|
#include <cplusplus/FullySpecifiedType.h>
|
|
|
|
|
#include <cplusplus/Symbol.h>
|
|
|
|
|
#include <cplusplus/Control.h>
|
2010-05-05 09:54:19 +02:00
|
|
|
|
2012-08-06 13:42:46 +02:00
|
|
|
#include <QDebug>
|
2010-05-05 09:54:19 +02:00
|
|
|
|
|
|
|
|
using namespace CPlusPlus;
|
|
|
|
|
|
2022-07-13 09:27:18 +02:00
|
|
|
size_t CPlusPlus::qHash(const LookupItem &key)
|
2010-05-05 09:54:19 +02:00
|
|
|
{
|
2022-07-13 09:27:18 +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()
|
2019-07-31 17:21:41 +02:00
|
|
|
: _scope(nullptr), _declaration(nullptr), _binding(nullptr)
|
2010-05-05 09:54:19 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
FullySpecifiedType LookupItem::type() const
|
2010-07-16 11:03:39 +02:00
|
|
|
{
|
|
|
|
|
if (! _type && _declaration)
|
|
|
|
|
return _declaration->type();
|
|
|
|
|
|
|
|
|
|
return _type;
|
|
|
|
|
}
|
2010-05-05 09:54:19 +02:00
|
|
|
|
|
|
|
|
void LookupItem::setType(const FullySpecifiedType &type)
|
|
|
|
|
{ _type = type; }
|
|
|
|
|
|
2010-05-11 11:26:27 +02:00
|
|
|
Symbol *LookupItem::declaration() const
|
|
|
|
|
{ return _declaration; }
|
|
|
|
|
|
|
|
|
|
void LookupItem::setDeclaration(Symbol *declaration)
|
|
|
|
|
{ _declaration = declaration; }
|
|
|
|
|
|
2010-05-12 12:53:16 +02:00
|
|
|
Scope *LookupItem::scope() const
|
|
|
|
|
{
|
|
|
|
|
if (! _scope && _declaration)
|
2010-08-26 16:16:22 +02:00
|
|
|
return _declaration->enclosingScope();
|
2010-05-12 12:53:16 +02:00
|
|
|
|
|
|
|
|
return _scope;
|
|
|
|
|
}
|
2010-05-05 09:54:19 +02:00
|
|
|
|
2010-05-12 12:53:16 +02:00
|
|
|
void LookupItem::setScope(Scope *scope)
|
|
|
|
|
{ _scope = scope; }
|
2010-05-05 09:54:19 +02:00
|
|
|
|
2015-11-19 13:49:26 +01:00
|
|
|
ClassOrNamespace *LookupItem::binding() const
|
2010-07-16 11:03:39 +02:00
|
|
|
{ return _binding; }
|
|
|
|
|
|
2015-11-19 13:49:26 +01:00
|
|
|
void LookupItem::setBinding(ClassOrNamespace *binding)
|
2010-07-16 11:03:39 +02:00
|
|
|
{ _binding = binding; }
|
|
|
|
|
|
2010-05-05 09:54:19 +02:00
|
|
|
bool LookupItem::operator == (const LookupItem &other) const
|
|
|
|
|
{
|
2010-07-16 11:03:39 +02:00
|
|
|
if (_type == other._type && _declaration == other._declaration && _scope == other._scope
|
|
|
|
|
&& _binding == other._binding)
|
2010-05-11 11:26:27 +02:00
|
|
|
return true;
|
2010-05-05 09:54:19 +02:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool LookupItem::operator != (const LookupItem &result) const
|
|
|
|
|
{ return ! operator == (result); }
|