2021-11-05 10:42:00 +08:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#pragma once
|
|
|
|
|
2023-10-21 04:36:26 +08:00
|
|
|
#include "Luau/TypeFwd.h"
|
2023-05-12 20:15:01 +08:00
|
|
|
#include "Luau/DenseHash.h"
|
2023-10-21 04:36:26 +08:00
|
|
|
#include "Luau/Unifiable.h"
|
2023-05-12 20:15:01 +08:00
|
|
|
|
|
|
|
#include <vector>
|
2023-10-21 04:36:26 +08:00
|
|
|
#include <optional>
|
2021-11-05 10:42:00 +08:00
|
|
|
|
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
|
2022-06-17 08:54:42 +08:00
|
|
|
struct TypeArena;
|
2022-07-29 11:41:13 +08:00
|
|
|
struct Scope;
|
2022-06-04 04:32:20 +08:00
|
|
|
|
2022-02-18 08:41:20 +08:00
|
|
|
void quantify(TypeId ty, TypeLevel level);
|
2023-05-12 20:15:01 +08:00
|
|
|
|
|
|
|
// TODO: This is eerily similar to the pattern that NormalizedClassType
|
|
|
|
// implements. We could, and perhaps should, merge them together.
|
|
|
|
template<typename K, typename V>
|
|
|
|
struct OrderedMap
|
|
|
|
{
|
|
|
|
std::vector<K> keys;
|
|
|
|
DenseHashMap<K, V> pairings{nullptr};
|
|
|
|
|
|
|
|
void push(K k, V v)
|
|
|
|
{
|
|
|
|
keys.push_back(k);
|
|
|
|
pairings[k] = v;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct QuantifierResult
|
|
|
|
{
|
|
|
|
TypeId result;
|
|
|
|
OrderedMap<TypeId, TypeId> insertedGenerics;
|
|
|
|
OrderedMap<TypePackId, TypePackId> insertedGenericPacks;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::optional<QuantifierResult> quantify(TypeArena* arena, TypeId ty, Scope* scope);
|
2021-11-05 10:42:00 +08:00
|
|
|
|
|
|
|
} // namespace Luau
|