2023-09-08 01:13:49 +01:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
|
|
|
|
#include "Luau/GlobalTypes.h"
|
|
|
|
|
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
|
|
|
|
GlobalTypes::GlobalTypes(NotNull<BuiltinTypes> builtinTypes)
|
|
|
|
: builtinTypes(builtinTypes)
|
|
|
|
{
|
|
|
|
globalScope = std::make_shared<Scope>(globalTypes.addTypePack(TypePackVar{FreeTypePack{TypeLevel{}}}));
|
|
|
|
|
|
|
|
globalScope->addBuiltinTypeBinding("any", TypeFun{{}, builtinTypes->anyType});
|
|
|
|
globalScope->addBuiltinTypeBinding("nil", TypeFun{{}, builtinTypes->nilType});
|
|
|
|
globalScope->addBuiltinTypeBinding("number", TypeFun{{}, builtinTypes->numberType});
|
|
|
|
globalScope->addBuiltinTypeBinding("string", TypeFun{{}, builtinTypes->stringType});
|
|
|
|
globalScope->addBuiltinTypeBinding("boolean", TypeFun{{}, builtinTypes->booleanType});
|
|
|
|
globalScope->addBuiltinTypeBinding("thread", TypeFun{{}, builtinTypes->threadType});
|
2024-01-19 18:04:46 +00:00
|
|
|
globalScope->addBuiltinTypeBinding("buffer", TypeFun{{}, builtinTypes->bufferType});
|
2023-09-08 01:13:49 +01:00
|
|
|
globalScope->addBuiltinTypeBinding("unknown", TypeFun{{}, builtinTypes->unknownType});
|
|
|
|
globalScope->addBuiltinTypeBinding("never", TypeFun{{}, builtinTypes->neverType});
|
|
|
|
|
2024-01-12 22:25:27 +00:00
|
|
|
unfreeze(*builtinTypes->arena);
|
|
|
|
TypeId stringMetatableTy = makeStringMetatable(builtinTypes);
|
|
|
|
asMutable(builtinTypes->stringType)->ty.emplace<PrimitiveType>(PrimitiveType::String, stringMetatableTy);
|
|
|
|
persist(stringMetatableTy);
|
|
|
|
freeze(*builtinTypes->arena);
|
2023-09-08 01:13:49 +01:00
|
|
|
}
|
|
|
|
|
2023-09-15 18:26:59 +01:00
|
|
|
} // namespace Luau
|