Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/Analysis/src/Symbol.cpp
2725 views
1
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
#include "Luau/Symbol.h"
3
4
#include "Luau/Common.h"
5
6
LUAU_FASTFLAG(LuauSolverV2)
7
8
namespace Luau
9
{
10
11
bool Symbol::operator==(const Symbol& rhs) const
12
{
13
if (local)
14
return local == rhs.local;
15
else if (global.value)
16
return rhs.global.value && global == rhs.global.value; // Subtlety: AstName::operator==(const char*) uses strcmp, not pointer identity.
17
else
18
return !rhs.local && !rhs.global.value; // Reflexivity: we already know `this` Symbol is empty, so check that rhs is.
19
}
20
21
std::string toString(const Symbol& name)
22
{
23
if (name.local)
24
return name.local->name.value;
25
26
LUAU_ASSERT(name.global.value);
27
return name.global.value;
28
}
29
30
} // namespace Luau
31
32