|
| 1 | +// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details |
| 2 | +#pragma once |
| 3 | + |
| 4 | +#include "TypeInfer.h" |
| 5 | + |
| 6 | +namespace Luau |
| 7 | +{ |
| 8 | + |
| 9 | +void registerBuiltinTypes(TypeChecker& typeChecker); |
| 10 | + |
| 11 | +TypeId makeUnion(TypeArena& arena, std::vector<TypeId>&& types); |
| 12 | +TypeId makeIntersection(TypeArena& arena, std::vector<TypeId>&& types); |
| 13 | + |
| 14 | +/** Build an optional 't' |
| 15 | + */ |
| 16 | +TypeId makeOption(TypeChecker& typeChecker, TypeArena& arena, TypeId t); |
| 17 | + |
| 18 | +/** Small utility function for building up type definitions from C++. |
| 19 | + */ |
| 20 | +TypeId makeFunction( // Monomorphic |
| 21 | + TypeArena& arena, std::optional<TypeId> selfType, std::initializer_list<TypeId> paramTypes, std::initializer_list<TypeId> retTypes); |
| 22 | + |
| 23 | +TypeId makeFunction( // Polymorphic |
| 24 | + TypeArena& arena, std::optional<TypeId> selfType, std::initializer_list<TypeId> generics, std::initializer_list<TypePackId> genericPacks, |
| 25 | + std::initializer_list<TypeId> paramTypes, std::initializer_list<TypeId> retTypes); |
| 26 | + |
| 27 | +TypeId makeFunction( // Monomorphic |
| 28 | + TypeArena& arena, std::optional<TypeId> selfType, std::initializer_list<TypeId> paramTypes, std::initializer_list<std::string> paramNames, |
| 29 | + std::initializer_list<TypeId> retTypes); |
| 30 | + |
| 31 | +TypeId makeFunction( // Polymorphic |
| 32 | + TypeArena& arena, std::optional<TypeId> selfType, std::initializer_list<TypeId> generics, std::initializer_list<TypePackId> genericPacks, |
| 33 | + std::initializer_list<TypeId> paramTypes, std::initializer_list<std::string> paramNames, std::initializer_list<TypeId> retTypes); |
| 34 | + |
| 35 | +void attachMagicFunction(TypeId ty, MagicFunction fn); |
| 36 | +void attachFunctionTag(TypeId ty, std::string constraint); |
| 37 | + |
| 38 | +Property makeProperty(TypeId ty, std::optional<std::string> documentationSymbol = std::nullopt); |
| 39 | +void assignPropDocumentationSymbols(TableTypeVar::Props& props, const std::string& baseName); |
| 40 | + |
| 41 | +std::string getBuiltinDefinitionSource(); |
| 42 | + |
| 43 | +void addGlobalBinding(TypeChecker& typeChecker, const std::string& name, TypeId ty, const std::string& packageName); |
| 44 | +void addGlobalBinding(TypeChecker& typeChecker, const std::string& name, Binding binding); |
| 45 | +void addGlobalBinding(TypeChecker& typeChecker, const ScopePtr& scope, const std::string& name, TypeId ty, const std::string& packageName); |
| 46 | +void addGlobalBinding(TypeChecker& typeChecker, const ScopePtr& scope, const std::string& name, Binding binding); |
| 47 | +std::optional<Binding> tryGetGlobalBinding(TypeChecker& typeChecker, const std::string& name); |
| 48 | +Binding* tryGetGlobalBindingRef(TypeChecker& typeChecker, const std::string& name); |
| 49 | +TypeId getGlobalBinding(TypeChecker& typeChecker, const std::string& name); |
| 50 | + |
| 51 | +} // namespace Luau |
0 commit comments