fast flag

This commit is contained in:
LoganDark 2021-11-08 13:37:01 -08:00
parent 5c8971b895
commit 937c5e91a6
No known key found for this signature in database
GPG key ID: B8C37CEDE1AC60EA

View file

@ -14,6 +14,7 @@ LUAU_FASTFLAGVARIABLE(LuauPreloadClosures, false)
LUAU_FASTFLAGVARIABLE(LuauPreloadClosuresFenv, false)
LUAU_FASTFLAGVARIABLE(LuauPreloadClosuresUpval, false)
LUAU_FASTFLAG(LuauIfElseExpressionBaseSupport)
LUAU_FASTFLAG(LuauGenericSpecialGlobals)
namespace Luau
{
@ -22,6 +23,8 @@ static const uint32_t kMaxRegisterCount = 255;
static const uint32_t kMaxUpvalueCount = 200;
static const uint32_t kMaxLocalCount = 200;
static const char* kSpecialGlobals[] = {"Game", "Workspace", "_G", "game", "plugin", "script", "shared", "workspace"};
CompileError::CompileError(const Location& location, const std::string& message)
: location(location)
, message(message)
@ -3702,21 +3705,30 @@ void compileOrThrow(BytecodeBuilder& bytecode, AstStatBlock* root, const AstName
Compiler compiler(bytecode, options);
// since access to some global objects may result in values that change over time, we block imports from non-readonly tables
if (FFlag::LuauGenericSpecialGlobals)
{
AstName name = names.get("_G");
if (name.value)
compiler.globals[name].writable = true;
}
if (options.mutableGlobalNames)
for (const char** ptr = options.mutableGlobalNames; *ptr != NULL; ++ptr)
if (options.mutableGlobalNames)
for (const char** ptr = options.mutableGlobalNames; *ptr != NULL; ++ptr)
{
AstName name = names.get(*ptr);
if (name.value)
compiler.globals[name].writable = true;
}
} else {
for (const char* global : kSpecialGlobals)
{
AstName name = names.get(*ptr);
AstName name = names.get(global);
if (name.value)
compiler.globals[name].writable = true;
}
}
// this visitor traverses the AST to analyze mutability of locals/globals, filling Local::written and Global::written
Compiler::AssignmentVisitor assignmentVisitor(&compiler);