mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
fast flag
This commit is contained in:
parent
5c8971b895
commit
937c5e91a6
1 changed files with 16 additions and 4 deletions
|
@ -14,6 +14,7 @@ LUAU_FASTFLAGVARIABLE(LuauPreloadClosures, false)
|
||||||
LUAU_FASTFLAGVARIABLE(LuauPreloadClosuresFenv, false)
|
LUAU_FASTFLAGVARIABLE(LuauPreloadClosuresFenv, false)
|
||||||
LUAU_FASTFLAGVARIABLE(LuauPreloadClosuresUpval, false)
|
LUAU_FASTFLAGVARIABLE(LuauPreloadClosuresUpval, false)
|
||||||
LUAU_FASTFLAG(LuauIfElseExpressionBaseSupport)
|
LUAU_FASTFLAG(LuauIfElseExpressionBaseSupport)
|
||||||
|
LUAU_FASTFLAG(LuauGenericSpecialGlobals)
|
||||||
|
|
||||||
namespace Luau
|
namespace Luau
|
||||||
{
|
{
|
||||||
|
@ -22,6 +23,8 @@ static const uint32_t kMaxRegisterCount = 255;
|
||||||
static const uint32_t kMaxUpvalueCount = 200;
|
static const uint32_t kMaxUpvalueCount = 200;
|
||||||
static const uint32_t kMaxLocalCount = 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)
|
CompileError::CompileError(const Location& location, const std::string& message)
|
||||||
: location(location)
|
: location(location)
|
||||||
, message(message)
|
, message(message)
|
||||||
|
@ -3702,21 +3705,30 @@ void compileOrThrow(BytecodeBuilder& bytecode, AstStatBlock* root, const AstName
|
||||||
Compiler compiler(bytecode, options);
|
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
|
// 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");
|
AstName name = names.get("_G");
|
||||||
|
|
||||||
if (name.value)
|
if (name.value)
|
||||||
compiler.globals[name].writable = true;
|
compiler.globals[name].writable = true;
|
||||||
}
|
|
||||||
|
|
||||||
if (options.mutableGlobalNames)
|
if (options.mutableGlobalNames)
|
||||||
for (const char** ptr = options.mutableGlobalNames; *ptr != NULL; ++ptr)
|
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)
|
if (name.value)
|
||||||
compiler.globals[name].writable = true;
|
compiler.globals[name].writable = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// this visitor traverses the AST to analyze mutability of locals/globals, filling Local::written and Global::written
|
// this visitor traverses the AST to analyze mutability of locals/globals, filling Local::written and Global::written
|
||||||
Compiler::AssignmentVisitor assignmentVisitor(&compiler);
|
Compiler::AssignmentVisitor assignmentVisitor(&compiler);
|
||||||
|
|
Loading…
Add table
Reference in a new issue