mirror of
https://github.com/luau-lang/luau.git
synced 2025-01-10 05:19:10 +00:00
32 lines
924 B
C++
32 lines
924 B
C++
// 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"
|
|
|
|
LUAU_FASTFLAG(DebugLuauDeferredConstraintResolution)
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
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;
|
|
}
|
|
|
|
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
|