v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
preparser.h
Go to the documentation of this file.
1// Copyright 2012 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_PARSING_PREPARSER_H_
6#define V8_PARSING_PREPARSER_H_
7
9#include "src/ast/ast.h"
10#include "src/ast/scopes.h"
15
16namespace v8 {
17namespace internal {
18
19// Whereas the Parser generates AST during the recursive descent,
20// the PreParser doesn't create a tree. Instead, it passes around minimal
21// data objects (PreParserExpression, PreParserIdentifier etc.) which contain
22// just enough data for the upper layer functions. PreParserFactory is
23// responsible for creating these dummy objects. It provides a similar kind of
24// interface as AstNodeFactory, so ParserBase doesn't need to care which one is
25// used.
26
27class PreparseDataBuilder;
28
30 public:
53 bool IsNull() const { return type_ == kNullIdentifier; }
54 bool IsEval() const { return type_ == kEvalIdentifier; }
55 bool IsAsync() const { return type_ == kAsyncIdentifier; }
56 bool IsArguments() const { return type_ == kArgumentsIdentifier; }
61 bool IsConstructor() const { return type_ == kConstructorIdentifier; }
62 bool IsPrivateName() const { return type_ == kPrivateNameIdentifier; }
63
64 private:
74
75 explicit PreParserIdentifier(Type type) : string_(nullptr), type_(type) {}
77
79 friend class PreParserExpression;
80 friend class PreParser;
81};
82
84 public:
86
91
95
100
105
110
115
119
124
130
136
142
148
153
159
165
171
172 bool IsNull() const { return TypeField::decode(code_) == kNull; }
173 bool IsFailureExpression() const {
175 }
176
177 bool IsIdentifier() const {
179 }
180
185
190
194
198
203
210
219
226
232
237
242
243 // At the moment PreParser doesn't track these expression types.
244 bool IsFunctionLiteral() const { return false; }
245 bool IsCallNew() const { return false; }
246 bool is_tagged_template() const { return false; }
247
249
253
257
258 PreParserExpression* AsCall() { return this; }
260
261 // Dummy implementation for making expression->somefunc() work in both Parser
262 // and PreParser.
263 PreParserExpression* operator->() { return this; }
264
265 // More dummy implementations of things PreParser doesn't need to track:
267
268 int position() const { return kNoSourcePosition; }
270 void set_suspend_count(int suspend_count) {}
271
272 private:
281
294
295 explicit PreParserExpression(uint32_t expression_code)
296 : code_(expression_code) {}
297
298 // The first three bits are for the Type.
300
301 // The high order bit applies only to nodes which would inherit from the
302 // Expression ASTNode --- This is by necessity, due to the fact that
303 // Expression nodes may be represented as multiple Types, not exclusively
304 // through kExpression.
305 // TODO(caitp, adamk): clean up PreParserExpression bitfields.
307
308 // The rest of the bits are interpreted depending on the value
309 // of the Type field, so they can share the storage.
314
315 uint32_t code_;
316 friend class PreParser;
317 friend class PreParserFactory;
319};
320
323 public:
326 void Add(const PreParserStatement& element, Zone* zone) {}
328 bool IsNull() const { return is_null_; }
329
330 private:
331 explicit PreParserStatementList(bool is_null) : is_null_(is_null) {}
333};
334
336 public:
337 explicit PreParserScopedStatementList(std::vector<void*>* buffer) {}
338 void Rewind() {}
340 void Add(const PreParserStatement& element) {}
341 int length() { return 0; }
342};
343
344// The pre-parser doesn't need to build lists of expressions, identifiers, or
345// the like. If the PreParser is used in variable tracking mode, it needs to
346// build lists of variables though.
348 public:
349 explicit PreParserExpressionList(std::vector<void*>* buffer) : length_(0) {}
350
351 int length() const { return length_; }
352
353 void Add(const PreParserExpression& expression) {
354 ++length_;
355 }
356
357 private:
359
360 friend class PreParser;
361 friend class PreParserFactory;
362};
363
365 public:
369
373
377
381
384
385 // Creates expression statement from expression.
386 // Preserves being an unparenthesized string literal, possibly
387 // "use strict".
389 const PreParserExpression& expression) {
390 if (expression.IsStringLiteral()) {
392 }
393 return Default();
394 }
395
397
399 return code_ == kJumpStatement;
400 }
401
402 bool IsNull() { return code_ == kNullStatement; }
403
405
407 DCHECK(!IsNull());
408 return false;
409 }
410
411 // Dummy implementation for making statement->somefunc() work in both Parser
412 // and PreParser.
413 PreParserStatement* operator->() { return this; }
414
417
418 void set_scope(Scope* scope) {}
420 const SourceRange& body_range = {}) {}
423 const SourceRange& body_range = {}) {}
425 PreParserStatement body, Scope* subject_scope) {}
426
427 protected:
435
436 explicit PreParserStatement(Type code) : code_(code) {}
437
438 private:
440};
441
442// A PreParserBlock extends statement with a place to store the scope.
443// The scope is dropped as the block is returned as a statement.
445 public:
447 Scope* scope() const { return scope_; }
454 // Dummy implementation for making block->somefunc() work in both Parser and
455 // PreParser.
456 PreParserBlock* operator->() { return this; }
457
458 private:
460 : PreParserStatement(type), scope_(nullptr) {}
462};
463
465 public:
466 explicit PreParserFactory(AstValueFactory* ast_value_factory, Zone* zone)
467 : ast_node_factory_(ast_value_factory, zone) {}
468
470
476 int pos) {
478 }
486 int js_flags, int pos) {
488 }
490 int first_spread_index, int pos) {
492 }
494 const PreParserExpression& value,
496 bool is_static,
497 bool is_computed_name,
498 bool is_private) {
500 }
508 const PreParserExpression& value,
509 bool is_computed_name) {
511 }
513 const PreParserExpressionList& properties, int boilerplate_properties,
514 int pos, bool has_rest_property, Variable* home_object = nullptr) {
516 }
520
522 // Needed to track `delete a?.#b` early errors
523 if (expr.IsPrivateReference()) {
525 }
527 }
528
530 const PreParserExpression& key, int pos,
531 bool optional_chain = false) {
532 if (key.IsIdentifier() && key.AsIdentifier().IsPrivateName()) {
533 if (obj.IsThis()) {
535 }
537 }
538
539 if (obj.IsThis()) {
541 }
543 }
562 const PreParserExpression& left,
563 const PreParserExpression& right, int pos) {
564 // Identifiers need to be tracked since this might be a parameter with a
565 // default value inside an arrow function parameter list.
567 }
569 Suspend::OnAbruptResume on_abrupt_resume) {
571 }
579 PreParserExpression NewConditionalChain(size_t initial_size, int pos) {
581 }
583 const PreParserExpression& then_expression,
584 const PreParserExpression& else_expression,
585 int pos) {
587 }
589 const PreParserExpression& expression,
590 int pos) {
592 }
594 const PreParserExpressionList& arguments, int pos,
595 bool has_spread, int eval_scope_info_index = 0,
596 bool optional_chain = false) {
597 if (eval_scope_info_index > 0) {
598 DCHECK(expression.IsIdentifier() && expression.AsIdentifier().IsEval());
599 DCHECK(!optional_chain);
601 }
603 }
605 const PreParserExpressionList& arguments,
606 int pos, bool has_spread) {
608 }
610 const PreParserExpression& expression, int pos,
611 int continuation_pos = kNoSourcePosition) {
613 }
615 const PreParserExpression& expression, int pos,
616 int continuation_pos = kNoSourcePosition) {
618 }
620 const PreParserIdentifier& name, Scope* scope,
621 const PreParserScopedStatementList& body, int expected_property_count,
622 int parameter_count, int function_length,
624 FunctionSyntaxKind function_syntax_kind,
625 FunctionLiteral::EagerCompileHint eager_compile_hint, int position,
626 bool has_braces, int function_literal_id,
627 ProducedPreparseData* produced_preparse_data = nullptr) {
628 DCHECK_NULL(produced_preparse_data);
630 }
631
633 int expr_pos) {
635 }
636
642
644
645 PreParserBlock NewBlock(int capacity, bool ignore_completion_value) {
647 }
648
649 PreParserBlock NewBlock(bool ignore_completion_value, bool is_breakable) {
651 }
652
653 PreParserBlock NewBlock(bool ignore_completion_value,
654 const PreParserScopedStatementList& list) {
656 }
657
661
666
668 PreParserStatement then_statement,
669 PreParserStatement else_statement, int pos,
670 SourceRange then_range = {},
671 SourceRange else_range = {}) {
672 // This must return a jump statement iff both clauses are jump statements.
673 return else_statement.IsJumpStatement() ? then_statement : else_statement;
674 }
675
677 PreParserStatement target, int pos,
678 int continuation_pos = kNoSourcePosition) {
680 }
681
683 PreParserStatement target, int pos,
684 int continuation_pos = kNoSourcePosition) {
686 }
687
693
697
701
706
712
716
721
725
731
733 const PreParserExpression& specifier, const ModuleImportPhase phase,
734 const PreParserExpression& import_options, int pos) {
736 }
737
738 private:
739 // For creating VariableProxy objects to track unresolved variables.
741};
742
743class PreParser;
744
746 public:
749
751 bool has_duplicate() { return has_duplicate_; }
752 void ValidateDuplicate(PreParser* preparser) const;
753
758 void ValidateStrictMode(PreParser* preparser) const;
759
760 private:
761 bool has_duplicate_ = false;
763};
764
766 public:
770 delete;
772 void Infer() const {}
773 void RemoveLastFunction() const {}
774
775 class State {
776 public:
778 State(const State&) = delete;
779 State& operator=(const State&) = delete;
780 };
781};
782
784 public:
788 static PreParserSourceRange OpenEnded(int32_t start) { return Empty(); }
790 const PreParserSourceRange& that, int end) {
791 return that;
792 }
793};
794
805
807
808template <>
841
842
843// Preparsing checks a JavaScript program and emits preparse-data that helps
844// a later parsing to be faster.
845// See preparse-data-format.h for the data format.
846
847// The PreParser checks that the syntax follows the grammar for JavaScript,
848// and collects some information about the program along the way.
849// The grammar check is only performed in order to understand the program
850// sufficiently to deduce some information about it, that can be used
851// to speed up later parsing. Finding errors is not the goal of pre-parsing,
852// rather it is to speed up properly written and correct programs.
853// That means that contextual checks (like a label being declared where
854// it is used) are generally omitted.
855class PreParser : public ParserBase<PreParser> {
856 friend class ParserBase<PreParser>;
857
858 public:
862
868
872 RuntimeCallStats* runtime_call_stats, V8FileLogger* v8_file_logger,
873 UnoptimizedCompileFlags flags, bool parsing_on_main_thread = true)
874 // Set compile_hints_magic_enabled = false, since we cannot have eager
875 // functions inside lazy functions (when we're already using the
876 // PreParser). Ditto compile_hints_per_function_magic_enabled.
879 pending_error_handler, runtime_call_stats, v8_file_logger, flags,
880 parsing_on_main_thread,
881 /*compile_hints_magic_enabled=*/false,
882 /*compile_hints_per_function_magic_enabled=*/false),
883 use_counts_(nullptr),
884 preparse_data_builder_(nullptr),
887 }
888
889 static bool IsPreParser() { return true; }
890
892
893 // Pre-parse the program from the character stream; returns true on
894 // success (even if parsing failed, the pre-parse data successfully
895 // captured the syntax error), and false if a stack-overflow happened
896 // during parsing.
898
899 // Parses a single function literal, from the opening parentheses before
900 // parameters to the closing brace after the body.
901 // Returns a FunctionEntry describing the body of the function in enough
902 // detail that it can be lazily compiled.
903 // The scanner is expected to have matched the "function" or "function*"
904 // keyword and parameters, and have consumed the initial '{'.
905 // At return, unless an error occurred, the scanner is positioned before the
906 // the final '}'.
908 const AstRawString* function_name, FunctionKind kind,
909 FunctionSyntaxKind function_syntax_kind, DeclarationScope* function_scope,
910 int* use_counts, ProducedPreparseData** produced_preparser_scope_data);
911
915
919
920 std::vector<void*>* preparse_data_builder_buffer() {
922 }
923
924 private:
930 // These types form an algebra over syntactic categories that is just
931 // rich enough to let us recognize and propagate the constructs that
932 // are either being counted in the preparser data, or is important
933 // to throw the correct syntax error exceptions.
934
935 // All ParseXXX functions take as the last argument an *ok parameter
936 // which is set to false if parsing failed; it is unchanged otherwise.
937 // By making the 'exception handling' explicit, we are forced to check
938 // for failure at the call sites.
939
940 // Indicates that we won't switch from the preparser to the preparser; we'll
941 // just stay where we are.
942 bool AllowsLazyParsingWithoutUnresolvedVariables() const { return false; }
943 bool parse_lazily() const { return false; }
944
948
950 FunctionSyntaxKind function_syntax_kind,
951 DeclarationScope* function_scope,
952 int* num_parameters, int* function_length,
953 ProducedPreparseData** produced_preparse_data) {
954 UNREACHABLE();
955 }
956
958 Identifier name, Scanner::Location function_name_location,
959 FunctionNameValidity function_name_validity, FunctionKind kind,
960 int function_token_pos, FunctionSyntaxKind function_syntax_kind,
962 ZonePtrList<const AstRawString>* arguments_for_wrapped_function);
963
967
968 bool HasCheckedSyntax() { return false; }
969
971
973
979 V8_INLINE void AddTemplateSpan(TemplateLiteralState* state, bool should_cook,
980 bool tail) {}
986 return expression.IsPrivateReference();
987 }
992
994
999
1002 Scope* scope, bool* was_added, int position) {
1003 return DeclareVariableName(name, mode, scope, was_added, position, kind);
1004 }
1005
1007 VariableMode mode, Scope* scope, bool* was_added,
1008 int initializer_position) {
1009 Variable* var = DeclareVariableName(proxy->raw_name(), mode, scope,
1010 was_added, proxy->position(), kind);
1011 var->set_initializer_position(initializer_position);
1012 // Don't bother actually binding the proxy.
1013 }
1014
1017 IsStaticFlag is_static_flag,
1018 bool* was_added) {
1020 return scope->DeclarePrivateName(name, mode, is_static_flag, was_added);
1021 }
1022
1024 Scope* scope, bool* was_added,
1028 Variable* var = scope->DeclareVariableName(name, mode, was_added, kind);
1029 if (var == nullptr) {
1032 var = scope->LookupLocal(name);
1033 } else if (var->scope() != scope) {
1036 Declaration* nested_declaration =
1038 position);
1039 nested_declaration->set_var(var);
1040 var->scope()->declarations()->Add(nested_declaration);
1041 }
1042 return var;
1043 }
1044
1046 return PreParserBlock::Default();
1047 }
1048
1053
1055 PreParserStatement try_block, PreParserStatement catch_block,
1056 const SourceRange& catch_range, PreParserStatement finally_block,
1057 const SourceRange& finally_range, const CatchInfo& catch_info, int pos) {
1059 }
1060
1062 Scanner::Location location, Token::Value token,
1063 MessageTemplate message = MessageTemplate::kUnexpectedToken) {
1065 }
1068 ParseStatementList(body, Token::kRightBrace);
1069 }
1075 FunctionSyntaxKind function_syntax_kind,
1076 DeclarationScope* function_scope) {
1077 if (function_syntax_kind == FunctionSyntaxKind::kNamedExpression &&
1078 function_scope->LookupLocal(function_name) == nullptr) {
1079 DCHECK_EQ(function_scope, scope());
1080 function_scope->DeclareFunctionVar(function_name);
1081 }
1082 }
1083
1085 const PreParserIdentifier& function_name,
1086 FunctionSyntaxKind function_syntax_kind,
1087 DeclarationScope* function_scope) {
1088 DeclareFunctionNameVar(function_name.string_, function_syntax_kind,
1089 function_scope);
1090 }
1091
1093 const AstRawString* other);
1094
1096 const PreParserIdentifier& variable_name,
1097 const PreParserExpression& function, VariableMode mode, VariableKind kind,
1098 int beg_pos, int end_pos, ZonePtrList<const AstRawString>* names) {
1099 DCHECK_NULL(names);
1100 bool was_added;
1101 Variable* var = DeclareVariableName(variable_name.string_, mode, scope(),
1102 &was_added, beg_pos, kind);
1104 Token::Value init =
1105 loop_nesting_depth() > 0 ? Token::kAssign : Token::kInit;
1108 end_pos, var, init);
1110 }
1111 return Statement::Default();
1112 }
1113
1115 const PreParserIdentifier& variable_name,
1117 int class_token_pos, int end_pos) {
1118 // Preparser shouldn't be used in contexts where we need to track the names.
1119 DCHECK_NULL(names);
1120 bool was_added;
1122 &was_added);
1124 }
1126 const PreParserIdentifier& name,
1127 ClassInfo* class_info,
1128 int class_token_pos) {
1129 DCHECK_IMPLIES(IsEmptyIdentifier(name), class_info->is_anonymous);
1130 // Declare a special class variable for anonymous classes with the dot
1131 // if we need to save it for static private method access.
1132 scope->DeclareClassVariable(ast_value_factory(), name.string_,
1133 class_token_pos);
1134 }
1136 const PreParserExpression& property,
1137 bool is_constructor,
1138 ClassInfo* class_info) {}
1139
1141 const PreParserExpression& property, ClassInfo* class_info,
1142 bool is_static) {}
1144 const PreParserExpression& property,
1145 bool is_static, bool is_computed_name,
1146 ClassInfo* class_info) {
1147 if (is_computed_name) {
1148 bool was_added;
1151 class_info->computed_field_count),
1152 VariableMode::kConst, scope, &was_added);
1153 }
1154 }
1155
1157 ClassScope* scope, const PreParserIdentifier& property_name,
1159 bool is_static, ClassInfo* class_info) {
1160 bool was_added;
1161
1163 property_name.string_, scope, GetVariableMode(kind),
1165 &was_added);
1166 if (!was_added) {
1167 Scanner::Location loc(property.position(), property.position() + 1);
1168 ReportMessageAt(loc, MessageTemplate::kVarRedeclaration,
1169 property_name.string_);
1170 }
1171 }
1172
1174 ClassInfo* class_info) {
1175 DCHECK(class_info->has_static_elements());
1176 }
1177
1179 // Creating and disposing of a FunctionState makes tracking of
1180 // next_function_is_likely_called match what Parser does. TODO(marja):
1181 // Make the lazy function + next_function_is_likely_called + default ctor
1182 // logic less surprising. Default ctors shouldn't affect the laziness of
1183 // functions.
1184 DeclarationScope* function_scope = NewFunctionScope(kind);
1185 SetLanguageMode(function_scope, LanguageMode::kStrict);
1186 function_scope->set_start_position(pos);
1187 function_scope->set_end_position(pos);
1188 FunctionState function_state(&function_state_, &scope_, function_scope);
1189 GetNextInfoId();
1190 }
1191
1194 ClassInfo* class_info, int pos) {
1195 bool has_default_constructor = !class_info->has_seen_constructor;
1196 // Account for the default constructor.
1197 if (has_default_constructor) {
1198 bool has_extends = class_info->extends.IsNull();
1202 }
1204 }
1205
1210
1211 // Helper functions for recursive descent.
1213 return identifier.IsEval();
1214 }
1215
1217 return identifier.IsAsync();
1218 }
1219
1221 return identifier.IsArguments();
1222 }
1223
1225 const PreParserIdentifier& identifier) const {
1226 return identifier.IsEvalOrArguments();
1227 }
1228
1229 // Returns true if the expression is of type "this.foo".
1230 V8_INLINE static bool IsThisProperty(const PreParserExpression& expression) {
1231 return expression.IsThisProperty();
1232 }
1233
1234 V8_INLINE static bool IsIdentifier(const PreParserExpression& expression) {
1235 return expression.IsIdentifier();
1236 }
1237
1239 const PreParserExpression& expression) {
1240 return expression.AsIdentifier();
1241 }
1242
1244 const PreParserExpression& expression) {
1245 return expression;
1246 }
1247
1249 return identifier.IsConstructor();
1250 }
1251
1253 const PreParserExpression& property) {
1254 // PreParser doesn't count boilerplate properties.
1255 return false;
1256 }
1257
1259 // Preparsing is disabled for extensions (because the extension
1260 // details aren't passed to lazily compiled functions), so we
1261 // don't accept "native function" in the preparser and there is
1262 // no need to keep track of "native".
1263 return false;
1264 }
1265
1266 V8_INLINE bool IsNative(const PreParserExpression& expr) const {
1267 // Preparsing is disabled for extensions (because the extension
1268 // details aren't passed to lazily compiled functions), so we
1269 // don't accept "native function" in the preparser and there is
1270 // no need to keep track of "native".
1271 return false;
1272 }
1273
1274 V8_INLINE static bool IsArrayIndex(const PreParserIdentifier& string,
1275 uint32_t* index) {
1276 return false;
1277 }
1278
1280 return statement.IsStringLiteral();
1281 }
1282
1284 PreParserIdentifier* default_string,
1285 PreParserIdentifier* dot_default_string) {}
1286
1287 // Functions for encapsulating the differences between parsing and preparsing;
1288 // operations interleaved with the recursive descent.
1294 const PreParserExpression& expression) {}
1296
1299
1301 const PreParserExpression& y,
1302 Token::Value op, int pos) {
1303 return false;
1304 }
1305
1308 PreParserExpression then_expression,
1309 PreParserExpression else_expression,
1310 int pos,
1311 const SourceRange& then_range) {
1312 return false;
1313 }
1314
1317
1320 int pos, const SourceRange& range) {
1321 x->clear_parenthesized();
1322 return false;
1323 }
1324
1329
1331 BuildInitializationBlock(DeclarationParsingResult* parsing_result) {
1333 }
1334
1336 return PreParserBlock::Null();
1337 }
1338
1340 ForInfo* for_info, PreParserStatement* body_block,
1341 PreParserExpression* each_variable) {
1342 }
1343
1345 const ForInfo& for_info) {
1346 if (IsLexicalVariableMode(for_info.parsing_result.descriptor.mode)) {
1347 for (auto name : for_info.bound_names) {
1348 bool was_added;
1349 DeclareVariableName(name, VariableMode::kLet, scope(), &was_added);
1350 }
1351 return PreParserBlock::Default();
1352 }
1353 return init_block;
1354 }
1355
1358 const PreParserExpression& cond, PreParserStatement next,
1359 PreParserStatement body, Scope* inner_scope, const ForInfo& for_info) {
1360 // See Parser::DesugarLexicalBindingsInForStatement.
1361 for (auto name : for_info.bound_names) {
1362 bool was_added;
1363 DeclareVariableName(name, for_info.parsing_result.descriptor.mode,
1364 inner_scope, &was_added);
1365 }
1366 return loop;
1367 }
1368
1370 const PreParserFormalParameters& parameters);
1371
1373 scope->HoistSloppyBlockFunctions(nullptr);
1374 }
1375
1378
1383
1385 const PreParserIdentifier& x) {
1386 return x.string_;
1387 }
1388
1393
1395 return arg.string_;
1396 }
1397
1399
1400 // "null" return type creators.
1420
1421 template <typename T>
1422 V8_INLINE static bool IsNull(T subject) {
1423 return subject.IsNull();
1424 }
1425
1427 return subject.IsIterationStatement();
1428 }
1429
1436 return subject.string_->IsEmpty();
1437 }
1438
1439 // Producing data during the recursive descent.
1443
1445
1449
1453
1457
1462
1467
1471
1473 scope()->NewUnresolved(factory()->ast_node_factory(),
1474 ast_value_factory()->this_function_string(), pos,
1476 scope()->NewUnresolved(factory()->ast_node_factory(),
1477 ast_value_factory()->new_target_string(), pos,
1480 }
1481
1485
1489
1491 int pos) {
1492 if (token != Token::kString) return PreParserExpression::Default();
1494 }
1495
1497 PrivateNameScopeIterator* private_name_scope,
1498 const PreParserIdentifier& name, int start_position) {
1500 name.string_, NORMAL_VARIABLE, start_position);
1501 private_name_scope->AddUnresolvedPrivateName(proxy);
1503 }
1504
1506 const PreParserIdentifier& name, int start_position,
1507 InferName infer = InferName::kYes) {
1508 expression_scope()->NewVariable(name.string_, start_position);
1510 }
1511
1513 int start_position) {
1514 expression_scope()->Declare(name.string_, start_position);
1515 }
1516
1521
1525
1529
1533
1535 ClassScope* scope, ClassInfo* class_info, const PreParserIdentifier& name,
1536 const PreParserExpression& key, const PreParserExpression& value,
1537 bool is_static, bool is_computed_name, bool is_private, int pos) {
1538 // Declare the accessor storage name variable and generated getter and
1539 // setter.
1540 bool was_added;
1543 class_info->autoaccessor_count++),
1544 VariableMode::kConst, scope, &was_added);
1545 DCHECK(was_added);
1554 is_computed_name, is_private);
1555 }
1556
1559 const PreParserExpressionList& arguments, int pos) {
1561 }
1562
1565 return PreParserStatement::Jump();
1566 }
1567
1570 const PreParserExpression& initializer,
1571 int initializer_end_position,
1572 bool is_rest) {
1573 DeclarationScope* scope = parameters->scope;
1574 scope->RecordParameter(is_rest);
1575 parameters->UpdateArityAndFunctionLength(!initializer.IsNull(), is_rest);
1576 }
1577
1583 const PreParserFormalParameters* parameters) {
1584 if (!parameters->is_simple) parameters->scope->SetHasNonSimpleParameters();
1585 }
1586
1588 PreParserFormalParameters* parameters, const PreParserExpression& params,
1589 const Scanner::Location& params_loc) {
1590 }
1591
1596
1598 const PreParserExpression& property, const PreParserIdentifier& name,
1599 const AstRawString* prefix = nullptr) {}
1603
1605 if (use_counts_ != nullptr) ++use_counts_[feature];
1606 }
1607
1608 V8_INLINE bool ParsingDynamicFunctionDeclaration() const { return false; }
1609
1611 FunctionLiteral::EagerCompileHint current_compile_hint, int position) {
1612 return current_compile_hint;
1613 }
1614
1615// Generate empty functions here as the preparser does not collect source
1616// ranges for block coverage.
1617#define DEFINE_RECORD_SOURCE_RANGE(Name) \
1618 template <typename... Ts> \
1619 V8_INLINE void Record##Name##SourceRange(Ts... args) {}
1621#undef DEFINE_RECORD_SOURCE_RANGE
1622
1623 // Preparser's private field members.
1624
1627
1630};
1631
1632} // namespace internal
1633} // namespace v8
1634
1635#endif // V8_PARSING_PREPARSER_H_
#define AST_SOURCE_RANGE_LIST(V)
int16_t parameter_count
Definition builtins.cc:67
Builtins::Kind kind
Definition builtins.cc:40
SourcePosition pos
static constexpr T decode(U value)
Definition bit-field.h:66
static constexpr U encode(T value)
Definition bit-field.h:55
static V8_NODISCARD constexpr U update(U previous, T value)
Definition bit-field.h:61
NestedVariableDeclaration * NewNestedVariableDeclaration(Scope *scope, int pos)
Definition ast.h:3044
SloppyBlockFunctionStatement * NewSloppyBlockFunctionStatement(int pos, Variable *var, Token::Value init)
Definition ast.h:3215
VariableProxy * NewVariableProxy(Variable *var, int start_position=kNoSourcePosition)
Definition ast.h:3299
int position() const
Definition ast.h:155
void DeclareSloppyBlockFunction(SloppyBlockFunctionStatement *sloppy_block_function)
Definition scopes.cc:576
Variable * DeclareFunctionVar(const AstRawString *name, Scope *cache=nullptr)
Definition scopes.cc:813
void set_var(Variable *var)
Definition ast.h:376
V8_INLINE void ParseStatementList(StatementListT *body, Token::Value end_token)
V8_INLINE DeclarationScope * GetDeclarationScope() const
V8_INLINE ExpressionScope * expression_scope() const
const AstRawString * ClassFieldVariableName(AstValueFactory *ast_value_factory, int index)
DeclarationScope * NewFunctionScope(FunctionKind kind, Zone *parse_zone=nullptr) const
VariableMode GetVariableMode(ClassLiteralProperty::Kind kind)
typename Types::SourceRange SourceRange
typename Types::Statement StatementT
const AstRawString * AutoAccessorVariableName(AstValueFactory *ast_value_factory, int index)
AstValueFactory * ast_value_factory() const
PendingCompilationErrorHandler * pending_error_handler_
V8_NOINLINE void ReportMessageAt(Scanner::Location source_location, MessageTemplate message, const Ts &... args)
PreParserBlock * operator->()
Definition preparser.h:456
static PreParserBlock Null()
Definition preparser.h:451
void set_scope(Scope *scope)
Definition preparser.h:446
PreParserBlock(PreParserStatement::Type type)
Definition preparser.h:459
static PreParserBlock Default()
Definition preparser.h:448
PreParserExpressionList(std::vector< void * > *buffer)
Definition preparser.h:349
void Add(const PreParserExpression &expression)
Definition preparser.h:353
void set_suspend_count(int suspend_count)
Definition preparser.h:270
PreParserExpression * AsFunctionLiteral()
Definition preparser.h:259
static PreParserExpression ThisProperty()
Definition preparser.h:131
PreParserExpression(uint32_t expression_code)
Definition preparser.h:295
static PreParserExpression Assignment()
Definition preparser.h:101
static PreParserExpression ImportCall()
Definition preparser.h:160
void set_function_token_position(int position)
Definition preparser.h:269
static PreParserExpression Failure()
Definition preparser.h:88
PreParserExpression * operator->()
Definition preparser.h:263
static PreParserExpression Call()
Definition preparser.h:149
static PreParserExpression This()
Definition preparser.h:120
static PreParserExpression Null()
Definition preparser.h:87
static PreParserExpression Property()
Definition preparser.h:137
static PreParserExpression CallEval()
Definition preparser.h:154
static PreParserExpression FromIdentifier(const PreParserIdentifier &id)
Definition preparser.h:96
static PreParserExpression SuperCallReference()
Definition preparser.h:166
static PreParserExpression Default()
Definition preparser.h:92
static PreParserExpression PrivateReference()
Definition preparser.h:143
static PreParserExpression StringLiteral()
Definition preparser.h:116
static PreParserExpression ObjectLiteral()
Definition preparser.h:106
PreParserIdentifier AsIdentifier() const
Definition preparser.h:181
static PreParserExpression ThisPrivateReference()
Definition preparser.h:125
PreParserExpression * AsCall()
Definition preparser.h:258
static PreParserExpression ArrayLiteral()
Definition preparser.h:111
PreParserStatement NewForOfStatement(int pos, IteratorType type)
Definition preparser.h:722
PreParserStatement NewDoWhileStatement(int pos)
Definition preparser.h:694
PreParserStatement NewContinueStatement(PreParserStatement target, int pos, int continuation_pos=kNoSourcePosition)
Definition preparser.h:682
PreParserExpression NewConditional(const PreParserExpression &condition, const PreParserExpression &then_expression, const PreParserExpression &else_expression, int pos)
Definition preparser.h:582
PreParserBlock NewBlock(bool ignore_completion_value, const PreParserScopedStatementList &list)
Definition preparser.h:653
PreParserExpression NewBinaryOperation(Token::Value op, const PreParserExpression &left, const PreParserExpression &right, int pos)
Definition preparser.h:549
PreParserStatement NewSwitchStatement(const PreParserExpression &tag, int pos)
Definition preparser.h:702
PreParserExpression NewSpread(const PreParserExpression &expression, int pos, int expr_pos)
Definition preparser.h:632
PreParserExpression NewCallNew(const PreParserExpression &expression, const PreParserExpressionList &arguments, int pos, bool has_spread)
Definition preparser.h:604
AstNodeFactory * ast_node_factory()
Definition preparser.h:469
PreParserFactory(AstValueFactory *ast_value_factory, Zone *zone)
Definition preparser.h:466
PreParserExpression NewYield(const PreParserExpression &expression, int pos, Suspend::OnAbruptResume on_abrupt_resume)
Definition preparser.h:568
PreParserExpression NewNumberLiteral(double number, int pos)
Definition preparser.h:475
PreParserStatement NewWithStatement(Scope *scope, const PreParserExpression &expression, PreParserStatement statement, int pos)
Definition preparser.h:688
PreParserExpression NewConditionalChain(size_t initial_size, int pos)
Definition preparser.h:579
PreParserExpression NewVariableProxy(void *variable)
Definition preparser.h:517
PreParserExpression NewStringLiteral(const PreParserIdentifier &identifier, int pos)
Definition preparser.h:471
PreParserExpression NewCall(PreParserExpression expression, const PreParserExpressionList &arguments, int pos, bool has_spread, int eval_scope_info_index=0, bool optional_chain=false)
Definition preparser.h:593
PreParserExpression NewCountOperation(Token::Value op, bool is_prefix, const PreParserExpression &expression, int pos)
Definition preparser.h:588
PreParserExpression NewObjectLiteralProperty(const PreParserExpression &key, const PreParserExpression &value, ObjectLiteralProperty::Kind kind, bool is_computed_name)
Definition preparser.h:501
PreParserExpression NewOptionalChain(const PreParserExpression &expr)
Definition preparser.h:521
PreParserStatement NewForEachStatement(ForEachStatement::VisitMode visit_mode, int pos)
Definition preparser.h:717
PreParserExpression NewEmptyParentheses(int pos)
Definition preparser.h:637
PreParserExpression NewFunctionLiteral(const PreParserIdentifier &name, Scope *scope, const PreParserScopedStatementList &body, int expected_property_count, int parameter_count, int function_length, FunctionLiteral::ParameterFlag has_duplicate_parameters, FunctionSyntaxKind function_syntax_kind, FunctionLiteral::EagerCompileHint eager_compile_hint, int position, bool has_braces, int function_literal_id, ProducedPreparseData *produced_preparse_data=nullptr)
Definition preparser.h:619
PreParserStatement NewExpressionStatement(const PreParserExpression &expr, int pos)
Definition preparser.h:662
PreParserExpression NewImportCallExpression(const PreParserExpression &specifier, const ModuleImportPhase phase, const PreParserExpression &import_options, int pos)
Definition preparser.h:732
AstNodeFactory ast_node_factory_
Definition preparser.h:740
PreParserBlock NewBlock(int capacity, bool ignore_completion_value)
Definition preparser.h:645
PreParserExpression NewCompareOperation(Token::Value op, const PreParserExpression &left, const PreParserExpression &right, int pos)
Definition preparser.h:555
PreParserBlock NewBlock(bool ignore_completion_value, bool is_breakable)
Definition preparser.h:649
PreParserExpression NewAwait(const PreParserExpression &expression, int pos)
Definition preparser.h:572
PreParserStatement NewForStatement(int pos)
Definition preparser.h:713
PreParserStatement NewCaseClause(const PreParserExpression &label, const PreParserScopedStatementList &statements)
Definition preparser.h:707
PreParserExpression NewProperty(const PreParserExpression &obj, const PreParserExpression &key, int pos, bool optional_chain=false)
Definition preparser.h:529
PreParserExpression NewObjectLiteralProperty(const PreParserExpression &key, const PreParserExpression &value, bool is_computed_name)
Definition preparser.h:507
PreParserExpression NewUndefinedLiteral(int pos)
Definition preparser.h:479
PreParserStatement NewAsyncReturnStatement(const PreParserExpression &expression, int pos, int continuation_pos=kNoSourcePosition)
Definition preparser.h:614
PreParserExpression NewUnaryOperation(Token::Value op, const PreParserExpression &expression, int pos)
Definition preparser.h:544
PreParserExpression NewRegExpLiteral(const AstRawString *js_pattern, int js_flags, int pos)
Definition preparser.h:485
PreParserExpression NewTheHoleLiteral()
Definition preparser.h:482
PreParserStatement NewWhileStatement(int pos)
Definition preparser.h:698
PreParserStatement EmptyStatement()
Definition preparser.h:643
PreParserExpression NewAssignment(Token::Value op, const PreParserExpression &left, const PreParserExpression &right, int pos)
Definition preparser.h:561
PreParserExpression NewObjectLiteral(const PreParserExpressionList &properties, int boilerplate_properties, int pos, bool has_rest_property, Variable *home_object=nullptr)
Definition preparser.h:512
PreParserStatement NewDebuggerStatement(int pos)
Definition preparser.h:658
PreParserStatement NewReturnStatement(const PreParserExpression &expression, int pos, int continuation_pos=kNoSourcePosition)
Definition preparser.h:609
PreParserExpression NewYieldStar(const PreParserExpression &iterable, int pos)
Definition preparser.h:575
PreParserExpression NewClassLiteralProperty(const PreParserExpression &key, const PreParserExpression &value, ClassLiteralProperty::Kind kind, bool is_static, bool is_computed_name, bool is_private)
Definition preparser.h:493
PreParserExpression NewImportCallExpression(const PreParserExpression &args, const ModuleImportPhase phase, int pos)
Definition preparser.h:726
PreParserStatement NewBreakStatement(PreParserStatement target, int pos, int continuation_pos=kNoSourcePosition)
Definition preparser.h:676
PreParserExpression NewArrayLiteral(const PreParserExpressionList &values, int first_spread_index, int pos)
Definition preparser.h:489
PreParserStatement NewIfStatement(const PreParserExpression &condition, PreParserStatement then_statement, PreParserStatement else_statement, int pos, SourceRange then_range={}, SourceRange else_range={})
Definition preparser.h:667
void ValidateStrictMode(PreParser *preparser) const
Definition preparser.cc:97
void ValidateDuplicate(PreParser *preparser) const
Definition preparser.cc:93
void set_strict_parameter_error(const Scanner::Location &loc, MessageTemplate message)
Definition preparser.h:754
PreParserFormalParameters(DeclarationScope *scope)
Definition preparser.h:747
State & operator=(const State &)=delete
State(PreParserFuncNameInferrer *fni)
Definition preparser.h:777
PreParserFuncNameInferrer(AstValueFactory *avf)
Definition preparser.h:767
PreParserFuncNameInferrer(const PreParserFuncNameInferrer &)=delete
PreParserFuncNameInferrer & operator=(const PreParserFuncNameInferrer &)=delete
static PreParserIdentifier Eval()
Definition preparser.h:38
static PreParserIdentifier Arguments()
Definition preparser.h:41
static PreParserIdentifier Null()
Definition preparser.h:35
static PreParserIdentifier Async()
Definition preparser.h:47
const AstRawString * string_
Definition preparser.h:76
static PreParserIdentifier PrivateName()
Definition preparser.h:50
static PreParserIdentifier Default()
Definition preparser.h:32
static PreParserIdentifier Constructor()
Definition preparser.h:44
void Add(const PreParserStatement &element)
Definition preparser.h:340
PreParserScopedStatementList(std::vector< void * > *buffer)
Definition preparser.h:337
void MergeInto(const PreParserScopedStatementList *other)
Definition preparser.h:339
const PreParserSourceRange & Finalize() const
Definition preparser.h:798
DISALLOW_IMPLICIT_CONSTRUCTORS(PreParserSourceRangeScope)
PreParserSourceRangeScope(Scanner *scanner, PreParserSourceRange *range)
Definition preparser.h:797
static PreParserSourceRange Empty()
Definition preparser.h:787
static const PreParserSourceRange & ContinuationOf(const PreParserSourceRange &that, int end)
Definition preparser.h:789
PreParserSourceRange(int start, int end)
Definition preparser.h:786
static PreParserSourceRange OpenEnded(int32_t start)
Definition preparser.h:788
void Add(const PreParserStatement &element, Zone *zone)
Definition preparser.h:326
PreParserStatementList * operator->()
Definition preparser.h:325
static PreParserStatementList Null()
Definition preparser.h:327
void Initialize(const PreParserExpression &cond, PreParserStatement body, const SourceRange &body_range={})
Definition preparser.h:419
void set_scope(Scope *scope)
Definition preparser.h:418
static PreParserStatement Null()
Definition preparser.h:374
static PreParserStatement Iteration()
Definition preparser.h:370
PreParserStatement * operator->()
Definition preparser.h:413
static PreParserStatement Default()
Definition preparser.h:366
PreParserStatementList statements()
Definition preparser.h:415
void Initialize(PreParserExpression each, const PreParserExpression &subject, PreParserStatement body, Scope *subject_scope)
Definition preparser.h:424
static PreParserStatement Jump()
Definition preparser.h:378
void InitializeStatements(const PreParserScopedStatementList &statements, Zone *zone)
Definition preparser.h:382
static PreParserStatement ExpressionStatement(const PreParserExpression &expression)
Definition preparser.h:388
PreParserStatementList cases()
Definition preparser.h:416
void Initialize(PreParserStatement init, const PreParserExpression &cond, PreParserStatement next, PreParserStatement body, const SourceRange &body_range={})
Definition preparser.h:421
V8_INLINE void AddTemplateExpression(TemplateLiteralState *state, const PreParserExpression &expression)
Definition preparser.h:977
V8_INLINE void ReindexComputedMemberName(const PreParserExpression &expression)
Definition preparser.h:1580
Variable * DeclareVariable(const AstRawString *name, VariableKind kind, VariableMode mode, InitializationFlag init, Scope *scope, bool *was_added, int position)
Definition preparser.h:1000
Variable * DeclareVariableName(const AstRawString *name, VariableMode mode, Scope *scope, bool *was_added, int position=kNoSourcePosition, VariableKind kind=NORMAL_VARIABLE)
Definition preparser.h:1023
static V8_INLINE PreParserIdentifier NullIdentifier()
Definition preparser.h:1401
V8_INLINE void DeclarePrivateClassMember(ClassScope *scope, const PreParserIdentifier &property_name, const PreParserExpression &property, ClassLiteralProperty::Kind kind, bool is_static, ClassInfo *class_info)
Definition preparser.h:1156
static V8_INLINE PreParserExpression AsIdentifierExpression(const PreParserExpression &expression)
Definition preparser.h:1243
V8_INLINE PreParserExpression NewClassLiteralPropertyWithAccessorInfo(ClassScope *scope, ClassInfo *class_info, const PreParserIdentifier &name, const PreParserExpression &key, const PreParserExpression &value, bool is_static, bool is_computed_name, bool is_private, int pos)
Definition preparser.h:1534
V8_INLINE PreParserExpression CloseTemplateLiteral(TemplateLiteralState *state, int start, const PreParserExpression &tag)
Definition preparser.h:981
V8_INLINE void AddInstanceFieldOrStaticElement(const PreParserExpression &property, ClassInfo *class_info, bool is_static)
Definition preparser.h:1140
static V8_INLINE void CheckAssigningFunctionLiteralToProperty(const PreParserExpression &left, const PreParserExpression &right)
Definition preparser.h:1297
static V8_INLINE PreParserStatement NullStatement()
Definition preparser.h:1416
V8_INLINE void DeclarePublicClassMethod(const PreParserIdentifier &class_name, const PreParserExpression &property, bool is_constructor, ClassInfo *class_info)
Definition preparser.h:1135
V8_INLINE void DeclareArrowFunctionFormalParameters(PreParserFormalParameters *parameters, const PreParserExpression &params, const Scanner::Location &params_loc)
Definition preparser.h:1587
V8_INLINE bool IsAsync(const PreParserIdentifier &identifier) const
Definition preparser.h:1216
PreParserLogger * logger()
Definition preparser.h:891
V8_INLINE bool IsArguments(const PreParserIdentifier &identifier) const
Definition preparser.h:1220
V8_INLINE void SetFunctionNameFromPropertyName(const PreParserExpression &property, const PreParserIdentifier &name, const AstRawString *prefix=nullptr)
Definition preparser.h:1597
V8_INLINE void AddFormalParameter(PreParserFormalParameters *parameters, const PreParserExpression &pattern, const PreParserExpression &initializer, int initializer_end_position, bool is_rest)
Definition preparser.h:1568
V8_INLINE PreParserStatement DeclareNative(const PreParserIdentifier &name, int pos)
Definition preparser.h:1206
V8_INLINE void ReportVarRedeclarationIn(const AstRawString *name, Scope *scope)
Definition preparser.h:1049
V8_INLINE PreParserPropertyList NewClassStaticElementList(int size) const
Definition preparser.h:1526
V8_INLINE void DeclareFunctionNameVar(const AstRawString *function_name, FunctionSyntaxKind function_syntax_kind, DeclarationScope *function_scope)
Definition preparser.h:1074
V8_INLINE PreParserExpression NewTargetExpression(int pos)
Definition preparser.h:1482
V8_INLINE void InsertShadowingVarBindingInitializers(PreParserStatement block)
Definition preparser.h:1376
V8_INLINE PreParserExpression NewSuperCallReference(int pos)
Definition preparser.h:1472
V8_INLINE bool IsNative(const PreParserExpression &expr) const
Definition preparser.h:1266
V8_INLINE void AddTemplateSpan(TemplateLiteralState *state, bool should_cook, bool tail)
Definition preparser.h:979
std::vector< void * > * preparse_data_builder_buffer()
Definition preparser.h:920
PreParserIdentifier GetIdentifier() const
Definition preparser.cc:58
V8_INLINE PreParserIdentifier GetNextSymbol() const
Definition preparser.h:1446
static V8_INLINE PreParserBlock NullBlock()
Definition preparser.h:1419
static V8_INLINE PreParserExpression FailureExpression()
Definition preparser.h:1407
PreParserBlock BuildParameterInitializationBlock(const PreParserFormalParameters &parameters)
Definition preparser.cc:372
V8_INLINE PreParserExpression RewriteClassLiteral(ClassScope *scope, const PreParserIdentifier &name, ClassInfo *class_info, int pos)
Definition preparser.h:1193
V8_INLINE PreParserExpression NewThrowReferenceError(MessageTemplate message, int pos)
Definition preparser.h:1379
V8_INLINE PreParserStatement NewThrowStatement(const PreParserExpression &exception, int pos)
Definition preparser.h:1564
V8_INLINE void SetAsmModule()
Definition preparser.h:991
bool IdentifierEquals(const PreParserIdentifier &identifier, const AstRawString *other)
Definition preparser.cc:396
PreParserExpression InitializeObjectLiteral(PreParserExpression literal)
Definition preparser.h:964
PreParserStatement AsIterationStatement(PreParserStatement s)
Definition preparser.h:1398
static bool IsPreParser()
Definition preparser.h:889
V8_INLINE void PushPropertyName(const PreParserExpression &expression)
Definition preparser.h:1291
PreparseDataBuilder * preparse_data_builder() const
Definition preparser.h:912
V8_INLINE PreParserStatementList NewStatementList(int size) const
Definition preparser.h:1530
V8_INLINE void CountUsage(v8::Isolate::UseCounterFeature feature)
Definition preparser.h:1604
V8_INLINE void AddClassStaticBlock(PreParserBlock block, ClassInfo *class_info)
Definition preparser.h:1173
bool parse_lazily() const
Definition preparser.h:943
V8_INLINE bool IsEmptyIdentifier(PreParserIdentifier subject)
Definition preparser.h:1435
Variable * DeclarePrivateVariableName(const AstRawString *name, ClassScope *scope, VariableMode mode, IsStaticFlag is_static_flag, bool *was_added)
Definition preparser.h:1015
V8_INLINE PreParserIdentifier EmptyIdentifierString() const
Definition preparser.h:1430
V8_INLINE bool ParsingDynamicFunctionDeclaration() const
Definition preparser.h:1608
V8_INLINE bool IsPrivateReference(const PreParserExpression &expression)
Definition preparser.h:985
V8_INLINE void DeclareIdentifier(const PreParserIdentifier &name, int start_position)
Definition preparser.h:1512
V8_INLINE void AddSyntheticFunctionDeclaration(FunctionKind kind, int pos)
Definition preparser.h:1178
static V8_INLINE PreParserStatementList NullStatementList()
Definition preparser.h:1413
static V8_INLINE PreParserExpression NullLiteralProperty()
Definition preparser.h:1410
V8_INLINE bool ShortcutLiteralBinaryExpression(PreParserExpression *x, const PreParserExpression &y, Token::Value op, int pos)
Definition preparser.h:1300
V8_INLINE FunctionLiteral::EagerCompileHint GetEmbedderCompileHint(FunctionLiteral::EagerCompileHint current_compile_hint, int position)
Definition preparser.h:1610
static V8_INLINE void PushLiteralName(const PreParserIdentifier &id)
Definition preparser.h:1289
V8_EXPORT_PRIVATE PreParseResult PreParseProgram()
Definition preparser.cc:67
V8_INLINE PreParserPropertyList NewClassPropertyList(int size) const
Definition preparser.h:1522
static V8_INLINE bool IsThisProperty(const PreParserExpression &expression)
Definition preparser.h:1230
PreParser(Zone *zone, Scanner *scanner, uintptr_t stack_limit, AstValueFactory *ast_value_factory, PendingCompilationErrorHandler *pending_error_handler, RuntimeCallStats *runtime_call_stats, V8FileLogger *v8_file_logger, UnoptimizedCompileFlags flags, bool parsing_on_main_thread=true)
Definition preparser.h:869
static V8_INLINE void PushVariableName(const PreParserIdentifier &id)
Definition preparser.h:1290
V8_INLINE PreParserStatement RewriteSwitchStatement(PreParserStatement switch_statement, Scope *scope)
Definition preparser.h:996
V8_INLINE void DesugarBindingInForEachStatement(ForInfo *for_info, PreParserStatement *body_block, PreParserExpression *each_variable)
Definition preparser.h:1339
V8_INLINE void ParseAsyncGeneratorFunctionBody(int pos, FunctionKind kind, PreParserScopedStatementList *body)
Definition preparser.h:1070
V8_INLINE bool CollapseConditionalChain(PreParserExpression *x, PreParserExpression cond, PreParserExpression then_expression, PreParserExpression else_expression, int pos, const SourceRange &then_range)
Definition preparser.h:1306
PreParseResult PreParseFunction(const AstRawString *function_name, FunctionKind kind, FunctionSyntaxKind function_syntax_kind, DeclarationScope *function_scope, int *use_counts, ProducedPreparseData **produced_preparser_scope_data)
Definition preparser.cc:101
static V8_INLINE bool IsIdentifier(const PreParserExpression &expression)
Definition preparser.h:1234
PreparseDataBuilder * preparse_data_builder_
Definition preparser.h:1628
V8_INLINE const AstRawString * PreParserIdentifierToAstRawString(const PreParserIdentifier &x)
Definition preparser.h:1384
V8_INLINE PreParserIdentifier GetNumberAsSymbol() const
Definition preparser.h:1450
V8_INLINE Variable * DeclareCatchVariableName(Scope *scope, const PreParserIdentifier &identifier)
Definition preparser.h:1517
V8_INLINE TemplateLiteralState OpenTemplateLiteral(int pos)
Definition preparser.h:974
V8_INLINE void AppendConditionalChainElse(PreParserExpression *x, const SourceRange &else_range)
Definition preparser.h:1315
bool AllowsLazyParsingWithoutUnresolvedVariables() const
Definition preparser.h:942
V8_INLINE void ReportUnexpectedTokenAt(Scanner::Location location, Token::Value token, MessageTemplate message=MessageTemplate::kUnexpectedToken)
Definition preparser.h:1061
V8_INLINE void ReportUnidentifiableError()
Definition preparser.h:1389
V8_INLINE void ParseGeneratorFunctionBody(int pos, FunctionKind kind, PreParserScopedStatementList *body)
Definition preparser.h:1066
V8_INLINE bool IsStringLiteral(PreParserStatement statement) const
Definition preparser.h:1279
const AstRawString * GetRawNameFromIdentifier(const PreParserIdentifier &arg)
Definition preparser.h:1394
V8_INLINE PreParserBlock RewriteCatchPattern(CatchInfo *catch_info)
Definition preparser.h:1045
V8_INLINE void SetLanguageMode(Scope *scope, LanguageMode mode)
Definition preparser.h:988
V8_INLINE void InsertSloppyBlockFunctionVarBindings(DeclarationScope *scope)
Definition preparser.h:1372
V8_INLINE PreParserBlock RewriteForVarInLegacy(const ForInfo &for_info)
Definition preparser.h:1335
static V8_INLINE bool IsIterationStatement(PreParserStatement subject)
Definition preparser.h:1426
V8_INLINE PreParserExpression ThisExpression()
Definition preparser.h:1458
static V8_INLINE bool IsNull(T subject)
Definition preparser.h:1422
static V8_INLINE PreParserIdentifier AsIdentifier(const PreParserExpression &expression)
Definition preparser.h:1238
V8_INLINE void DeclareFunctionNameVar(const PreParserIdentifier &function_name, FunctionSyntaxKind function_syntax_kind, DeclarationScope *function_scope)
Definition preparser.h:1084
V8_INLINE void PrepareGeneratorVariables()
Definition preparser.h:993
V8_INLINE void DeclareFormalParameters(const PreParserFormalParameters *parameters)
Definition preparser.h:1582
V8_INLINE bool CollapseNaryExpression(PreParserExpression *x, PreParserExpression y, Token::Value op, int pos, const SourceRange &range)
Definition preparser.h:1318
V8_INLINE PreParserExpression BuildUnaryExpression(const PreParserExpression &expression, Token::Value op, int pos)
Definition preparser.h:1325
PreParserIdentifier GetSymbol() const
Definition preparser.h:1440
PreParserLogger log_
Definition preparser.h:1626
static V8_INLINE bool IsArrayIndex(const PreParserIdentifier &string, uint32_t *index)
Definition preparser.h:1274
void set_preparse_data_builder(PreparseDataBuilder *preparse_data_builder)
Definition preparser.h:916
V8_INLINE void ReindexArrowFunctionFormalParameters(PreParserFormalParameters *parameters)
Definition preparser.h:1578
PreParserIdentifier Identifier
Definition preparser.h:859
V8_INLINE bool SkipFunction(const AstRawString *name, FunctionKind kind, FunctionSyntaxKind function_syntax_kind, DeclarationScope *function_scope, int *num_parameters, int *function_length, ProducedPreparseData **produced_preparse_data)
Definition preparser.h:949
Expression ParseFunctionLiteral(Identifier name, Scanner::Location function_name_location, FunctionNameValidity function_name_validity, FunctionKind kind, int function_token_pos, FunctionSyntaxKind function_syntax_kind, LanguageMode language_mode, ZonePtrList< const AstRawString > *arguments_for_wrapped_function)
Definition preparser.cc:259
V8_INLINE PreParserStatement RewriteTryStatement(PreParserStatement try_block, PreParserStatement catch_block, const SourceRange &catch_range, PreParserStatement finally_block, const SourceRange &finally_range, const CatchInfo &catch_info, int pos)
Definition preparser.h:1054
V8_INLINE void PushEnclosingName(const PreParserIdentifier &name)
Definition preparser.h:1292
void DeclareAndBindVariable(const VariableProxy *proxy, VariableKind kind, VariableMode mode, Scope *scope, bool *was_added, int initializer_position)
Definition preparser.h:1006
static V8_INLINE void InferFunctionName()
Definition preparser.h:1295
V8_INLINE bool IsConstructor(const PreParserIdentifier &identifier) const
Definition preparser.h:1248
V8_INLINE void DeclarePublicClassField(ClassScope *scope, const PreParserExpression &property, bool is_static, bool is_computed_name, ClassInfo *class_info)
Definition preparser.h:1143
std::vector< void * > preparse_data_builder_buffer_
Definition preparser.h:1629
V8_INLINE void DeclareClassVariable(ClassScope *scope, const PreParserIdentifier &name, ClassInfo *class_info, int class_token_pos)
Definition preparser.h:1125
V8_INLINE PreParserStatement DeclareClass(const PreParserIdentifier &variable_name, const PreParserExpression &value, ZonePtrList< const AstRawString > *names, int class_token_pos, int end_pos)
Definition preparser.h:1114
V8_INLINE PreParserExpression NewThisExpression(int pos)
Definition preparser.h:1463
V8_INLINE PreParserExpression ExpressionFromPrivateName(PrivateNameScopeIterator *private_name_scope, const PreParserIdentifier &name, int start_position)
Definition preparser.h:1496
V8_INLINE PreParserStatement DeclareFunction(const PreParserIdentifier &variable_name, const PreParserExpression &function, VariableMode mode, VariableKind kind, int beg_pos, int end_pos, ZonePtrList< const AstRawString > *names)
Definition preparser.h:1095
V8_INLINE PreParserStatement BuildInitializationBlock(DeclarationParsingResult *parsing_result)
Definition preparser.h:1331
V8_INLINE PreParserExpression ExpressionListToExpression(const PreParserExpressionList &args)
Definition preparser.h:1593
static V8_INLINE void GetDefaultStrings(PreParserIdentifier *default_string, PreParserIdentifier *dot_default_string)
Definition preparser.h:1283
static V8_INLINE PreParserExpression NullExpression()
Definition preparser.h:1404
static V8_INLINE void AddFunctionForNameInference(const PreParserExpression &expression)
Definition preparser.h:1293
V8_INLINE PreParserExpression NewV8Intrinsic(const PreParserIdentifier &name, const PreParserExpressionList &arguments, int pos)
Definition preparser.h:1558
V8_INLINE void SetFunctionNameFromIdentifierRef(const PreParserExpression &value, const PreParserExpression &identifier)
Definition preparser.h:1600
V8_INLINE bool IsEvalOrArguments(const PreParserIdentifier &identifier) const
Definition preparser.h:1224
V8_INLINE PreParserExpression ImportMetaExpression(int pos)
Definition preparser.h:1486
V8_INLINE StatementT DesugarLexicalBindingsInForStatement(PreParserStatement loop, PreParserStatement init, const PreParserExpression &cond, PreParserStatement next, PreParserStatement body, Scope *inner_scope, const ForInfo &for_info)
Definition preparser.h:1356
V8_INLINE PreParserExpression NewSuperPropertyReference(int pos)
Definition preparser.h:1468
static V8_INLINE bool IsBoilerplateProperty(const PreParserExpression &property)
Definition preparser.h:1252
V8_INLINE PreParserIdentifier GetBigIntAsSymbol() const
Definition preparser.h:1454
PreParserExpression ExpressionFromIdentifier(const PreParserIdentifier &name, int start_position, InferName infer=InferName::kYes)
Definition preparser.h:1505
V8_INLINE PreParserExpression ExpressionFromLiteral(Token::Value token, int pos)
Definition preparser.h:1490
V8_INLINE PreParserBlock CreateForEachStatementTDZ(PreParserBlock init_block, const ForInfo &for_info)
Definition preparser.h:1344
V8_INLINE bool ParsingExtension() const
Definition preparser.h:1258
V8_INLINE bool IsEval(const PreParserIdentifier &identifier) const
Definition preparser.h:1212
void ParseStatementListAndLogFunction(PreParserFormalParameters *formals)
Definition preparser.cc:359
PendingCompilationErrorHandler * pending_error_handler()
Definition preparser.h:945
void AddUnresolvedPrivateName(VariableProxy *proxy)
Definition scopes.cc:3234
V8_INLINE void set_parser_error()
Definition scanner.h:246
void SetLanguageMode(LanguageMode language_mode)
Definition scopes.h:288
void set_end_position(int statement_pos)
Definition scopes.h:343
base::ThreadedList< Declaration > * declarations()
Definition scopes.h:229
VariableProxy * NewUnresolved(AstNodeFactory *factory, const AstRawString *name, int start_pos, VariableKind kind=NORMAL_VARIABLE)
Definition scopes.h:234
Variable * DeclareCatchVariableName(const AstRawString *name)
Definition scopes.cc:1213
Variable * DeclareVariableName(const AstRawString *name, VariableMode mode, bool *was_added, VariableKind kind=NORMAL_VARIABLE)
Definition scopes.cc:1177
void set_start_position(int statement_pos)
Definition scopes.h:339
DeclarationScope * GetDeclarationScope()
Definition scopes.cc:1456
Variable * LookupLocal(const AstRawString *name)
Definition scopes.h:200
const AstRawString * raw_name() const
Definition ast.h:1513
void set_initializer_position(int pos)
Definition variables.h:122
Scope * scope() const
Definition variables.h:58
const ObjectRef type_
int start
int end
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
Label label
std::string pattern
ZoneVector< RpoNumber > & result
int x
FunctionLiteral * literal
Definition liveedit.cc:294
int position
Definition liveedit.cc:290
int s
Definition mul-fft.cc:297
constexpr bool IsInRange(T value, U lower_limit, U higher_limit)
Definition bounds.h:20
constexpr int kNoSourcePosition
Definition globals.h:850
bool IsLexicalVariableMode(VariableMode mode)
Definition globals.h:2155
@ SLOPPY_BLOCK_FUNCTION_VARIABLE
Definition globals.h:2112
SharedFunctionInfo::HasStaticPrivateMethodsOrAccessorsBit SharedFunctionInfo::MaglevCompilationFailedBit SharedFunctionInfo::FunctionSyntaxKindBits has_duplicate_parameters
bool IsPrivateMethodOrAccessorVariableMode(VariableMode mode)
Definition globals.h:2135
bool IsImmutableLexicalOrPrivateVariableMode(VariableMode mode)
Definition globals.h:2150
ModuleImportPhase
#define DEFINE_RECORD_SOURCE_RANGE(Name)
Definition preparser.h:1617
#define DCHECK_NULL(val)
Definition logging.h:491
#define DCHECK_IMPLIES(v1, v2)
Definition logging.h:493
#define DCHECK_NE(v1, v2)
Definition logging.h:486
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_EQ(v1, v2)
Definition logging.h:485
#define V8_EXPORT_PRIVATE
Definition macros.h:460
void UpdateArityAndFunctionLength(bool is_optional, bool is_rest)
Definition parser-base.h:69
Symbol identifier
Symbol * expression
Symbol statement
#define V8_INLINE
Definition v8config.h:500