@@ -202,6 +202,8 @@ enum class NormalizationResult
202202// * G is a union of generic/free/blocked types, intersected with a normalized type
203203struct NormalizedType
204204{
205+ NotNull<BuiltinTypes> builtinTypes;
206+
205207 // The top part of the type.
206208 // This type is either never, unknown, or any.
207209 // If this type is not never, all the other fields are null.
@@ -315,6 +317,8 @@ class Normalizer
315317 DenseHashMap<TypeId, bool > cachedIsInhabited{nullptr };
316318 DenseHashMap<std::pair<TypeId, TypeId>, bool , TypeIdPairHash> cachedIsInhabitedIntersection{{nullptr , nullptr }};
317319
320+ std::optional<int > fuel{std::nullopt };
321+
318322 bool withinResourceLimits ();
319323 bool useNewLuauSolver () const ;
320324
@@ -340,13 +344,29 @@ class Normalizer
340344
341345 // If this returns null, the typechecker should emit a "too complex" error
342346 std::shared_ptr<const NormalizedType> normalize (TypeId ty);
343- void clearNormal (NormalizedType& norm);
344347
348+ void clearCaches ();
349+
350+ NormalizationResult isIntersectionInhabited (TypeId left, TypeId right);
351+
352+ // Check for inhabitance
353+ NormalizationResult isInhabited (TypeId ty);
354+ NormalizationResult isInhabited (const NormalizedType* norm);
355+
356+ // -------- Convert back from a normalized type to a type
357+ TypeId typeFromNormal (const NormalizedType& norm);
358+
359+ std::optional<TypePackId> intersectionOfTypePacks (TypePackId here, TypePackId there);
360+
361+ // Move to private with LuauNormalizerStepwiseFuel
362+ std::optional<TypePackId> intersectionOfTypePacks_INTERNAL (TypePackId here, TypePackId there);
363+
364+ private:
345365 // ------- Cached TypeIds
346366 TypeId unionType (TypeId here, TypeId there);
347367 TypeId intersectionType (TypeId here, TypeId there);
348368 const TypeIds* cacheTypeIds (TypeIds tys);
349- void clearCaches ( );
369+ void clearNormal (NormalizedType& norm );
350370
351371 // ------- Normalizing unions
352372 void unionTysWithTy (TypeIds& here, TypeId there);
@@ -387,7 +407,6 @@ class Normalizer
387407 void intersectExternTypes (NormalizedExternType& heres, const NormalizedExternType& theres);
388408 void intersectExternTypesWithExternType (NormalizedExternType& heres, TypeId there);
389409 void intersectStrings (NormalizedStringType& here, const NormalizedStringType& there);
390- std::optional<TypePackId> intersectionOfTypePacks (TypePackId here, TypePackId there);
391410 std::optional<TypeId> intersectionOfTables (TypeId here, TypeId there, SeenTablePropPairs& seenTablePropPairs, Set<TypeId>& seenSet);
392411 void intersectTablesWithTable (TypeIds& heres, TypeId there, SeenTablePropPairs& seenTablePropPairs, Set<TypeId>& seenSetTypes);
393412 void intersectTables (TypeIds& heres, const TypeIds& theres);
@@ -409,18 +428,20 @@ class Normalizer
409428 Set<TypeId>& seenSet
410429 );
411430
412- // Check for inhabitance
413- NormalizationResult isInhabited (TypeId ty);
414431 NormalizationResult isInhabited (TypeId ty, Set<TypeId>& seen);
415- NormalizationResult isInhabited (const NormalizedType* norm);
416432 NormalizationResult isInhabited (const NormalizedType* norm, Set<TypeId>& seen);
417433
418434 // Check for intersections being inhabited
419- NormalizationResult isIntersectionInhabited (TypeId left, TypeId right);
420435 NormalizationResult isIntersectionInhabited (TypeId left, TypeId right, SeenTablePropPairs& seenTablePropPairs, Set<TypeId>& seenSet);
421436
422- // -------- Convert back from a normalized type to a type
423- TypeId typeFromNormal (const NormalizedType& norm);
437+
438+ // Fuel setup
439+
440+ bool initializeFuel ();
441+ void clearFuel ();
442+ void consumeFuel ();
443+
444+ friend struct FuelInitializer ;
424445};
425446
426447} // namespace Luau
0 commit comments