2021-11-05 23:47:21 +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-01-05 04:53:17 +08:00
|
|
|
#include "Luau/Type.h"
|
2023-05-13 01:50:47 +08:00
|
|
|
#include "Luau/DenseHash.h"
|
|
|
|
|
|
|
|
#include <vector>
|
2021-11-05 23:47:21 +08:00
|
|
|
|
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
|
2022-06-17 09:05:14 +08:00
|
|
|
struct TypeArena;
|
2022-07-29 12:24:07 +08:00
|
|
|
struct Scope;
|
2022-06-04 06:15:45 +08:00
|
|
|
|
2022-02-18 09:18:01 +08:00
|
|
|
void quantify(TypeId ty, TypeLevel level);
|
2023-05-13 01:50:47 +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 23:47:21 +08:00
|
|
|
|
|
|
|
} // namespace Luau
|