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
|
|
|
|
|
|
|
|
#include "Luau/DenseHash.h"
|
2022-03-25 06:04:14 +08:00
|
|
|
#include "Luau/Error.h"
|
2023-01-05 04:53:17 +08:00
|
|
|
#include "Luau/Type.h"
|
2021-11-05 23:47:21 +08:00
|
|
|
#include "Luau/TypePack.h"
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
struct InternalErrorReporter;
|
|
|
|
|
|
|
|
struct TypeIdPairHash
|
|
|
|
{
|
|
|
|
size_t hashOne(Luau::TypeId key) const
|
|
|
|
{
|
|
|
|
return (uintptr_t(key) >> 4) ^ (uintptr_t(key) >> 9);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t operator()(const std::pair<Luau::TypeId, Luau::TypeId>& x) const
|
|
|
|
{
|
|
|
|
return hashOne(x.first) ^ (hashOne(x.second) << 1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-12-03 14:41:04 +08:00
|
|
|
struct UnifierCounters
|
|
|
|
{
|
|
|
|
int recursionCount = 0;
|
2022-04-15 07:57:43 +08:00
|
|
|
int recursionLimit = 0;
|
2021-12-03 14:41:04 +08:00
|
|
|
int iterationCount = 0;
|
2022-04-15 07:57:43 +08:00
|
|
|
int iterationLimit = 0;
|
2021-12-03 14:41:04 +08:00
|
|
|
};
|
|
|
|
|
2021-11-05 23:47:21 +08:00
|
|
|
struct UnifierSharedState
|
|
|
|
{
|
|
|
|
UnifierSharedState(InternalErrorReporter* iceHandler)
|
|
|
|
: iceHandler(iceHandler)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
InternalErrorReporter* iceHandler;
|
|
|
|
|
|
|
|
DenseHashMap<TypeId, bool> skipCacheForType{nullptr};
|
|
|
|
DenseHashSet<std::pair<TypeId, TypeId>, TypeIdPairHash> cachedUnify{{nullptr, nullptr}};
|
2022-03-25 06:04:14 +08:00
|
|
|
DenseHashMap<std::pair<TypeId, TypeId>, TypeErrorData, TypeIdPairHash> cachedUnifyError{{nullptr, nullptr}};
|
2021-11-05 23:47:21 +08:00
|
|
|
|
|
|
|
DenseHashSet<TypeId> tempSeenTy{nullptr};
|
|
|
|
DenseHashSet<TypePackId> tempSeenTp{nullptr};
|
2021-12-03 14:41:04 +08:00
|
|
|
|
|
|
|
UnifierCounters counters;
|
2021-11-05 23:47:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Luau
|