luau/Analysis/include/Luau/Instantiation.h

58 lines
1.6 KiB
C
Raw Normal View History

2022-05-26 21:33:48 +01:00
// 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"
2023-01-03 17:33:19 +00:00
#include "Luau/Type.h"
2022-05-26 21:33:48 +01:00
#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
{
2022-09-29 23:11:54 +01:00
ReplaceGenerics(const TxnLog* log, TypeArena* arena, TypeLevel level, Scope* scope, const std::vector<TypeId>& generics,
const std::vector<TypePackId>& genericPacks)
2022-05-26 21:33:48 +01:00
: Substitution(log, arena)
, level(level)
2022-09-29 23:11:54 +01:00
, scope(scope)
2022-05-26 21:33:48 +01:00
, generics(generics)
, genericPacks(genericPacks)
{
}
TypeLevel level;
2022-09-29 23:11:54 +01:00
Scope* scope;
2022-05-26 21:33:48 +01:00
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
{
2022-09-29 23:11:54 +01:00
Instantiation(const TxnLog* log, TypeArena* arena, TypeLevel level, Scope* scope)
2022-05-26 21:33:48 +01:00
: Substitution(log, arena)
, level(level)
2022-09-29 23:11:54 +01:00
, scope(scope)
2022-05-26 21:33:48 +01:00
{
}
TypeLevel level;
2022-09-29 23:11:54 +01:00
Scope* scope;
2022-05-26 21:33:48 +01:00
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