mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-13 13:30:40 +00:00
fd6250cf9d
### What's Changed - Improve readability of unions and intersections by limiting the number of elements of those types that can be presented on a single line (gated under `FFlag::LuauToStringSimpleCompositeTypesSingleLine`) - Adds a new option to the compiler `--record-stats` to record and output compilation statistics - `if...then...else` expressions are now optimized into `AND/OR` form when possible. ### VM - Add a new `buffer` type to Luau based on the [buffer RFC](https://github.com/Roblox/luau/pull/739) and additional C API functions to work with it; this release does not include the library. - Internal C API to work with string buffers has been updated to align with Lua version more closely ### Native Codegen - Added support for new X64 instruction (rev) and new A64 instruction (bswap) in the assembler - Simplified the way numerical loop condition is translated to IR ### New Type Solver - Operator inference now handled by type families - Created a new system called `Type Paths` to explain why subtyping tests fail in order to improve the quality of error messages. - Systematic changes to implement Data Flow analysis in the new solver (`Breadcrumb` removed and replaced with `RefinementKey`) --- Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: Lily Brown <lbrown@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Lily Brown <lbrown@roblox.com> Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com>
82 lines
2.6 KiB
C++
82 lines
2.6 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
#pragma once
|
|
|
|
#include "Luau/NotNull.h"
|
|
#include "Luau/Substitution.h"
|
|
#include "Luau/TypeFwd.h"
|
|
#include "Luau/Unifiable.h"
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
struct TxnLog;
|
|
struct TypeArena;
|
|
struct TypeCheckLimits;
|
|
|
|
// A substitution which replaces generic types in a given set by free types.
|
|
struct ReplaceGenerics : Substitution
|
|
{
|
|
ReplaceGenerics(const TxnLog* log, TypeArena* arena, NotNull<BuiltinTypes> builtinTypes, TypeLevel level, Scope* scope,
|
|
const std::vector<TypeId>& generics, const std::vector<TypePackId>& genericPacks)
|
|
: Substitution(log, arena)
|
|
, builtinTypes(builtinTypes)
|
|
, level(level)
|
|
, scope(scope)
|
|
, generics(generics)
|
|
, genericPacks(genericPacks)
|
|
{
|
|
}
|
|
|
|
NotNull<BuiltinTypes> builtinTypes;
|
|
|
|
TypeLevel level;
|
|
Scope* scope;
|
|
std::vector<TypeId> generics;
|
|
std::vector<TypePackId> genericPacks;
|
|
bool ignoreChildren(TypeId ty) override;
|
|
bool isDirty(TypeId ty) override;
|
|
bool isDirty(TypePackId tp) override;
|
|
TypeId clean(TypeId ty) override;
|
|
TypePackId clean(TypePackId tp) override;
|
|
};
|
|
|
|
// A substitution which replaces generic functions by monomorphic functions
|
|
struct Instantiation : Substitution
|
|
{
|
|
Instantiation(const TxnLog* log, TypeArena* arena, NotNull<BuiltinTypes> builtinTypes, TypeLevel level, Scope* scope)
|
|
: Substitution(log, arena)
|
|
, builtinTypes(builtinTypes)
|
|
, level(level)
|
|
, scope(scope)
|
|
{
|
|
}
|
|
|
|
NotNull<BuiltinTypes> builtinTypes;
|
|
|
|
TypeLevel level;
|
|
Scope* scope;
|
|
bool ignoreChildren(TypeId ty) override;
|
|
bool isDirty(TypeId ty) override;
|
|
bool isDirty(TypePackId tp) override;
|
|
TypeId clean(TypeId ty) override;
|
|
TypePackId clean(TypePackId tp) override;
|
|
};
|
|
|
|
/** Attempt to instantiate a type. Only used under local type inference.
|
|
*
|
|
* When given a generic function type, instantiate() will return a copy with the
|
|
* generics replaced by fresh types. Instantiation will return the same TypeId
|
|
* back if the function does not have any generics.
|
|
*
|
|
* All higher order generics are left as-is. For example, instantiation of
|
|
* <X>(<Y>(Y) -> (X, Y)) -> (X, Y) is (<Y>(Y) -> ('x, Y)) -> ('x, Y)
|
|
*
|
|
* We substitute the generic X for the free 'x, but leave the generic Y alone.
|
|
*
|
|
* Instantiation fails only when processing the type causes internal recursion
|
|
* limits to be exceeded.
|
|
*/
|
|
std::optional<TypeId> instantiate(
|
|
NotNull<BuiltinTypes> builtinTypes, NotNull<TypeArena> arena, NotNull<TypeCheckLimits> limits, NotNull<Scope> scope, TypeId ty);
|
|
|
|
} // namespace Luau
|