2021-10-29 21:25:12 +01:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#include "Luau/Symbol.h"
|
|
|
|
|
|
|
|
#include "Luau/Common.h"
|
|
|
|
|
2023-07-28 12:37:00 +01:00
|
|
|
LUAU_FASTFLAG(DebugLuauDeferredConstraintResolution)
|
|
|
|
|
2021-10-29 21:25:12 +01:00
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
|
2023-07-28 12:37:00 +01:00
|
|
|
bool Symbol::operator==(const Symbol& rhs) const
|
|
|
|
{
|
|
|
|
if (local)
|
|
|
|
return local == rhs.local;
|
|
|
|
else if (global.value)
|
|
|
|
return rhs.global.value && global == rhs.global.value; // Subtlety: AstName::operator==(const char*) uses strcmp, not pointer identity.
|
|
|
|
else if (FFlag::DebugLuauDeferredConstraintResolution)
|
|
|
|
return !rhs.local && !rhs.global.value; // Reflexivity: we already know `this` Symbol is empty, so check that rhs is.
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-10-29 21:25:12 +01:00
|
|
|
std::string toString(const Symbol& name)
|
|
|
|
{
|
|
|
|
if (name.local)
|
|
|
|
return name.local->name.value;
|
|
|
|
|
|
|
|
LUAU_ASSERT(name.global.value);
|
|
|
|
return name.global.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Luau
|