mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-12 21:10:37 +00:00
e491128f95
## What's new * Added `math.map` function to the standard library, based on https://rfcs.luau-lang.org/function-math-map.html * `FileResolver` can provide an implementation of `getRequireSuggestions` to provide auto-complete suggestions for require-by-string ## New Solver * In user-defined type functions, `readproperty` and `writeproperty` will return `nil` instead of erroring if property is not found * Fixed incorrect scope of variadic arguments in the data-flow graph * Fixed multiple assertion failures --- Internal Contributors: Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Varun Saini <vsaini@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
85 lines
3.1 KiB
C++
85 lines
3.1 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/Scope.h"
|
|
#include "Luau/Type.h"
|
|
|
|
#include <optional>
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
static constexpr char kRequireTagName[] = "require";
|
|
|
|
struct Frontend;
|
|
struct GlobalTypes;
|
|
struct TypeChecker;
|
|
struct TypeArena;
|
|
struct Subtyping;
|
|
|
|
void registerBuiltinGlobals(Frontend& frontend, GlobalTypes& globals, bool typeCheckForAutocomplete = false);
|
|
TypeId makeUnion(TypeArena& arena, std::vector<TypeId>&& types);
|
|
TypeId makeIntersection(TypeArena& arena, std::vector<TypeId>&& types);
|
|
|
|
/** Build an optional 't'
|
|
*/
|
|
TypeId makeOption(NotNull<BuiltinTypes> builtinTypes, TypeArena& arena, TypeId t);
|
|
|
|
/** Small utility function for building up type definitions from C++.
|
|
*/
|
|
TypeId makeFunction( // Monomorphic
|
|
TypeArena& arena,
|
|
std::optional<TypeId> selfType,
|
|
std::initializer_list<TypeId> paramTypes,
|
|
std::initializer_list<TypeId> retTypes,
|
|
bool checked = false
|
|
);
|
|
|
|
TypeId makeFunction( // Polymorphic
|
|
TypeArena& arena,
|
|
std::optional<TypeId> selfType,
|
|
std::initializer_list<TypeId> generics,
|
|
std::initializer_list<TypePackId> genericPacks,
|
|
std::initializer_list<TypeId> paramTypes,
|
|
std::initializer_list<TypeId> retTypes,
|
|
bool checked = false
|
|
);
|
|
|
|
TypeId makeFunction( // Monomorphic
|
|
TypeArena& arena,
|
|
std::optional<TypeId> selfType,
|
|
std::initializer_list<TypeId> paramTypes,
|
|
std::initializer_list<std::string> paramNames,
|
|
std::initializer_list<TypeId> retTypes,
|
|
bool checked = false
|
|
);
|
|
|
|
TypeId makeFunction( // Polymorphic
|
|
TypeArena& arena,
|
|
std::optional<TypeId> selfType,
|
|
std::initializer_list<TypeId> generics,
|
|
std::initializer_list<TypePackId> genericPacks,
|
|
std::initializer_list<TypeId> paramTypes,
|
|
std::initializer_list<std::string> paramNames,
|
|
std::initializer_list<TypeId> retTypes,
|
|
bool checked = false
|
|
);
|
|
|
|
void attachMagicFunction(TypeId ty, MagicFunction fn);
|
|
void attachDcrMagicFunction(TypeId ty, DcrMagicFunction fn);
|
|
void attachDcrMagicRefinement(TypeId ty, DcrMagicRefinement fn);
|
|
void attachDcrMagicFunctionTypeCheck(TypeId ty, DcrMagicFunctionTypeCheck fn);
|
|
Property makeProperty(TypeId ty, std::optional<std::string> documentationSymbol = std::nullopt);
|
|
void assignPropDocumentationSymbols(TableType::Props& props, const std::string& baseName);
|
|
|
|
std::string getBuiltinDefinitionSource();
|
|
|
|
void addGlobalBinding(GlobalTypes& globals, const std::string& name, TypeId ty, const std::string& packageName);
|
|
void addGlobalBinding(GlobalTypes& globals, const std::string& name, Binding binding);
|
|
void addGlobalBinding(GlobalTypes& globals, const ScopePtr& scope, const std::string& name, TypeId ty, const std::string& packageName);
|
|
void addGlobalBinding(GlobalTypes& globals, const ScopePtr& scope, const std::string& name, Binding binding);
|
|
std::optional<Binding> tryGetGlobalBinding(GlobalTypes& globals, const std::string& name);
|
|
Binding* tryGetGlobalBindingRef(GlobalTypes& globals, const std::string& name);
|
|
TypeId getGlobalBinding(GlobalTypes& globals, const std::string& name);
|
|
|
|
} // namespace Luau
|