mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 14:25:44 +08:00
54324867df
* Support `["prop"]` syntax on class definitions in definition files. (#704) * Improve type checking performance for complex overloaded functions * Fix rare cases of incorrect stack traces for out of memory errors at runtime
54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
#pragma once
|
|
|
|
#include "Luau/Variant.h"
|
|
#include "Luau/Symbol.h"
|
|
|
|
#include <memory>
|
|
#include <unordered_map>
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
struct TypeVar;
|
|
using TypeId = const TypeVar*;
|
|
|
|
struct Field;
|
|
|
|
// Deprecated. Do not use in new work.
|
|
using LValue = Variant<Symbol, Field>;
|
|
|
|
struct Field
|
|
{
|
|
std::shared_ptr<LValue> parent;
|
|
std::string key;
|
|
|
|
bool operator==(const Field& rhs) const;
|
|
bool operator!=(const Field& rhs) const;
|
|
};
|
|
|
|
struct LValueHasher
|
|
{
|
|
size_t operator()(const LValue& lvalue) const;
|
|
};
|
|
|
|
const LValue* baseof(const LValue& lvalue);
|
|
|
|
std::optional<LValue> tryGetLValue(const class AstExpr& expr);
|
|
|
|
// Utility function: breaks down an LValue to get at the Symbol
|
|
Symbol getBaseSymbol(const LValue& lvalue);
|
|
|
|
template<typename T>
|
|
const T* get(const LValue& lvalue)
|
|
{
|
|
return get_if<T>(&lvalue);
|
|
}
|
|
|
|
using RefinementMap = std::unordered_map<LValue, TypeId, LValueHasher>;
|
|
|
|
void merge(RefinementMap& l, const RefinementMap& r, std::function<TypeId(TypeId, TypeId)> f);
|
|
void addRefinement(RefinementMap& refis, const LValue& lvalue, TypeId ty);
|
|
|
|
} // namespace Luau
|