@@ -60,6 +60,8 @@ class AstStat;
60
60
class AstStatBlock ;
61
61
class AstExpr ;
62
62
class AstTypePack ;
63
+ class AstAttr ;
64
+ class AstExprTable ;
63
65
64
66
struct AstLocal
65
67
{
@@ -172,6 +174,10 @@ class AstNode
172
174
{
173
175
return nullptr ;
174
176
}
177
+ virtual AstAttr* asAttr ()
178
+ {
179
+ return nullptr ;
180
+ }
175
181
176
182
template <typename T>
177
183
bool is () const
@@ -193,6 +199,28 @@ class AstNode
193
199
Location location;
194
200
};
195
201
202
+ class AstAttr : public AstNode
203
+ {
204
+ public:
205
+ LUAU_RTTI (AstAttr)
206
+
207
+ enum Type
208
+ {
209
+ Checked,
210
+ };
211
+
212
+ AstAttr (const Location& location, Type type);
213
+
214
+ AstAttr* asAttr () override
215
+ {
216
+ return this ;
217
+ }
218
+
219
+ void visit (AstVisitor* visitor) override ;
220
+
221
+ Type type;
222
+ };
223
+
196
224
class AstExpr : public AstNode
197
225
{
198
226
public:
@@ -384,13 +412,15 @@ class AstExprFunction : public AstExpr
384
412
public:
385
413
LUAU_RTTI (AstExprFunction)
386
414
387
- AstExprFunction (const Location& location, const AstArray<AstGenericType>& generics, const AstArray<AstGenericTypePack>& genericPacks,
388
- AstLocal* self, const AstArray<AstLocal*>& args, bool vararg, const Location& varargLocation, AstStatBlock* body, size_t functionDepth,
389
- const AstName& debugname, const std::optional<AstTypeList>& returnAnnotation = {}, AstTypePack* varargAnnotation = nullptr ,
415
+ AstExprFunction (const Location& location, const AstArray<AstAttr*>& attributes, const AstArray<AstGenericType>& generics,
416
+ const AstArray<AstGenericTypePack>& genericPacks, AstLocal* self, const AstArray<AstLocal*>& args, bool vararg,
417
+ const Location& varargLocation, AstStatBlock* body, size_t functionDepth, const AstName& debugname,
418
+ const std::optional<AstTypeList>& returnAnnotation = {}, AstTypePack* varargAnnotation = nullptr ,
390
419
const std::optional<Location>& argLocation = std::nullopt);
391
420
392
421
void visit (AstVisitor* visitor) override ;
393
422
423
+ AstArray<AstAttr*> attributes;
394
424
AstArray<AstGenericType> generics;
395
425
AstArray<AstGenericTypePack> genericPacks;
396
426
AstLocal* self;
@@ -810,20 +840,22 @@ class AstStatDeclareFunction : public AstStat
810
840
const AstArray<AstGenericTypePack>& genericPacks, const AstTypeList& params, const AstArray<AstArgumentName>& paramNames,
811
841
const AstTypeList& retTypes);
812
842
813
- AstStatDeclareFunction (const Location& location, const AstName& name , const AstArray<AstGenericType>& generics ,
814
- const AstArray<AstGenericTypePack >& genericPacks , const AstTypeList& params , const AstArray<AstArgumentName>& paramNames ,
815
- const AstTypeList& retTypes, bool checkedFunction );
843
+ AstStatDeclareFunction (const Location& location, const AstArray<AstAttr*>& attributes , const AstName& name ,
844
+ const AstArray<AstGenericType >& generics , const AstArray<AstGenericTypePack>& genericPacks , const AstTypeList& params ,
845
+ const AstArray<AstArgumentName>& paramNames, const AstTypeList& retTypes );
816
846
817
847
818
848
void visit (AstVisitor* visitor) override ;
819
849
850
+ bool isCheckedFunction () const ;
851
+
852
+ AstArray<AstAttr*> attributes;
820
853
AstName name;
821
854
AstArray<AstGenericType> generics;
822
855
AstArray<AstGenericTypePack> genericPacks;
823
856
AstTypeList params;
824
857
AstArray<AstArgumentName> paramNames;
825
858
AstTypeList retTypes;
826
- bool checkedFunction;
827
859
};
828
860
829
861
struct AstDeclaredClassProp
@@ -936,17 +968,20 @@ class AstTypeFunction : public AstType
936
968
AstTypeFunction (const Location& location, const AstArray<AstGenericType>& generics, const AstArray<AstGenericTypePack>& genericPacks,
937
969
const AstTypeList& argTypes, const AstArray<std::optional<AstArgumentName>>& argNames, const AstTypeList& returnTypes);
938
970
939
- AstTypeFunction (const Location& location, const AstArray<AstGenericType>& generics, const AstArray<AstGenericTypePack>& genericPacks,
940
- const AstTypeList& argTypes, const AstArray<std::optional<AstArgumentName>>& argNames, const AstTypeList& returnTypes, bool checkedFunction);
971
+ AstTypeFunction (const Location& location, const AstArray<AstAttr*>& attributes, const AstArray<AstGenericType>& generics,
972
+ const AstArray<AstGenericTypePack>& genericPacks, const AstTypeList& argTypes, const AstArray<std::optional<AstArgumentName>>& argNames,
973
+ const AstTypeList& returnTypes);
941
974
942
975
void visit (AstVisitor* visitor) override ;
943
976
977
+ bool isCheckedFunction () const ;
978
+
979
+ AstArray<AstAttr*> attributes;
944
980
AstArray<AstGenericType> generics;
945
981
AstArray<AstGenericTypePack> genericPacks;
946
982
AstTypeList argTypes;
947
983
AstArray<std::optional<AstArgumentName>> argNames;
948
984
AstTypeList returnTypes;
949
- bool checkedFunction;
950
985
};
951
986
952
987
class AstTypeTypeof : public AstType
@@ -1105,6 +1140,11 @@ class AstVisitor
1105
1140
return true ;
1106
1141
}
1107
1142
1143
+ virtual bool visit (class AstAttr * node)
1144
+ {
1145
+ return visit (static_cast <AstNode*>(node));
1146
+ }
1147
+
1108
1148
virtual bool visit (class AstExpr * node)
1109
1149
{
1110
1150
return visit (static_cast <AstNode*>(node));
0 commit comments