v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
ast.h
Go to the documentation of this file.
1// Copyright 2018 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_TORQUE_AST_H_
6#define V8_TORQUE_AST_H_
7
8#include <algorithm>
9#include <iostream>
10#include <map>
11#include <memory>
12#include <optional>
13#include <set>
14#include <string>
15#include <vector>
16
20#include "src/torque/utils.h"
21
23
24#define AST_EXPRESSION_NODE_KIND_LIST(V) \
25 V(CallExpression) \
26 V(CallMethodExpression) \
27 V(IntrinsicCallExpression) \
28 V(StructExpression) \
29 V(LogicalOrExpression) \
30 V(LogicalAndExpression) \
31 V(SpreadExpression) \
32 V(ConditionalExpression) \
33 V(IdentifierExpression) \
34 V(StringLiteralExpression) \
35 V(IntegerLiteralExpression) \
36 V(FloatingPointLiteralExpression) \
37 V(FieldAccessExpression) \
38 V(ElementAccessExpression) \
39 V(DereferenceExpression) \
40 V(AssignmentExpression) \
41 V(IncrementDecrementExpression) \
42 V(NewExpression) \
43 V(AssumeTypeImpossibleExpression) \
44 V(StatementExpression) \
45 V(TryLabelExpression)
46
47#define AST_TYPE_EXPRESSION_NODE_KIND_LIST(V) \
48 V(BasicTypeExpression) \
49 V(FunctionTypeExpression) \
50 V(PrecomputedTypeExpression) \
51 V(UnionTypeExpression)
52
53#define AST_STATEMENT_NODE_KIND_LIST(V) \
54 V(BlockStatement) \
55 V(ExpressionStatement) \
56 V(IfStatement) \
57 V(WhileStatement) \
58 V(ForLoopStatement) \
59 V(BreakStatement) \
60 V(ContinueStatement) \
61 V(ReturnStatement) \
62 V(DebugStatement) \
63 V(AssertStatement) \
64 V(TailCallStatement) \
65 V(VarDeclarationStatement) \
66 V(GotoStatement)
67
68#define AST_TYPE_DECLARATION_NODE_KIND_LIST(V) \
69 V(AbstractTypeDeclaration) \
70 V(TypeAliasDeclaration) \
71 V(BitFieldStructDeclaration) \
72 V(ClassDeclaration) \
73 V(StructDeclaration)
74
75#define AST_DECLARATION_NODE_KIND_LIST(V) \
76 AST_TYPE_DECLARATION_NODE_KIND_LIST(V) \
77 V(GenericCallableDeclaration) \
78 V(GenericTypeDeclaration) \
79 V(SpecializationDeclaration) \
80 V(ExternConstDeclaration) \
81 V(NamespaceDeclaration) \
82 V(ConstDeclaration) \
83 V(CppIncludeDeclaration) \
84 V(TorqueMacroDeclaration) \
85 V(TorqueBuiltinDeclaration) \
86 V(ExternalMacroDeclaration) \
87 V(ExternalBuiltinDeclaration) \
88 V(ExternalRuntimeDeclaration) \
89 V(IntrinsicDeclaration)
90
91#define AST_NODE_KIND_LIST(V) \
92 AST_EXPRESSION_NODE_KIND_LIST(V) \
93 AST_TYPE_EXPRESSION_NODE_KIND_LIST(V) \
94 AST_STATEMENT_NODE_KIND_LIST(V) \
95 AST_DECLARATION_NODE_KIND_LIST(V) \
96 V(Identifier) \
97 V(TryHandler) \
98 V(ClassBody)
99
100struct AstNode {
101 public:
102 enum class Kind {
103#define ENUM_ITEM(name) k##name,
105#undef ENUM_ITEM
106 };
107
109 virtual ~AstNode() = default;
110
111 const Kind kind;
113};
114
116 template <class T>
117 static bool IsInstanceOf(AstNode* node);
118};
119
120// Boilerplate for most derived classes.
121#define DEFINE_AST_NODE_LEAF_BOILERPLATE(T) \
122 static const Kind kKind = Kind::k##T; \
123 static T* cast(AstNode* node) { \
124 DCHECK_EQ(node->kind, kKind); \
125 return static_cast<T*>(node); \
126 } \
127 static T* DynamicCast(AstNode* node) { \
128 if (!node) return nullptr; \
129 if (node->kind != kKind) return nullptr; \
130 return static_cast<T*>(node); \
131 }
132
133// Boilerplate for classes with subclasses.
134#define DEFINE_AST_NODE_INNER_BOILERPLATE(T) \
135 static T* cast(AstNode* node) { \
136 DCHECK(AstNodeClassCheck::IsInstanceOf<T>(node)); \
137 return static_cast<T*>(node); \
138 } \
139 static T* DynamicCast(AstNode* node) { \
140 if (!node) return nullptr; \
141 if (!AstNodeClassCheck::IsInstanceOf<T>(node)) return nullptr; \
142 return static_cast<T*>(node); \
143 }
144
148
149 using VisitCallback = std::function<void(Expression*)>;
151 // TODO(szuend): Hoist this up to AstNode and make it a
152 // general Ast visitor.
153 }
154};
155
160
165
170
175
176class Namespace;
177
181 std::vector<Declaration*> declarations)
182 : Declaration(kKind, pos),
184 name(name) {}
185 std::vector<Declaration*> declarations;
186 std::string name;
187};
188
190 struct Entry {
191 std::string name;
192 std::string alias_entry;
193 Entry(std::string name, std::string alias_entry)
194 : name(std::move(name)), alias_entry(std::move(alias_entry)) {}
195 };
197 std::string name;
200 std::vector<Entry> entries;
201
203 std::string constexpr_generates, bool is_open,
204 std::vector<Entry> entries = {})
205 : pos(std::move(pos)),
206 name(std::move(name)),
209 entries(std::move(entries)) {}
210};
211
212class Ast {
213 public:
214 Ast() = default;
215
216 std::vector<Declaration*>& declarations() { return declarations_; }
217 const std::vector<Declaration*>& declarations() const {
218 return declarations_;
219 }
220 template <class T>
221 T* AddNode(std::unique_ptr<T> node) {
222 T* result = node.get();
223 nodes_.push_back(std::move(node));
224 return result;
225 }
226
228 declared_imports_[CurrentSourcePosition::Get().source].insert(import_id);
229 }
230
232 std::string name = description.name;
233 DCHECK(!name.empty());
234 auto f = [&](const auto& d) { return d.name == name; };
235 USE(f); // Suppress unused in release.
236 DCHECK_EQ(
237 std::find_if(enum_descriptions_.begin(), enum_descriptions_.end(), f),
238 enum_descriptions_.end());
239 enum_descriptions_.push_back(std::move(description));
240 }
241
242 std::vector<EnumDescription>& EnumDescriptions() {
243 return enum_descriptions_;
244 }
245
246 private:
247 std::vector<Declaration*> declarations_;
248 std::vector<std::unique_ptr<AstNode>> nodes_;
249 std::map<SourceId, std::set<SourceId>> declared_imports_;
250 std::vector<EnumDescription> enum_descriptions_;
251};
252
253static const char* const kThisParameterName = "this";
254
255// A Identifier is a string with a SourcePosition attached.
262
263inline std::ostream& operator<<(std::ostream& os, Identifier* id) {
264 return os << id->value;
265}
266
268 bool operator()(const Identifier* a, const Identifier* b) {
269 return a->value < b->value;
270 }
271};
272
283 std::vector<TypeExpression*> args = {})
284 : IdentifierExpression(pos, {}, name, std::move(args)) {}
285 bool IsThis() const { return name->value == kThisParameterName; }
286
288 callback(this);
289 }
290
291 std::vector<std::string> namespace_qualification;
293 std::vector<TypeExpression*> generic_arguments;
294};
295
300 std::vector<Expression*> arguments)
301 : Expression(kKind, pos),
302 name(name),
304 arguments(std::move(arguments)) {}
305
307 for (auto argument : arguments) {
308 argument->VisitAllSubExpressions(callback);
309 }
310 callback(this);
311 }
312
314 std::vector<TypeExpression*> generic_arguments;
315 std::vector<Expression*> arguments;
316};
317
322 std::vector<Expression*> arguments,
323 std::vector<Identifier*> labels)
324 : Expression(kKind, pos),
325 target(target),
326 method(method),
327 arguments(std::move(arguments)),
328 labels(std::move(labels)) {}
329
331 target->VisitAllSubExpressions(callback);
333 for (auto argument : arguments) {
334 argument->VisitAllSubExpressions(callback);
335 }
336 callback(this);
337 }
338
341 std::vector<Expression*> arguments;
342 std::vector<Identifier*> labels;
343};
344
348 std::vector<Expression*> arguments,
349 std::vector<Identifier*> labels)
350 : Expression(kKind, pos),
351 callee(callee),
352 arguments(std::move(arguments)),
353 labels(std::move(labels)) {}
354
357 for (auto argument : arguments) {
358 argument->VisitAllSubExpressions(callback);
359 }
360 callback(this);
361 }
362
364 std::vector<Expression*> arguments;
365 std::vector<Identifier*> labels;
366};
367
372
380
382 for (auto& initializer : initializers) {
383 initializer.expression->VisitAllSubExpressions(callback);
384 }
385 callback(this);
386 }
387
389 std::vector<NameAndExpression> initializers;
390};
391
406
421
434
455
467
479
491
495 Expression* index)
496 : LocationExpression(kKind, pos), array(array), index(index) {}
497
499 array->VisitAllSubExpressions(callback);
500 index->VisitAllSubExpressions(callback);
501 callback(this);
502 }
503
506};
507
522
535
542 std::optional<std::string> op, Expression* value)
543 : Expression(kKind, pos),
545 op(std::move(op)),
546 value(value) {}
547
550 value->VisitAllSubExpressions(callback);
551 callback(this);
552 }
553
555 std::optional<std::string> op;
557};
558
560
576
577// This expression is only used in the desugaring of typeswitch, and it allows
578// to bake in the static information that certain types are impossible at a
579// certain position in the control flow.
580// The result type is the type of {expression} minus the provided type.
598
609
611 for (auto& initializer : initializers) {
612 initializer.expression->VisitAllSubExpressions(callback);
613 }
614 callback(this);
615 }
616
618 std::vector<NameAndExpression> initializers;
621};
622
624
626 std::vector<Identifier*> names;
627 std::vector<TypeExpression*> types;
630 size_t implicit_count = 0;
631 bool has_varargs = false;
632 std::string arguments_variable = "";
633
634 static ParameterList Empty() { return {}; }
635 std::vector<TypeExpression*> GetImplicitTypes() {
636 return std::vector<TypeExpression*>(types.begin(),
637 types.begin() + implicit_count);
638 }
639 std::vector<TypeExpression*> GetExplicitTypes() {
640 return std::vector<TypeExpression*>(types.begin() + implicit_count,
641 types.end());
642 }
643};
644
663
675
676// A PrecomputedTypeExpression is never created directly by the parser. Later
677// stages can use this to insert AST snippets where the type has already been
678// resolved.
679class Type;
686
694
701
716
724
728 : Statement(kKind, pos), value(value) {}
729 std::optional<Expression*> value;
730};
731
739
744 std::string source)
745 : Statement(kKind, pos),
746 kind(kind),
747 expression(expression),
748 source(std::move(source)) {}
751 std::string source;
752};
753
760
764 Identifier* name, std::optional<TypeExpression*> type,
765 std::optional<Expression*> initializer = std::nullopt)
766 : Statement(kKind, pos),
768 name(name),
769 type(type),
773 std::optional<TypeExpression*> type;
774 std::optional<Expression*> initializer;
775};
776
781
786
790 const std::vector<Expression*>& arguments)
791 : Statement(kKind, pos), label(label), arguments(std::move(arguments)) {}
793 std::vector<Expression*> arguments;
794};
795
799 std::optional<Expression*> test,
800 std::optional<Statement*> action, Statement* body)
801 : Statement(kKind, pos),
803 test(std::move(test)),
804 action(std::move(action)),
805 body(std::move(body)) {
806 if (declaration)
807 var_declaration = VarDeclarationStatement::cast(*declaration);
808 }
809 std::optional<VarDeclarationStatement*> var_declaration;
810 std::optional<Expression*> test;
811 std::optional<Statement*> action;
813};
814
830
837
848
852 std::vector<Statement*> statements = {})
853 : Statement(kKind, pos),
855 statements(std::move(statements)) {}
857 std::vector<Statement*> statements;
858};
859
866
872
876 AbstractTypeFlags flags,
877 std::optional<TypeExpression*> extends,
878 std::optional<std::string> generates)
879 : TypeDeclaration(kKind, pos, name),
880 flags(flags),
882 generates(std::move(generates)) {
883 CHECK_EQ(IsConstexprName(name->value),
884 !!(flags & AbstractTypeFlag::kConstexpr));
885 }
886
887 bool IsConstexpr() const { return flags & AbstractTypeFlag::kConstexpr; }
888 bool IsTransient() const { return flags & AbstractTypeFlag::kTransient; }
889
891 std::optional<TypeExpression*> extends;
892 std::optional<std::string> generates;
893};
894
902
907
910 std::vector<NameAndTypeExpression> parameters;
911};
912
917
922
924 kPositive,
925 kNegative,
926};
927
932
934 std::string string_value;
936 bool is_int;
937};
938
941 std::optional<AnnotationParameter> param;
942};
943
945 // The expression that can compute how many items are in the indexed field.
947
948 // Whether the field was declared as optional, meaning it can only hold zero
949 // or one values, and thus should not require an index expression to access.
951};
952
961
964 std::vector<TypeExpression*> types;
965};
966
967using LabelAndTypesVector = std::vector<LabelAndTypes>;
968
987
991 Identifier* name, std::optional<std::string> op,
994 : CallableDeclaration(kind, pos, transitioning, name,
995 std::move(parameters), return_type,
996 std::move(labels)),
997 op(std::move(op)) {
999 Error("Cannot use \"js-implicit\" with macros, use \"implicit\" instead.")
1000 .Position(parameters.implicit_kind_pos);
1001 }
1002 }
1003 std::optional<std::string> op;
1004};
1005
1009 std::string external_assembler_name,
1010 Identifier* name, std::optional<std::string> op,
1011 ParameterList parameters,
1012 TypeExpression* return_type,
1013 LabelAndTypesVector labels)
1014 : MacroDeclaration(kKind, pos, transitioning, name, std::move(op),
1015 std::move(parameters), return_type, std::move(labels)),
1016 external_assembler_name(std::move(external_assembler_name)) {}
1018};
1019
1023 ParameterList parameters, TypeExpression* return_type)
1024 : CallableDeclaration(kKind, pos, false, name, std::move(parameters),
1025 return_type, {}) {
1026 if (parameters.implicit_kind != ImplicitKind::kNoImplicit) {
1027 Error("Intinsics cannot have implicit parameters.");
1028 }
1029 }
1030};
1031
1035 Identifier* name, std::optional<std::string> op,
1036 ParameterList parameters, TypeExpression* return_type,
1037 LabelAndTypesVector labels, bool export_to_csa,
1038 std::optional<Statement*> body)
1039 : MacroDeclaration(kKind, pos, transitioning, name, std::move(op),
1040 std::move(parameters), return_type, std::move(labels)),
1041 export_to_csa(export_to_csa),
1042 body(body) {}
1044 std::optional<Statement*> body;
1045};
1046
1050 bool javascript_linkage, bool transitioning,
1051 Identifier* name, ParameterList parameters,
1052 TypeExpression* return_type)
1053 : CallableDeclaration(kind, pos, transitioning, name,
1054 std::move(parameters), return_type, {}),
1055 javascript_linkage(javascript_linkage) {
1056 if (parameters.implicit_kind == ImplicitKind::kJSImplicit &&
1057 !javascript_linkage) {
1058 Error(
1059 "\"js-implicit\" is for implicit parameters passed according to the "
1060 "JavaScript calling convention. Use \"implicit\" instead.");
1061 }
1062 if (parameters.implicit_kind == ImplicitKind::kImplicit &&
1063 javascript_linkage) {
1064 Error(
1065 "The JavaScript calling convention implicitly passes a fixed set of "
1066 "values. Use \"js-implicit\" to refer to those.")
1067 .Position(parameters.implicit_kind_pos);
1068 }
1069 }
1071};
1072
1076 bool javascript_linkage, Identifier* name,
1077 ParameterList parameters,
1078 TypeExpression* return_type)
1079 : BuiltinDeclaration(kKind, pos, javascript_linkage, transitioning, name,
1080 std::move(parameters), return_type) {}
1081};
1082
1086 bool javascript_linkage, Identifier* name,
1087 ParameterList parameters,
1088 TypeExpression* return_type,
1089 bool has_custom_interface_descriptor,
1090 std::optional<std::string> use_counter_name,
1091 std::optional<Statement*> body)
1092 : BuiltinDeclaration(kKind, pos, javascript_linkage, transitioning, name,
1093 std::move(parameters), return_type),
1094 has_custom_interface_descriptor(has_custom_interface_descriptor),
1095 use_counter_name(use_counter_name),
1096 body(body) {}
1098 std::optional<std::string> use_counter_name;
1099 std::optional<Statement*> body;
1100};
1101
1105 Identifier* name, ParameterList parameters,
1106 TypeExpression* return_type)
1107 : CallableDeclaration(kKind, pos, transitioning, name, parameters,
1108 return_type, {}) {}
1109};
1110
1114 Expression* expression)
1115 : Declaration(kKind, pos),
1116 name(name),
1117 type(type),
1118 expression(expression) {}
1122};
1123
1126 std::optional<TypeExpression*> constraint;
1127};
1128
1129using GenericParameters = std::vector<GenericParameter>;
1130
1131// The AST re-shuffles generics from the concrete syntax:
1132// Instead of the generic parameters being part of a normal declaration,
1133// a declaration with generic parameters gets wrapped in a generic declaration,
1134// which holds the generic parameters. This corresponds to how you write
1135// templates in C++, with the template parameters coming before the declaration.
1136
1149
1162
1166 Identifier* name,
1167 std::vector<TypeExpression*> generic_parameters,
1168 ParameterList parameters,
1169 TypeExpression* return_type,
1170 LabelAndTypesVector labels, Statement* body)
1171 : CallableDeclaration(kKind, pos, transitioning, name,
1172 std::move(parameters), return_type,
1173 std::move(labels)),
1174 generic_parameters(std::move(generic_parameters)),
1175 body(body) {}
1176 std::vector<TypeExpression*> generic_parameters;
1178};
1179
1192
1196 std::vector<Declaration*> methods,
1197 std::vector<StructFieldExpression> fields)
1198 : TypeDeclaration(kKind, pos, name),
1199 flags(flags),
1200 methods(std::move(methods)),
1201 fields(std::move(fields)) {}
1203 std::vector<Declaration*> methods;
1204 std::vector<StructFieldExpression> fields;
1205};
1206
1210 TypeExpression* parent,
1211 std::vector<BitFieldDeclaration> fields)
1212 : TypeDeclaration(kKind, pos, name),
1213 parent(parent),
1214 fields(std::move(fields)) {}
1216 std::vector<BitFieldDeclaration> fields;
1217};
1218
1222 std::vector<ClassFieldExpression> fields)
1223 : AstNode(kKind, pos),
1224 methods(std::move(methods)),
1225 fields(std::move(fields)) {}
1226 std::vector<Declaration*> methods;
1227 std::vector<ClassFieldExpression> fields;
1228};
1229
1233 TypeExpression* super, std::optional<std::string> generates,
1234 std::vector<Declaration*> methods,
1235 std::vector<ClassFieldExpression> fields,
1236 InstanceTypeConstraints instance_type_constraints)
1237 : TypeDeclaration(kKind, pos, name),
1238 flags(flags),
1239 super(super),
1240 generates(std::move(generates)),
1241 methods(std::move(methods)),
1242 fields(std::move(fields)),
1243 instance_type_constraints(std::move(instance_type_constraints)) {}
1246 std::optional<std::string> generates;
1247 std::vector<Declaration*> methods;
1248 std::vector<ClassFieldExpression> fields;
1250};
1251
1255 : Declaration(kKind, pos), include_path(std::move(include_path)) {}
1256 std::string include_path;
1257};
1258
1259#define ENUM_ITEM(name) \
1260 case AstNode::Kind::k##name: \
1261 return std::is_base_of<T, name>::value; \
1262 break;
1263
1264template <class T>
1266 switch (node->kind) {
1268 default:
1269 UNIMPLEMENTED();
1270 }
1271 return true;
1272}
1273
1274#undef ENUM_ITEM
1275
1276inline bool IsDeferred(Statement* stmt) {
1277 if (auto* block = BlockStatement::DynamicCast(stmt)) {
1278 return block->deferred;
1279 }
1280 return false;
1281}
1282
1284
1285template <class T, class... Args>
1286T* MakeNode(Args... args) {
1287 return CurrentAst::Get().AddNode(
1288 std::make_unique<T>(CurrentSourcePosition::Get(), std::move(args)...));
1289}
1290
1292 std::string field) {
1294 object, MakeNode<Identifier>(std::move(field)));
1295}
1296
1298 std::vector<std::string> namespace_qualification, std::string name,
1299 std::vector<TypeExpression*> args = {}) {
1300 return MakeNode<IdentifierExpression>(std::move(namespace_qualification),
1301 MakeNode<Identifier>(std::move(name)),
1302 std::move(args));
1303}
1304
1306 return MakeIdentifierExpression({}, std::move(name));
1307}
1308
1310 IdentifierExpression* callee, std::vector<Expression*> arguments,
1311 std::vector<Identifier*> labels = {}) {
1312 return MakeNode<CallExpression>(callee, std::move(arguments),
1313 std::move(labels));
1314}
1315
1317 std::string callee, std::vector<Expression*> arguments,
1318 std::vector<Identifier*> labels = {}) {
1319 return MakeCallExpression(MakeIdentifierExpression(std::move(callee)),
1320 std::move(arguments), std::move(labels));
1321}
1322
1324 std::string name, Expression* initializer) {
1326 /*const_qualified=*/true, MakeNode<Identifier>(std::move(name)),
1327 std::optional<TypeExpression*>{}, initializer);
1328}
1329
1331 std::vector<std::string> namespace_qualification, Identifier* name,
1332 std::vector<TypeExpression*> generic_arguments = {}) {
1333 return MakeNode<BasicTypeExpression>(std::move(namespace_qualification), name,
1334 std::move(generic_arguments));
1335}
1336
1338 TypeExpression* type, std::vector<NameAndExpression> initializers) {
1339 return MakeNode<StructExpression>(type, std::move(initializers));
1340}
1341
1342} // namespace v8::internal::torque
1343
1344#endif // V8_TORQUE_AST_H_
#define T
Builtins::Kind kind
Definition builtins.cc:40
SourcePosition pos
const std::vector< Declaration * > & declarations() const
Definition ast.h:217
T * AddNode(std::unique_ptr< T > node)
Definition ast.h:221
std::map< SourceId, std::set< SourceId > > declared_imports_
Definition ast.h:249
std::vector< EnumDescription > & EnumDescriptions()
Definition ast.h:242
void AddEnumDescription(EnumDescription description)
Definition ast.h:231
std::vector< Declaration * > declarations_
Definition ast.h:247
void DeclareImportForCurrentFile(SourceId import_id)
Definition ast.h:227
std::vector< EnumDescription > enum_descriptions_
Definition ast.h:250
std::vector< std::unique_ptr< AstNode > > nodes_
Definition ast.h:248
std::vector< Declaration * > & declarations()
Definition ast.h:216
#define DECLARE_CONTEXTUAL_VARIABLE(VarName,...)
Definition contextual.h:88
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
TNode< Object > callback
ZoneVector< RpoNumber > & result
FunctionLiteral * literal
Definition liveedit.cc:294
STL namespace.
VarDeclarationStatement * MakeConstDeclarationStatement(std::string name, Expression *initializer)
Definition ast.h:1323
static const char *const kThisParameterName
Definition ast.h:253
std::ostream & operator<<(std::ostream &os, Identifier *id)
Definition ast.h:263
BasicTypeExpression * MakeBasicTypeExpression(std::vector< std::string > namespace_qualification, Identifier *name, std::vector< TypeExpression * > generic_arguments={})
Definition ast.h:1330
StructExpression * MakeStructExpression(TypeExpression *type, std::vector< NameAndExpression > initializers)
Definition ast.h:1337
T * MakeNode(Args... args)
Definition ast.h:1286
std::vector< GenericParameter > GenericParameters
Definition ast.h:1129
FieldAccessExpression * MakeFieldAccessExpression(Expression *object, std::string field)
Definition ast.h:1291
bool IsDeferred(Statement *stmt)
Definition ast.h:1276
bool IsConstexprName(const std::string &name)
Definition constants.h:144
IdentifierExpression * MakeIdentifierExpression(std::vector< std::string > namespace_qualification, std::string name, std::vector< TypeExpression * > args={})
Definition ast.h:1297
std::vector< LabelAndTypes > LabelAndTypesVector
Definition ast.h:967
CallExpression * MakeCallExpression(IdentifierExpression *callee, std::vector< Expression * > arguments, std::vector< Identifier * > labels={})
Definition ast.h:1309
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in name
Definition flags.cc:2086
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_EQ(v1, v2)
Definition logging.h:485
#define USE(...)
Definition macros.h:293
std::optional< TypeExpression * > extends
Definition ast.h:891
std::optional< std::string > generates
Definition ast.h:892
std::optional< AnnotationParameter > param
Definition ast.h:941
AssertStatement(SourcePosition pos, AssertKind kind, Expression *expression, std::string source)
Definition ast.h:743
std::optional< std::string > op
Definition ast.h:555
AssignmentExpression(SourcePosition pos, Expression *location, std::optional< std::string > op, Expression *value)
Definition ast.h:541
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:548
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:590
static bool IsInstanceOf(AstNode *node)
Definition ast.h:1265
SourcePosition pos
Definition ast.h:112
AstNode(Kind kind, SourcePosition pos)
Definition ast.h:108
virtual ~AstNode()=default
std::vector< TypeExpression * > generic_arguments
Definition ast.h:661
std::vector< std::string > namespace_qualification
Definition ast.h:658
BasicTypeExpression(SourcePosition pos, Identifier *name)
Definition ast.h:656
NameAndTypeExpression name_and_type
Definition ast.h:919
std::vector< BitFieldDeclaration > fields
Definition ast.h:1216
std::vector< Statement * > statements
Definition ast.h:857
std::vector< Identifier * > labels
Definition ast.h:365
IdentifierExpression * callee
Definition ast.h:363
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:355
std::vector< Expression * > arguments
Definition ast.h:364
IdentifierExpression * method
Definition ast.h:340
std::vector< Identifier * > labels
Definition ast.h:342
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:330
std::vector< Expression * > arguments
Definition ast.h:341
CallableDeclaration(AstNode::Kind kind, SourcePosition pos, bool transitioning, Identifier *name, ParameterList parameters, TypeExpression *return_type, LabelAndTypesVector labels)
Definition ast.h:970
std::vector< ClassFieldExpression > fields
Definition ast.h:1227
std::vector< Declaration * > methods
Definition ast.h:1226
std::vector< ClassFieldExpression > fields
Definition ast.h:1248
InstanceTypeConstraints instance_type_constraints
Definition ast.h:1249
std::optional< std::string > generates
Definition ast.h:1246
std::vector< Declaration * > methods
Definition ast.h:1247
NameAndTypeExpression name_and_type
Definition ast.h:954
std::vector< ConditionalAnnotation > conditions
Definition ast.h:956
FieldSynchronization synchronization
Definition ast.h:959
std::optional< ClassFieldIndexInfo > index
Definition ast.h:955
ConditionalAnnotationType type
Definition ast.h:930
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:444
DebugStatement(SourcePosition pos, Kind kind)
Definition ast.h:735
Declaration(Kind kind, SourcePosition pos)
Definition ast.h:167
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:528
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:498
Entry(std::string name, std::string alias_entry)
Definition ast.h:193
std::vector< Entry > entries
Definition ast.h:200
EnumDescription(SourcePosition pos, std::string name, std::string constexpr_generates, bool is_open, std::vector< Entry > entries={})
Definition ast.h:202
Expression(Kind kind, SourcePosition pos)
Definition ast.h:146
std::function< void(Expression *)> VisitCallback
Definition ast.h:149
virtual void VisitAllSubExpressions(VisitCallback callback)
Definition ast.h:150
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:514
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:485
std::optional< Statement * > action
Definition ast.h:811
std::optional< Expression * > test
Definition ast.h:810
std::optional< VarDeclarationStatement * > var_declaration
Definition ast.h:809
std::vector< TypeExpression * > parameters
Definition ast.h:672
std::optional< TypeExpression * > constraint
Definition ast.h:1126
std::vector< Expression * > arguments
Definition ast.h:793
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:287
IdentifierExpression(SourcePosition pos, Identifier *name, std::vector< TypeExpression * > args={})
Definition ast.h:282
std::vector< TypeExpression * > generic_arguments
Definition ast.h:293
std::vector< std::string > namespace_qualification
Definition ast.h:291
bool operator()(const Identifier *a, const Identifier *b)
Definition ast.h:268
std::optional< Statement * > if_false
Definition ast.h:714
std::vector< NameAndTypeExpression > parameters
Definition ast.h:910
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:567
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:473
std::vector< TypeExpression * > generic_arguments
Definition ast.h:314
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:306
std::vector< Expression * > arguments
Definition ast.h:315
std::vector< TypeExpression * > types
Definition ast.h:964
LocationExpression(Kind kind, SourcePosition pos)
Definition ast.h:157
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:412
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:397
std::optional< std::string > op
Definition ast.h:1003
std::vector< Declaration * > declarations
Definition ast.h:185
std::vector< NameAndExpression > initializers
Definition ast.h:618
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:610
std::vector< TypeExpression * > GetExplicitTypes()
Definition ast.h:639
std::vector< TypeExpression * > types
Definition ast.h:627
SourcePosition implicit_kind_pos
Definition ast.h:629
static ParameterList Empty()
Definition ast.h:634
std::vector< Identifier * > names
Definition ast.h:626
std::vector< TypeExpression * > GetImplicitTypes()
Definition ast.h:635
std::optional< Expression * > value
Definition ast.h:729
std::vector< TypeExpression * > generic_parameters
Definition ast.h:1176
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:427
Statement(Kind kind, SourcePosition pos)
Definition ast.h:172
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:461
std::vector< StructFieldExpression > fields
Definition ast.h:1204
std::vector< Declaration * > methods
Definition ast.h:1203
void VisitAllSubExpressions(VisitCallback callback) override
Definition ast.h:381
std::vector< NameAndExpression > initializers
Definition ast.h:389
NameAndTypeExpression name_and_type
Definition ast.h:914
std::optional< std::string > use_counter_name
Definition ast.h:1098
std::optional< Statement * > body
Definition ast.h:1099
std::optional< Statement * > body
Definition ast.h:1044
TryHandler(SourcePosition pos, HandlerKind handler_kind, Identifier *label, const ParameterList &parameters, Statement *body)
Definition ast.h:818
TypeExpression(Kind kind, SourcePosition pos)
Definition ast.h:162
std::optional< Expression * > initializer
Definition ast.h:774
std::optional< TypeExpression * > type
Definition ast.h:773
Symbol identifier
Symbol declaration
#define AST_NODE_KIND_LIST(V)
Definition ast.h:91
#define DEFINE_AST_NODE_INNER_BOILERPLATE(T)
Definition ast.h:134
#define DEFINE_AST_NODE_LEAF_BOILERPLATE(T)
Definition ast.h:121