Skip to content

Commit 73ad680

Browse files
committed
v0.10.2+luau635
1 parent ba10589 commit 73ad680

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1177
-1845
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "luau0-src"
3-
version = "0.10.1+luau630"
3+
version = "0.10.2+luau635"
44
authors = ["Aleksandr Orlenko <[email protected]>"]
55
edition = "2021"
66
repository = "https://github.com/khvzak/luau-src-rs"

luau/Ast/include/Luau/Ast.h

+12-6
Original file line numberDiff line numberDiff line change
@@ -826,11 +826,12 @@ class AstStatDeclareGlobal : public AstStat
826826
public:
827827
LUAU_RTTI(AstStatDeclareGlobal)
828828

829-
AstStatDeclareGlobal(const Location& location, const AstName& name, AstType* type);
829+
AstStatDeclareGlobal(const Location& location, const AstName& name, const Location& nameLocation, AstType* type);
830830

831831
void visit(AstVisitor* visitor) override;
832832

833833
AstName name;
834+
Location nameLocation;
834835
AstType* type;
835836
};
836837

@@ -839,13 +840,13 @@ class AstStatDeclareFunction : public AstStat
839840
public:
840841
LUAU_RTTI(AstStatDeclareFunction)
841842

842-
AstStatDeclareFunction(const Location& location, const AstName& name, const AstArray<AstGenericType>& generics,
843-
const AstArray<AstGenericTypePack>& genericPacks, const AstTypeList& params, const AstArray<AstArgumentName>& paramNames,
844-
const AstTypeList& retTypes);
843+
AstStatDeclareFunction(const Location& location, const AstName& name, const Location& nameLocation, const AstArray<AstGenericType>& generics,
844+
const AstArray<AstGenericTypePack>& genericPacks, const AstTypeList& params, const AstArray<AstArgumentName>& paramNames, bool vararg,
845+
const Location& varargLocation, const AstTypeList& retTypes);
845846

846-
AstStatDeclareFunction(const Location& location, const AstArray<AstAttr*>& attributes, const AstName& name,
847+
AstStatDeclareFunction(const Location& location, const AstArray<AstAttr*>& attributes, const AstName& name, const Location& nameLocation,
847848
const AstArray<AstGenericType>& generics, const AstArray<AstGenericTypePack>& genericPacks, const AstTypeList& params,
848-
const AstArray<AstArgumentName>& paramNames, const AstTypeList& retTypes);
849+
const AstArray<AstArgumentName>& paramNames, bool vararg, const Location& varargLocation, const AstTypeList& retTypes);
849850

850851

851852
void visit(AstVisitor* visitor) override;
@@ -854,18 +855,23 @@ class AstStatDeclareFunction : public AstStat
854855

855856
AstArray<AstAttr*> attributes;
856857
AstName name;
858+
Location nameLocation;
857859
AstArray<AstGenericType> generics;
858860
AstArray<AstGenericTypePack> genericPacks;
859861
AstTypeList params;
860862
AstArray<AstArgumentName> paramNames;
863+
bool vararg = false;
864+
Location varargLocation;
861865
AstTypeList retTypes;
862866
};
863867

864868
struct AstDeclaredClassProp
865869
{
866870
AstName name;
871+
Location nameLocation;
867872
AstType* ty = nullptr;
868873
bool isMethod = false;
874+
Location location;
869875
};
870876

871877
enum class AstTableAccess

luau/Ast/include/Luau/TimeTrace.h

+8
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ struct ThreadContext
134134
static constexpr size_t kEventFlushLimit = 8192;
135135
};
136136

137+
using ThreadContextProvider = ThreadContext& (*)();
138+
139+
inline ThreadContextProvider& threadContextProvider()
140+
{
141+
static ThreadContextProvider handler = nullptr;
142+
return handler;
143+
}
144+
137145
ThreadContext& getThreadContext();
138146

139147
struct Scope

luau/Ast/src/Ast.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -705,9 +705,10 @@ void AstStatTypeAlias::visit(AstVisitor* visitor)
705705
}
706706
}
707707

708-
AstStatDeclareGlobal::AstStatDeclareGlobal(const Location& location, const AstName& name, AstType* type)
708+
AstStatDeclareGlobal::AstStatDeclareGlobal(const Location& location, const AstName& name, const Location& nameLocation, AstType* type)
709709
: AstStat(ClassIndex(), location)
710710
, name(name)
711+
, nameLocation(nameLocation)
711712
, type(type)
712713
{
713714
}
@@ -718,30 +719,36 @@ void AstStatDeclareGlobal::visit(AstVisitor* visitor)
718719
type->visit(visitor);
719720
}
720721

721-
AstStatDeclareFunction::AstStatDeclareFunction(const Location& location, const AstName& name, const AstArray<AstGenericType>& generics,
722-
const AstArray<AstGenericTypePack>& genericPacks, const AstTypeList& params, const AstArray<AstArgumentName>& paramNames,
723-
const AstTypeList& retTypes)
722+
AstStatDeclareFunction::AstStatDeclareFunction(const Location& location, const AstName& name, const Location& nameLocation,
723+
const AstArray<AstGenericType>& generics, const AstArray<AstGenericTypePack>& genericPacks, const AstTypeList& params,
724+
const AstArray<AstArgumentName>& paramNames, bool vararg, const Location& varargLocation, const AstTypeList& retTypes)
724725
: AstStat(ClassIndex(), location)
725726
, attributes()
726727
, name(name)
728+
, nameLocation(nameLocation)
727729
, generics(generics)
728730
, genericPacks(genericPacks)
729731
, params(params)
730732
, paramNames(paramNames)
733+
, vararg(vararg)
734+
, varargLocation(varargLocation)
731735
, retTypes(retTypes)
732736
{
733737
}
734738

735739
AstStatDeclareFunction::AstStatDeclareFunction(const Location& location, const AstArray<AstAttr*>& attributes, const AstName& name,
736-
const AstArray<AstGenericType>& generics, const AstArray<AstGenericTypePack>& genericPacks, const AstTypeList& params,
737-
const AstArray<AstArgumentName>& paramNames, const AstTypeList& retTypes)
740+
const Location& nameLocation, const AstArray<AstGenericType>& generics, const AstArray<AstGenericTypePack>& genericPacks,
741+
const AstTypeList& params, const AstArray<AstArgumentName>& paramNames, bool vararg, const Location& varargLocation, const AstTypeList& retTypes)
738742
: AstStat(ClassIndex(), location)
739743
, attributes(attributes)
740744
, name(name)
745+
, nameLocation(nameLocation)
741746
, generics(generics)
742747
, genericPacks(genericPacks)
743748
, params(params)
744749
, paramNames(paramNames)
750+
, vararg(vararg)
751+
, varargLocation(varargLocation)
745752
, retTypes(retTypes)
746753
{
747754
}

luau/Ast/src/Parser.cpp

+69-22
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ LUAU_FASTFLAG(LuauAttributeSyntax)
2121
LUAU_FASTFLAGVARIABLE(LuauLeadingBarAndAmpersand2, false)
2222
LUAU_FASTFLAGVARIABLE(LuauNativeAttribute, false)
2323
LUAU_FASTFLAGVARIABLE(LuauAttributeSyntaxFunExpr, false)
24+
LUAU_FASTFLAGVARIABLE(LuauDeclarationExtraPropData, false)
2425

2526
namespace Luau
2627
{
@@ -796,7 +797,7 @@ AstStat* Parser::parseAttributeStat()
796797
}
797798
default:
798799
return reportStatError(lexer.current().location, {}, {},
799-
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got %s intead",
800+
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got %s instead",
800801
lexer.current().toString().c_str());
801802
}
802803
}
@@ -835,7 +836,7 @@ AstStat* Parser::parseLocal(const AstArray<AstAttr*>& attributes)
835836
{
836837
if (FFlag::LuauAttributeSyntax && attributes.size != 0)
837838
{
838-
return reportStatError(lexer.current().location, {}, {}, "Expected 'function' after local declaration with attribute, but got %s intead",
839+
return reportStatError(lexer.current().location, {}, {}, "Expected 'function' after local declaration with attribute, but got %s instead",
839840
lexer.current().toString().c_str());
840841
}
841842

@@ -909,8 +910,16 @@ AstStat* Parser::parseTypeAlias(const Location& start, bool exported)
909910

910911
AstDeclaredClassProp Parser::parseDeclaredClassMethod()
911912
{
913+
Location start;
914+
915+
if (FFlag::LuauDeclarationExtraPropData)
916+
start = lexer.current().location;
917+
912918
nextLexeme();
913-
Location start = lexer.current().location;
919+
920+
if (!FFlag::LuauDeclarationExtraPropData)
921+
start = lexer.current().location;
922+
914923
Name fnName = parseName("function name");
915924

916925
// TODO: generic method declarations CLI-39909
@@ -935,15 +944,15 @@ AstDeclaredClassProp Parser::parseDeclaredClassMethod()
935944
expectMatchAndConsume(')', matchParen);
936945

937946
AstTypeList retTypes = parseOptionalReturnType().value_or(AstTypeList{copy<AstType*>(nullptr, 0), nullptr});
938-
Location end = lexer.current().location;
947+
Location end = FFlag::LuauDeclarationExtraPropData ? lexer.previousLocation() : lexer.current().location;
939948

940949
TempVector<AstType*> vars(scratchType);
941950
TempVector<std::optional<AstArgumentName>> varNames(scratchOptArgName);
942951

943952
if (args.size() == 0 || args[0].name.name != "self" || args[0].annotation != nullptr)
944953
{
945-
return AstDeclaredClassProp{
946-
fnName.name, reportTypeError(Location(start, end), {}, "'self' must be present as the unannotated first parameter"), true};
954+
return AstDeclaredClassProp{fnName.name, FFlag::LuauDeclarationExtraPropData ? fnName.location : Location{},
955+
reportTypeError(Location(start, end), {}, "'self' must be present as the unannotated first parameter"), true};
947956
}
948957

949958
// Skip the first index.
@@ -963,15 +972,16 @@ AstDeclaredClassProp Parser::parseDeclaredClassMethod()
963972
AstType* fnType = allocator.alloc<AstTypeFunction>(
964973
Location(start, end), generics, genericPacks, AstTypeList{copy(vars), varargAnnotation}, copy(varNames), retTypes);
965974

966-
return AstDeclaredClassProp{fnName.name, fnType, true};
975+
return AstDeclaredClassProp{fnName.name, FFlag::LuauDeclarationExtraPropData ? fnName.location : Location{}, fnType, true,
976+
FFlag::LuauDeclarationExtraPropData ? Location(start, end) : Location{}};
967977
}
968978

969979
AstStat* Parser::parseDeclaration(const Location& start, const AstArray<AstAttr*>& attributes)
970980
{
971981
// `declare` token is already parsed at this point
972982

973983
if (FFlag::LuauAttributeSyntax && (attributes.size != 0) && (lexer.current().type != Lexeme::ReservedFunction))
974-
return reportStatError(lexer.current().location, {}, {}, "Expected a function type declaration after attribute, but got %s intead",
984+
return reportStatError(lexer.current().location, {}, {}, "Expected a function type declaration after attribute, but got %s instead",
975985
lexer.current().toString().c_str());
976986

977987
if (lexer.current().type == Lexeme::ReservedFunction)
@@ -1014,8 +1024,12 @@ AstStat* Parser::parseDeclaration(const Location& start, const AstArray<AstAttr*
10141024
if (vararg && !varargAnnotation)
10151025
return reportStatError(Location(start, end), {}, {}, "All declaration parameters must be annotated");
10161026

1017-
return allocator.alloc<AstStatDeclareFunction>(Location(start, end), attributes, globalName.name, generics, genericPacks,
1018-
AstTypeList{copy(vars), varargAnnotation}, copy(varNames), retTypes);
1027+
if (FFlag::LuauDeclarationExtraPropData)
1028+
return allocator.alloc<AstStatDeclareFunction>(Location(start, end), attributes, globalName.name, globalName.location, generics,
1029+
genericPacks, AstTypeList{copy(vars), varargAnnotation}, copy(varNames), vararg, varargLocation, retTypes);
1030+
else
1031+
return allocator.alloc<AstStatDeclareFunction>(Location(start, end), attributes, globalName.name, Location{}, generics, genericPacks,
1032+
AstTypeList{copy(vars), varargAnnotation}, copy(varNames), false, Location{}, retTypes);
10191033
}
10201034
else if (AstName(lexer.current().name) == "class")
10211035
{
@@ -1045,19 +1059,42 @@ AstStat* Parser::parseDeclaration(const Location& start, const AstArray<AstAttr*
10451059
const Lexeme begin = lexer.current();
10461060
nextLexeme(); // [
10471061

1048-
std::optional<AstArray<char>> chars = parseCharArray();
1062+
if (FFlag::LuauDeclarationExtraPropData)
1063+
{
1064+
const Location nameBegin = lexer.current().location;
1065+
std::optional<AstArray<char>> chars = parseCharArray();
10491066

1050-
expectMatchAndConsume(']', begin);
1051-
expectAndConsume(':', "property type annotation");
1052-
AstType* type = parseType();
1067+
const Location nameEnd = lexer.previousLocation();
10531068

1054-
// since AstName contains a char*, it can't contain null
1055-
bool containsNull = chars && (strnlen(chars->data, chars->size) < chars->size);
1069+
expectMatchAndConsume(']', begin);
1070+
expectAndConsume(':', "property type annotation");
1071+
AstType* type = parseType();
10561072

1057-
if (chars && !containsNull)
1058-
props.push_back(AstDeclaredClassProp{AstName(chars->data), type, false});
1073+
// since AstName contains a char*, it can't contain null
1074+
bool containsNull = chars && (strnlen(chars->data, chars->size) < chars->size);
1075+
1076+
if (chars && !containsNull)
1077+
props.push_back(AstDeclaredClassProp{
1078+
AstName(chars->data), Location(nameBegin, nameEnd), type, false, Location(begin.location, lexer.previousLocation())});
1079+
else
1080+
report(begin.location, "String literal contains malformed escape sequence or \\0");
1081+
}
10591082
else
1060-
report(begin.location, "String literal contains malformed escape sequence or \\0");
1083+
{
1084+
std::optional<AstArray<char>> chars = parseCharArray();
1085+
1086+
expectMatchAndConsume(']', begin);
1087+
expectAndConsume(':', "property type annotation");
1088+
AstType* type = parseType();
1089+
1090+
// since AstName contains a char*, it can't contain null
1091+
bool containsNull = chars && (strnlen(chars->data, chars->size) < chars->size);
1092+
1093+
if (chars && !containsNull)
1094+
props.push_back(AstDeclaredClassProp{AstName(chars->data), Location{}, type, false});
1095+
else
1096+
report(begin.location, "String literal contains malformed escape sequence or \\0");
1097+
}
10611098
}
10621099
else if (lexer.current().type == '[')
10631100
{
@@ -1075,12 +1112,21 @@ AstStat* Parser::parseDeclaration(const Location& start, const AstArray<AstAttr*
10751112
indexer = parseTableIndexer(AstTableAccess::ReadWrite, std::nullopt);
10761113
}
10771114
}
1115+
else if (FFlag::LuauDeclarationExtraPropData)
1116+
{
1117+
Location propStart = lexer.current().location;
1118+
Name propName = parseName("property name");
1119+
expectAndConsume(':', "property type annotation");
1120+
AstType* propType = parseType();
1121+
props.push_back(
1122+
AstDeclaredClassProp{propName.name, propName.location, propType, false, Location(propStart, lexer.previousLocation())});
1123+
}
10781124
else
10791125
{
10801126
Name propName = parseName("property name");
10811127
expectAndConsume(':', "property type annotation");
10821128
AstType* propType = parseType();
1083-
props.push_back(AstDeclaredClassProp{propName.name, propType, false});
1129+
props.push_back(AstDeclaredClassProp{propName.name, Location{}, propType, false});
10841130
}
10851131
}
10861132

@@ -1094,7 +1140,8 @@ AstStat* Parser::parseDeclaration(const Location& start, const AstArray<AstAttr*
10941140
expectAndConsume(':', "global variable declaration");
10951141

10961142
AstType* type = parseType(/* in declaration context */ true);
1097-
return allocator.alloc<AstStatDeclareGlobal>(Location(start, type->location), globalName->name, type);
1143+
return allocator.alloc<AstStatDeclareGlobal>(
1144+
Location(start, type->location), globalName->name, FFlag::LuauDeclarationExtraPropData ? globalName->location : Location{}, type);
10981145
}
10991146
else
11001147
{
@@ -2391,7 +2438,7 @@ AstExpr* Parser::parseSimpleExpr()
23912438
if (lexer.current().type != Lexeme::ReservedFunction)
23922439
{
23932440
return reportExprError(
2394-
start, {}, "Expected 'function' declaration after attribute, but got %s intead", lexer.current().toString().c_str());
2441+
start, {}, "Expected 'function' declaration after attribute, but got %s instead", lexer.current().toString().c_str());
23952442
}
23962443
}
23972444

luau/Ast/src/TimeTrace.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ void flushEvents(GlobalContext& context, uint32_t threadId, const std::vector<Ev
250250

251251
ThreadContext& getThreadContext()
252252
{
253+
// Check custom provider that which might implement a custom TLS
254+
if (auto provider = threadContextProvider())
255+
return provider();
256+
253257
thread_local ThreadContext context;
254258
return context;
255259
}

luau/CodeGen/include/Luau/IrData.h

+11-7
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ enum class IrCmd : uint8_t
179179
// A: double
180180
ABS_NUM,
181181

182+
// Get the sign of the argument (math.sign)
183+
// A: double
184+
SIGN_NUM,
185+
182186
// Add/Sub/Mul/Div/Idiv two vectors
183187
// A, B: TValue
184188
ADD_VEC,
@@ -326,22 +330,22 @@ enum class IrCmd : uint8_t
326330
// This is used to recover after calling a variadic function
327331
ADJUST_STACK_TO_TOP,
328332

329-
// Execute fastcall builtin function in-place
333+
// Execute fastcall builtin function with 1 argument in-place
334+
// This is used for a few builtins that can have more than 1 result and cannot be represented as a regular instruction
330335
// A: unsigned int (builtin id)
331336
// B: Rn (result start)
332-
// C: Rn (argument start)
333-
// D: Rn or Kn or undef (optional second argument)
334-
// E: int (argument count)
335-
// F: int (result count)
337+
// C: Rn (first argument)
338+
// D: int (result count)
336339
FASTCALL,
337340

338341
// Call the fastcall builtin function
339342
// A: unsigned int (builtin id)
340343
// B: Rn (result start)
341344
// C: Rn (argument start)
342345
// D: Rn or Kn or undef (optional second argument)
343-
// E: int (argument count or -1 to use all arguments up to stack top)
344-
// F: int (result count or -1 to preserve all results and adjust stack top)
346+
// E: Rn or Kn or undef (optional third argument)
347+
// F: int (argument count or -1 to use all arguments up to stack top)
348+
// G: int (result count or -1 to preserve all results and adjust stack top)
345349
INVOKE_FASTCALL,
346350

347351
// Check that fastcall builtin function invocation was successful (negative result count jumps to fallback)

luau/CodeGen/include/Luau/IrDump.h

-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ void toString(IrToStringContext& ctx, IrOp op);
3131

3232
void toString(std::string& result, IrConst constant);
3333

34-
const char* getBytecodeTypeName_DEPRECATED(uint8_t type);
3534
const char* getBytecodeTypeName(uint8_t type, const char* const* userdataTypes);
3635

37-
void toString_DEPRECATED(std::string& result, const BytecodeTypes& bcTypes);
3836
void toString(std::string& result, const BytecodeTypes& bcTypes, const char* const* userdataTypes);
3937

4038
void toStringDetailed(

0 commit comments

Comments
 (0)