mirror of
https://github.com/luau-lang/luau.git
synced 2025-01-09 04:49:10 +00:00
35 lines
1.5 KiB
C++
35 lines
1.5 KiB
C++
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
||
|
|
||
|
#include "Luau/GlobalTypes.h"
|
||
|
|
||
|
LUAU_FASTFLAG(LuauInitializeStringMetatableInGlobalTypes)
|
||
|
|
||
|
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});
|
||
|
globalScope->addBuiltinTypeBinding("unknown", TypeFun{{}, builtinTypes->unknownType});
|
||
|
globalScope->addBuiltinTypeBinding("never", TypeFun{{}, builtinTypes->neverType});
|
||
|
|
||
|
if (FFlag::LuauInitializeStringMetatableInGlobalTypes)
|
||
|
{
|
||
|
unfreeze(*builtinTypes->arena);
|
||
|
TypeId stringMetatableTy = makeStringMetatable(builtinTypes);
|
||
|
asMutable(builtinTypes->stringType)->ty.emplace<PrimitiveType>(PrimitiveType::String, stringMetatableTy);
|
||
|
persist(stringMetatableTy);
|
||
|
freeze(*builtinTypes->arena);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|