Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/Analysis/include/Luau/LValue.h
2727 views
1
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
#pragma once
3
4
#include "Luau/Variant.h"
5
#include "Luau/Symbol.h"
6
#include "Luau/TypeFwd.h"
7
8
#include <memory>
9
#include <unordered_map>
10
11
namespace Luau
12
{
13
14
struct Field;
15
16
// Deprecated. Do not use in new work.
17
using LValue = Variant<Symbol, Field>;
18
19
struct Field
20
{
21
std::shared_ptr<LValue> parent;
22
std::string key;
23
24
bool operator==(const Field& rhs) const;
25
bool operator!=(const Field& rhs) const;
26
};
27
28
struct LValueHasher
29
{
30
size_t operator()(const LValue& lvalue) const;
31
};
32
33
const LValue* baseof(const LValue& lvalue);
34
35
std::optional<LValue> tryGetLValue(const class AstExpr& expr);
36
37
// Utility function: breaks down an LValue to get at the Symbol
38
Symbol getBaseSymbol(const LValue& lvalue);
39
40
template<typename T>
41
const T* get(const LValue& lvalue)
42
{
43
return get_if<T>(&lvalue);
44
}
45
46
using RefinementMap = std::unordered_map<LValue, TypeId, LValueHasher>;
47
48
void merge(RefinementMap& l, const RefinementMap& r, std::function<TypeId(TypeId, TypeId)> f);
49
void addRefinement(RefinementMap& refis, const LValue& lvalue, TypeId ty);
50
51
} // namespace Luau
52
53