mirror of
https://github.com/luau-lang/luau.git
synced 2025-01-05 19:09:11 +00:00
a7299c3f0f
# What's Changed? - Bugfixes in the new solver ## New Solver - Equality graphs(E-Graphs) data structures were added - Refactored even more instances of "type family" with "type function" - `table.insert` no longer spuriously warns while selecting an overload for reasonable arguments. - Add time tracing for the new solver - Miscellaneous fixes to unit tests --- ### Internal Contributors Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Jeremy Yoo <jyoo@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: David Cope <dcope@roblox.com> Co-authored-by: Lily Brown <lbrown@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Junseo Yoo <jyoo@roblox.com>
135 lines
3.2 KiB
C++
135 lines
3.2 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#include "Luau/TypeArena.h"
|
|
|
|
LUAU_FASTFLAGVARIABLE(DebugLuauFreezeArena, false);
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
void TypeArena::clear()
|
|
{
|
|
types.clear();
|
|
typePacks.clear();
|
|
}
|
|
|
|
TypeId TypeArena::addTV(Type&& tv)
|
|
{
|
|
TypeId allocated = types.allocate(std::move(tv));
|
|
|
|
asMutable(allocated)->owningArena = this;
|
|
|
|
return allocated;
|
|
}
|
|
|
|
TypeId TypeArena::freshType(TypeLevel level)
|
|
{
|
|
TypeId allocated = types.allocate(FreeType{level});
|
|
|
|
asMutable(allocated)->owningArena = this;
|
|
|
|
return allocated;
|
|
}
|
|
|
|
TypeId TypeArena::freshType(Scope* scope)
|
|
{
|
|
TypeId allocated = types.allocate(FreeType{scope});
|
|
|
|
asMutable(allocated)->owningArena = this;
|
|
|
|
return allocated;
|
|
}
|
|
|
|
TypeId TypeArena::freshType(Scope* scope, TypeLevel level)
|
|
{
|
|
TypeId allocated = types.allocate(FreeType{scope, level});
|
|
|
|
asMutable(allocated)->owningArena = this;
|
|
|
|
return allocated;
|
|
}
|
|
|
|
TypePackId TypeArena::freshTypePack(Scope* scope)
|
|
{
|
|
TypePackId allocated = typePacks.allocate(FreeTypePack{scope});
|
|
|
|
asMutable(allocated)->owningArena = this;
|
|
|
|
return allocated;
|
|
}
|
|
|
|
TypePackId TypeArena::addTypePack(std::initializer_list<TypeId> types)
|
|
{
|
|
TypePackId allocated = typePacks.allocate(TypePack{std::move(types)});
|
|
|
|
asMutable(allocated)->owningArena = this;
|
|
|
|
return allocated;
|
|
}
|
|
|
|
TypePackId TypeArena::addTypePack(std::vector<TypeId> types, std::optional<TypePackId> tail)
|
|
{
|
|
TypePackId allocated = typePacks.allocate(TypePack{std::move(types), tail});
|
|
|
|
asMutable(allocated)->owningArena = this;
|
|
|
|
return allocated;
|
|
}
|
|
|
|
TypePackId TypeArena::addTypePack(TypePack tp)
|
|
{
|
|
TypePackId allocated = typePacks.allocate(std::move(tp));
|
|
|
|
asMutable(allocated)->owningArena = this;
|
|
|
|
return allocated;
|
|
}
|
|
|
|
TypePackId TypeArena::addTypePack(TypePackVar tp)
|
|
{
|
|
TypePackId allocated = typePacks.allocate(std::move(tp));
|
|
|
|
asMutable(allocated)->owningArena = this;
|
|
|
|
return allocated;
|
|
}
|
|
|
|
TypeId TypeArena::addTypeFunction(const TypeFunction& function, std::initializer_list<TypeId> types)
|
|
{
|
|
return addType(TypeFunctionInstanceType{function, std::move(types)});
|
|
}
|
|
|
|
TypeId TypeArena::addTypeFunction(const TypeFunction& function, std::vector<TypeId> typeArguments, std::vector<TypePackId> packArguments)
|
|
{
|
|
return addType(TypeFunctionInstanceType{function, std::move(typeArguments), std::move(packArguments)});
|
|
}
|
|
|
|
TypePackId TypeArena::addTypePackFunction(const TypePackFunction& function, std::initializer_list<TypeId> types)
|
|
{
|
|
return addTypePack(TypeFunctionInstanceTypePack{NotNull{&function}, std::move(types)});
|
|
}
|
|
|
|
TypePackId TypeArena::addTypePackFunction(const TypePackFunction& function, std::vector<TypeId> typeArguments, std::vector<TypePackId> packArguments)
|
|
{
|
|
return addTypePack(TypeFunctionInstanceTypePack{NotNull{&function}, std::move(typeArguments), std::move(packArguments)});
|
|
}
|
|
|
|
void freeze(TypeArena& arena)
|
|
{
|
|
if (!FFlag::DebugLuauFreezeArena)
|
|
return;
|
|
|
|
arena.types.freeze();
|
|
arena.typePacks.freeze();
|
|
}
|
|
|
|
void unfreeze(TypeArena& arena)
|
|
{
|
|
if (!FFlag::DebugLuauFreezeArena)
|
|
return;
|
|
|
|
arena.types.unfreeze();
|
|
arena.typePacks.unfreeze();
|
|
}
|
|
|
|
} // namespace Luau
|