Skip to content

Commit 3a03180

Browse files
committed
v0.10.3+luau640
1 parent b35fbac commit 3a03180

Some content is hidden

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

75 files changed

+1798
-884
lines changed

luau/Ast/include/Luau/Ast.h

+141-34
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,13 @@ class AstExprIndexName : public AstExpr
384384
LUAU_RTTI(AstExprIndexName)
385385

386386
AstExprIndexName(
387-
const Location& location, AstExpr* expr, const AstName& index, const Location& indexLocation, const Position& opPosition, char op);
387+
const Location& location,
388+
AstExpr* expr,
389+
const AstName& index,
390+
const Location& indexLocation,
391+
const Position& opPosition,
392+
char op
393+
);
388394

389395
void visit(AstVisitor* visitor) override;
390396

@@ -413,11 +419,22 @@ class AstExprFunction : public AstExpr
413419
public:
414420
LUAU_RTTI(AstExprFunction)
415421

416-
AstExprFunction(const Location& location, const AstArray<AstAttr*>& attributes, const AstArray<AstGenericType>& generics,
417-
const AstArray<AstGenericTypePack>& genericPacks, AstLocal* self, const AstArray<AstLocal*>& args, bool vararg,
418-
const Location& varargLocation, AstStatBlock* body, size_t functionDepth, const AstName& debugname,
419-
const std::optional<AstTypeList>& returnAnnotation = {}, AstTypePack* varargAnnotation = nullptr,
420-
const std::optional<Location>& argLocation = std::nullopt);
422+
AstExprFunction(
423+
const Location& location,
424+
const AstArray<AstAttr*>& attributes,
425+
const AstArray<AstGenericType>& generics,
426+
const AstArray<AstGenericTypePack>& genericPacks,
427+
AstLocal* self,
428+
const AstArray<AstLocal*>& args,
429+
bool vararg,
430+
const Location& varargLocation,
431+
AstStatBlock* body,
432+
size_t functionDepth,
433+
const AstName& debugname,
434+
const std::optional<AstTypeList>& returnAnnotation = {},
435+
AstTypePack* varargAnnotation = nullptr,
436+
const std::optional<Location>& argLocation = std::nullopt
437+
);
421438

422439
void visit(AstVisitor* visitor) override;
423440

@@ -603,8 +620,14 @@ class AstStatIf : public AstStat
603620
public:
604621
LUAU_RTTI(AstStatIf)
605622

606-
AstStatIf(const Location& location, AstExpr* condition, AstStatBlock* thenbody, AstStat* elsebody, const std::optional<Location>& thenLocation,
607-
const std::optional<Location>& elseLocation);
623+
AstStatIf(
624+
const Location& location,
625+
AstExpr* condition,
626+
AstStatBlock* thenbody,
627+
AstStat* elsebody,
628+
const std::optional<Location>& thenLocation,
629+
const std::optional<Location>& elseLocation
630+
);
608631

609632
void visit(AstVisitor* visitor) override;
610633

@@ -698,8 +721,12 @@ class AstStatLocal : public AstStat
698721
public:
699722
LUAU_RTTI(AstStatLocal)
700723

701-
AstStatLocal(const Location& location, const AstArray<AstLocal*>& vars, const AstArray<AstExpr*>& values,
702-
const std::optional<Location>& equalsSignLocation);
724+
AstStatLocal(
725+
const Location& location,
726+
const AstArray<AstLocal*>& vars,
727+
const AstArray<AstExpr*>& values,
728+
const std::optional<Location>& equalsSignLocation
729+
);
703730

704731
void visit(AstVisitor* visitor) override;
705732

@@ -714,8 +741,16 @@ class AstStatFor : public AstStat
714741
public:
715742
LUAU_RTTI(AstStatFor)
716743

717-
AstStatFor(const Location& location, AstLocal* var, AstExpr* from, AstExpr* to, AstExpr* step, AstStatBlock* body, bool hasDo,
718-
const Location& doLocation);
744+
AstStatFor(
745+
const Location& location,
746+
AstLocal* var,
747+
AstExpr* from,
748+
AstExpr* to,
749+
AstExpr* step,
750+
AstStatBlock* body,
751+
bool hasDo,
752+
const Location& doLocation
753+
);
719754

720755
void visit(AstVisitor* visitor) override;
721756

@@ -734,8 +769,16 @@ class AstStatForIn : public AstStat
734769
public:
735770
LUAU_RTTI(AstStatForIn)
736771

737-
AstStatForIn(const Location& location, const AstArray<AstLocal*>& vars, const AstArray<AstExpr*>& values, AstStatBlock* body, bool hasIn,
738-
const Location& inLocation, bool hasDo, const Location& doLocation);
772+
AstStatForIn(
773+
const Location& location,
774+
const AstArray<AstLocal*>& vars,
775+
const AstArray<AstExpr*>& values,
776+
AstStatBlock* body,
777+
bool hasIn,
778+
const Location& inLocation,
779+
bool hasDo,
780+
const Location& doLocation
781+
);
739782

740783
void visit(AstVisitor* visitor) override;
741784

@@ -808,8 +851,15 @@ class AstStatTypeAlias : public AstStat
808851
public:
809852
LUAU_RTTI(AstStatTypeAlias)
810853

811-
AstStatTypeAlias(const Location& location, const AstName& name, const Location& nameLocation, const AstArray<AstGenericType>& generics,
812-
const AstArray<AstGenericTypePack>& genericPacks, AstType* type, bool exported);
854+
AstStatTypeAlias(
855+
const Location& location,
856+
const AstName& name,
857+
const Location& nameLocation,
858+
const AstArray<AstGenericType>& generics,
859+
const AstArray<AstGenericTypePack>& genericPacks,
860+
AstType* type,
861+
bool exported
862+
);
813863

814864
void visit(AstVisitor* visitor) override;
815865

@@ -821,6 +871,20 @@ class AstStatTypeAlias : public AstStat
821871
bool exported;
822872
};
823873

874+
class AstStatTypeFunction : public AstStat
875+
{
876+
public:
877+
LUAU_RTTI(AstStatTypeFunction);
878+
879+
AstStatTypeFunction(const Location& location, const AstName& name, const Location& nameLocation, AstExprFunction* body);
880+
881+
void visit(AstVisitor* visitor) override;
882+
883+
AstName name;
884+
Location nameLocation;
885+
AstExprFunction* body;
886+
};
887+
824888
class AstStatDeclareGlobal : public AstStat
825889
{
826890
public:
@@ -840,13 +904,32 @@ class AstStatDeclareFunction : public AstStat
840904
public:
841905
LUAU_RTTI(AstStatDeclareFunction)
842906

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);
846-
847-
AstStatDeclareFunction(const Location& location, const AstArray<AstAttr*>& attributes, const AstName& name, const Location& nameLocation,
848-
const AstArray<AstGenericType>& generics, const AstArray<AstGenericTypePack>& genericPacks, const AstTypeList& params,
849-
const AstArray<AstArgumentName>& paramNames, bool vararg, const Location& varargLocation, const AstTypeList& retTypes);
907+
AstStatDeclareFunction(
908+
const Location& location,
909+
const AstName& name,
910+
const Location& nameLocation,
911+
const AstArray<AstGenericType>& generics,
912+
const AstArray<AstGenericTypePack>& genericPacks,
913+
const AstTypeList& params,
914+
const AstArray<AstArgumentName>& paramNames,
915+
bool vararg,
916+
const Location& varargLocation,
917+
const AstTypeList& retTypes
918+
);
919+
920+
AstStatDeclareFunction(
921+
const Location& location,
922+
const AstArray<AstAttr*>& attributes,
923+
const AstName& name,
924+
const Location& nameLocation,
925+
const AstArray<AstGenericType>& generics,
926+
const AstArray<AstGenericTypePack>& genericPacks,
927+
const AstTypeList& params,
928+
const AstArray<AstArgumentName>& paramNames,
929+
bool vararg,
930+
const Location& varargLocation,
931+
const AstTypeList& retTypes
932+
);
850933

851934

852935
void visit(AstVisitor* visitor) override;
@@ -896,8 +979,13 @@ class AstStatDeclareClass : public AstStat
896979
public:
897980
LUAU_RTTI(AstStatDeclareClass)
898981

899-
AstStatDeclareClass(const Location& location, const AstName& name, std::optional<AstName> superName, const AstArray<AstDeclaredClassProp>& props,
900-
AstTableIndexer* indexer = nullptr);
982+
AstStatDeclareClass(
983+
const Location& location,
984+
const AstName& name,
985+
std::optional<AstName> superName,
986+
const AstArray<AstDeclaredClassProp>& props,
987+
AstTableIndexer* indexer = nullptr
988+
);
901989

902990
void visit(AstVisitor* visitor) override;
903991

@@ -934,8 +1022,15 @@ class AstTypeReference : public AstType
9341022
public:
9351023
LUAU_RTTI(AstTypeReference)
9361024

937-
AstTypeReference(const Location& location, std::optional<AstName> prefix, AstName name, std::optional<Location> prefixLocation,
938-
const Location& nameLocation, bool hasParameterList = false, const AstArray<AstTypeOrPack>& parameters = {});
1025+
AstTypeReference(
1026+
const Location& location,
1027+
std::optional<AstName> prefix,
1028+
AstName name,
1029+
std::optional<Location> prefixLocation,
1030+
const Location& nameLocation,
1031+
bool hasParameterList = false,
1032+
const AstArray<AstTypeOrPack>& parameters = {}
1033+
);
9391034

9401035
void visit(AstVisitor* visitor) override;
9411036

@@ -974,12 +1069,24 @@ class AstTypeFunction : public AstType
9741069
public:
9751070
LUAU_RTTI(AstTypeFunction)
9761071

977-
AstTypeFunction(const Location& location, const AstArray<AstGenericType>& generics, const AstArray<AstGenericTypePack>& genericPacks,
978-
const AstTypeList& argTypes, const AstArray<std::optional<AstArgumentName>>& argNames, const AstTypeList& returnTypes);
979-
980-
AstTypeFunction(const Location& location, const AstArray<AstAttr*>& attributes, const AstArray<AstGenericType>& generics,
981-
const AstArray<AstGenericTypePack>& genericPacks, const AstTypeList& argTypes, const AstArray<std::optional<AstArgumentName>>& argNames,
982-
const AstTypeList& returnTypes);
1072+
AstTypeFunction(
1073+
const Location& location,
1074+
const AstArray<AstGenericType>& generics,
1075+
const AstArray<AstGenericTypePack>& genericPacks,
1076+
const AstTypeList& argTypes,
1077+
const AstArray<std::optional<AstArgumentName>>& argNames,
1078+
const AstTypeList& returnTypes
1079+
);
1080+
1081+
AstTypeFunction(
1082+
const Location& location,
1083+
const AstArray<AstAttr*>& attributes,
1084+
const AstArray<AstGenericType>& generics,
1085+
const AstArray<AstGenericTypePack>& genericPacks,
1086+
const AstTypeList& argTypes,
1087+
const AstArray<std::optional<AstArgumentName>>& argNames,
1088+
const AstTypeList& returnTypes
1089+
);
9831090

9841091
void visit(AstVisitor* visitor) override;
9851092

@@ -1413,4 +1520,4 @@ struct hash<Luau::AstName>
14131520
}
14141521
};
14151522

1416-
} // namespace std
1523+
} // namespace std

luau/Ast/include/Luau/Parser.h

+32-8
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ class Parser
5555
{
5656
public:
5757
static ParseResult parse(
58-
const char* buffer, std::size_t bufferSize, AstNameTable& names, Allocator& allocator, ParseOptions options = ParseOptions());
58+
const char* buffer,
59+
std::size_t bufferSize,
60+
AstNameTable& names,
61+
Allocator& allocator,
62+
ParseOptions options = ParseOptions()
63+
);
5964

6065
private:
6166
struct Name;
@@ -140,6 +145,9 @@ class Parser
140145
// type Name `=' Type
141146
AstStat* parseTypeAlias(const Location& start, bool exported);
142147

148+
// type function Name ... end
149+
AstStat* parseTypeFunction(const Location& start);
150+
143151
AstDeclaredClassProp parseDeclaredClassMethod();
144152

145153
// `declare global' Name: Type |
@@ -157,7 +165,12 @@ class Parser
157165
// funcbodyhead ::= `(' [namelist [`,' `...'] | `...'] `)' [`:` Type]
158166
// funcbody ::= funcbodyhead block end
159167
std::pair<AstExprFunction*, AstLocal*> parseFunctionBody(
160-
bool hasself, const Lexeme& matchFunction, const AstName& debugname, const Name* localName, const AstArray<AstAttr*>& attributes);
168+
bool hasself,
169+
const Lexeme& matchFunction,
170+
const AstName& debugname,
171+
const Name* localName,
172+
const AstArray<AstAttr*>& attributes
173+
);
161174

162175
// explist ::= {exp `,'} exp
163176
void parseExprList(TempVector<AstExpr*>& result);
@@ -191,9 +204,15 @@ class Parser
191204
AstTableIndexer* parseTableIndexer(AstTableAccess access, std::optional<Location> accessLocation);
192205

193206
AstTypeOrPack parseFunctionType(bool allowPack, const AstArray<AstAttr*>& attributes);
194-
AstType* parseFunctionTypeTail(const Lexeme& begin, const AstArray<AstAttr*>& attributes, AstArray<AstGenericType> generics,
195-
AstArray<AstGenericTypePack> genericPacks, AstArray<AstType*> params, AstArray<std::optional<AstArgumentName>> paramNames,
196-
AstTypePack* varargAnnotation);
207+
AstType* parseFunctionTypeTail(
208+
const Lexeme& begin,
209+
const AstArray<AstAttr*>& attributes,
210+
AstArray<AstGenericType> generics,
211+
AstArray<AstGenericTypePack> genericPacks,
212+
AstArray<AstType*> params,
213+
AstArray<std::optional<AstArgumentName>> paramNames,
214+
AstTypePack* varargAnnotation
215+
);
197216

198217
AstType* parseTableType(bool inDeclarationContext = false);
199218
AstTypeOrPack parseSimpleType(bool allowPack, bool inDeclarationContext = false);
@@ -315,8 +334,13 @@ class Parser
315334

316335
void reportNameError(const char* context);
317336

318-
AstStatError* reportStatError(const Location& location, const AstArray<AstExpr*>& expressions, const AstArray<AstStat*>& statements,
319-
const char* format, ...) LUAU_PRINTF_ATTR(5, 6);
337+
AstStatError* reportStatError(
338+
const Location& location,
339+
const AstArray<AstExpr*>& expressions,
340+
const AstArray<AstStat*>& statements,
341+
const char* format,
342+
...
343+
) LUAU_PRINTF_ATTR(5, 6);
320344
AstExprError* reportExprError(const Location& location, const AstArray<AstExpr*>& expressions, const char* format, ...) LUAU_PRINTF_ATTR(4, 5);
321345
AstTypeError* reportTypeError(const Location& location, const AstArray<AstType*>& types, const char* format, ...) LUAU_PRINTF_ATTR(4, 5);
322346
// `parseErrorLocation` is associated with the parser error
@@ -428,4 +452,4 @@ class Parser
428452
std::string scratchData;
429453
};
430454

431-
} // namespace Luau
455+
} // namespace Luau

0 commit comments

Comments
 (0)