luau/Analysis/include/Luau/Simplify.h

39 lines
1.1 KiB
C
Raw Normal View History

2023-05-20 02:59:59 +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-11-11 02:05:48 +08:00
#include "Luau/DenseHash.h"
2023-10-21 04:36:26 +08:00
#include "Luau/NotNull.h"
#include "Luau/TypeFwd.h"
2024-06-01 01:46:33 +08:00
#include <set>
2023-05-20 02:59:59 +08:00
namespace Luau
{
struct TypeArena;
struct SimplifyResult
{
TypeId result;
2023-11-11 02:05:48 +08:00
DenseHashSet<TypeId> blockedTypes;
2023-05-20 02:59:59 +08:00
};
SimplifyResult simplifyIntersection(NotNull<BuiltinTypes> builtinTypes, NotNull<TypeArena> arena, TypeId ty, TypeId discriminant);
2024-06-01 01:46:33 +08:00
SimplifyResult simplifyIntersection(NotNull<BuiltinTypes> builtinTypes, NotNull<TypeArena> arena, std::set<TypeId> parts);
2023-05-20 02:59:59 +08:00
SimplifyResult simplifyUnion(NotNull<BuiltinTypes> builtinTypes, NotNull<TypeArena> arena, TypeId ty, TypeId discriminant);
enum class Relation
{
Disjoint, // No A is a B or vice versa
Coincident, // Every A is in B and vice versa
Intersects, // Some As are in B and some Bs are in A. ex (number | string) <-> (string | boolean)
Subset, // Every A is in B
Superset, // Every B is in A
};
Relation relate(TypeId left, TypeId right);
} // namespace Luau