mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 22:35:43 +08:00
944e8375aa
- Type aliases can no longer override primitive types; attempts to do that will result in a type error - Fix misleading type error messages for mismatches in expression list length during assignment - Fix incorrect type name display in certain cases - setmetatable/getmetatable are now ~2x faster - tools/perfstat.py can be used to display statistics about profiles captured via --profile switch
58 lines
1.6 KiB
C++
58 lines
1.6 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/Substitution.h"
|
|
#include "Luau/TypeVar.h"
|
|
#include "Luau/Unifiable.h"
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
struct TypeArena;
|
|
struct TxnLog;
|
|
|
|
// A substitution which replaces generic types in a given set by free types.
|
|
struct ReplaceGenerics : Substitution
|
|
{
|
|
ReplaceGenerics(const TxnLog* log, TypeArena* arena, TypeLevel level, Scope* scope, const std::vector<TypeId>& generics,
|
|
const std::vector<TypePackId>& genericPacks)
|
|
: Substitution(log, arena)
|
|
, level(level)
|
|
, scope(scope)
|
|
, generics(generics)
|
|
, genericPacks(genericPacks)
|
|
{
|
|
}
|
|
|
|
TypeLevel level;
|
|
Scope* scope;
|
|
std::vector<TypeId> generics;
|
|
std::vector<TypePackId> genericPacks;
|
|
bool ignoreChildren(TypeId ty) override;
|
|
bool isDirty(TypeId ty) override;
|
|
bool isDirty(TypePackId tp) override;
|
|
TypeId clean(TypeId ty) override;
|
|
TypePackId clean(TypePackId tp) override;
|
|
};
|
|
|
|
// A substitution which replaces generic functions by monomorphic functions
|
|
struct Instantiation : Substitution
|
|
{
|
|
Instantiation(const TxnLog* log, TypeArena* arena, TypeLevel level, Scope* scope)
|
|
: Substitution(log, arena)
|
|
, level(level)
|
|
, scope(scope)
|
|
{
|
|
}
|
|
|
|
TypeLevel level;
|
|
Scope* scope;
|
|
bool ignoreChildren(TypeId ty) override;
|
|
bool isDirty(TypeId ty) override;
|
|
bool isDirty(TypePackId tp) override;
|
|
TypeId clean(TypeId ty) override;
|
|
TypePackId clean(TypePackId tp) override;
|
|
};
|
|
|
|
} // namespace Luau
|