2021-10-29 21:25:12 +01:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#pragma once
|
|
|
|
|
2021-11-05 02:34:35 +00:00
|
|
|
#include "Luau/Scope.h"
|
2023-01-04 20:53:17 +00:00
|
|
|
#include "Luau/Type.h"
|
2022-12-09 19:57:01 +00:00
|
|
|
|
|
|
|
#include <optional>
|
2021-10-29 21:25:12 +01:00
|
|
|
|
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
|
2022-12-09 19:57:01 +00:00
|
|
|
struct Frontend;
|
2023-03-10 20:21:07 +00:00
|
|
|
struct GlobalTypes;
|
2022-12-09 19:57:01 +00:00
|
|
|
struct TypeChecker;
|
|
|
|
struct TypeArena;
|
|
|
|
|
2023-04-07 22:01:29 +01:00
|
|
|
void registerBuiltinGlobals(Frontend& frontend, GlobalTypes& globals, bool typeCheckForAutocomplete = false);
|
2021-10-29 21:25:12 +01:00
|
|
|
TypeId makeUnion(TypeArena& arena, std::vector<TypeId>&& types);
|
|
|
|
TypeId makeIntersection(TypeArena& arena, std::vector<TypeId>&& types);
|
|
|
|
|
|
|
|
/** Build an optional 't'
|
|
|
|
*/
|
2023-03-10 20:21:07 +00:00
|
|
|
TypeId makeOption(NotNull<BuiltinTypes> builtinTypes, TypeArena& arena, TypeId t);
|
2021-10-29 21:25:12 +01:00
|
|
|
|
|
|
|
/** 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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
void attachMagicFunction(TypeId ty, MagicFunction fn);
|
2022-09-02 00:14:03 +01:00
|
|
|
void attachDcrMagicFunction(TypeId ty, DcrMagicFunction fn);
|
2022-12-02 18:09:59 +00:00
|
|
|
void attachDcrMagicRefinement(TypeId ty, DcrMagicRefinement fn);
|
2021-10-29 21:25:12 +01:00
|
|
|
|
|
|
|
Property makeProperty(TypeId ty, std::optional<std::string> documentationSymbol = std::nullopt);
|
2023-01-04 20:53:17 +00:00
|
|
|
void assignPropDocumentationSymbols(TableType::Props& props, const std::string& baseName);
|
2021-10-29 21:25:12 +01:00
|
|
|
|
|
|
|
std::string getBuiltinDefinitionSource();
|
|
|
|
|
2023-03-10 20:21:07 +00:00
|
|
|
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);
|
2021-10-29 21:25:12 +01:00
|
|
|
|
|
|
|
} // namespace Luau
|