5 #ifndef V8_PARSING_PREPARSER_H_ 6 #define V8_PARSING_PREPARSER_H_ 8 #include "src/ast/ast.h" 9 #include "src/ast/scopes.h" 10 #include "src/parsing/parser-base.h" 11 #include "src/parsing/preparser-logger.h" 12 #include "src/pending-compilation-error-handler.h" 25 class PreParsedScopeDataBuilder;
57 bool IsNull()
const {
return type_ == kNullIdentifier; }
58 bool IsEval()
const {
return type_ == kEvalIdentifier; }
59 bool IsAsync()
const {
return type_ == kAsyncIdentifier; }
60 bool IsArguments()
const {
return type_ == kArgumentsIdentifier; }
61 bool IsEvalOrArguments()
const {
62 STATIC_ASSERT(kEvalIdentifier + 1 == kArgumentsIdentifier);
63 return IsInRange(type_, kEvalIdentifier, kArgumentsIdentifier);
65 bool IsConstructor()
const {
return type_ == kConstructorIdentifier; }
66 bool IsAwait()
const {
return type_ == kAwaitIdentifier; }
67 bool IsName()
const {
return type_ == kNameIdentifier; }
68 bool IsPrivateName()
const {
return type_ == kPrivateNameIdentifier; }
76 kConstructorIdentifier,
80 kPrivateNameIdentifier
98 : code_(TypeField::encode(kNull)), variables_(
nullptr) {}
112 expression.variables_);
119 IdentifierTypeField::encode(
id.type_));
120 expression.AddVariable(variable, zone);
134 ExpressionTypeField::encode(kAssignment),
139 return PreParserExpression::Default();
160 ExpressionTypeField::encode(kThisExpression));
165 ExpressionTypeField::encode(
166 kThisPropertyExpressionWithPrivateFieldKey));
171 TypeField::encode(kExpression) |
172 ExpressionTypeField::encode(kThisPropertyExpression));
177 TypeField::encode(kExpression) |
178 ExpressionTypeField::encode(kPropertyExpression));
183 TypeField::encode(kExpression) |
184 ExpressionTypeField::encode(kPropertyExpressionWithPrivateFieldKey));
189 ExpressionTypeField::encode(kCallExpression));
194 TypeField::encode(kExpression) |
195 ExpressionTypeField::encode(kCallEvalExpression));
200 TypeField::encode(kExpression) |
201 ExpressionTypeField::encode(kCallTaggedTemplateExpression));
204 bool is_tagged_template()
const {
206 return ExpressionTypeField::decode(code_) == kCallTaggedTemplateExpression;
211 TypeField::encode(kExpression) |
212 ExpressionTypeField::encode(kSuperCallReference));
215 bool IsNull()
const {
return TypeField::decode(code_) == kNull; }
216 bool IsFailureExpression()
const {
217 return TypeField::decode(code_) == kFailure;
220 bool IsIdentifier()
const {
221 return TypeField::decode(code_) == kIdentifierExpression;
225 DCHECK(IsIdentifier());
229 bool IsAssignment()
const {
230 return TypeField::decode(code_) == kExpression &&
231 ExpressionTypeField::decode(code_) == kAssignment;
234 bool IsObjectLiteral()
const {
235 return TypeField::decode(code_) == kObjectLiteralExpression;
238 bool IsArrayLiteral()
const {
239 return TypeField::decode(code_) == kArrayLiteralExpression;
242 bool IsPattern()
const {
243 STATIC_ASSERT(kObjectLiteralExpression + 1 == kArrayLiteralExpression);
244 return IsInRange(TypeField::decode(code_), kObjectLiteralExpression,
245 kArrayLiteralExpression);
248 bool IsStringLiteral()
const {
249 return TypeField::decode(code_) == kStringLiteralExpression;
252 bool IsThis()
const {
253 return TypeField::decode(code_) == kExpression &&
254 ExpressionTypeField::decode(code_) == kThisExpression;
257 bool IsThisProperty()
const {
258 return TypeField::decode(code_) == kExpression &&
259 (ExpressionTypeField::decode(code_) == kThisPropertyExpression ||
260 ExpressionTypeField::decode(code_) ==
261 kThisPropertyExpressionWithPrivateFieldKey);
264 bool IsProperty()
const {
265 return TypeField::decode(code_) == kExpression &&
266 (ExpressionTypeField::decode(code_) == kPropertyExpression ||
267 ExpressionTypeField::decode(code_) == kThisPropertyExpression ||
268 ExpressionTypeField::decode(code_) ==
269 kPropertyExpressionWithPrivateFieldKey ||
270 ExpressionTypeField::decode(code_) ==
271 kThisPropertyExpressionWithPrivateFieldKey);
274 bool IsPropertyWithPrivateFieldKey()
const {
275 return TypeField::decode(code_) == kExpression &&
276 (ExpressionTypeField::decode(code_) ==
277 kPropertyExpressionWithPrivateFieldKey ||
278 ExpressionTypeField::decode(code_) ==
279 kThisPropertyExpressionWithPrivateFieldKey);
282 bool IsCall()
const {
283 return TypeField::decode(code_) == kExpression &&
284 (ExpressionTypeField::decode(code_) == kCallExpression ||
285 ExpressionTypeField::decode(code_) == kCallEvalExpression ||
286 ExpressionTypeField::decode(code_) ==
287 kCallTaggedTemplateExpression);
290 if (IsCall())
return this;
294 bool IsSuperCallReference()
const {
295 return TypeField::decode(code_) == kExpression &&
296 ExpressionTypeField::decode(code_) == kSuperCallReference;
299 bool IsValidReferenceExpression()
const {
300 return IsIdentifier() || IsProperty();
304 bool IsFunctionLiteral()
const {
return false; }
305 bool IsCallNew()
const {
return false; }
307 bool IsSpread()
const {
308 return TypeField::decode(code_) == kSpreadExpression;
311 bool is_parenthesized()
const {
return IsParenthesizedField::decode(code_); }
313 void mark_parenthesized() {
314 code_ = IsParenthesizedField::update(code_,
true);
323 void set_is_private_name() {
324 if (variables_ !=
nullptr) {
325 DCHECK(IsIdentifier());
326 DCHECK(AsIdentifier().IsPrivateName());
327 DCHECK_EQ(1, variables_->LengthForTest());
328 variables_->first()->set_is_private_name();
333 void SetShouldEagerCompile() {}
334 void mark_as_iife() {}
336 int position()
const {
return kNoSourcePosition; }
337 void set_function_token_position(
int position) {}
338 void set_scope(
Scope* scope) {}
339 void set_suspend_count(
int suspend_count) {}
346 kIdentifierExpression,
347 kStringLiteralExpression,
349 kObjectLiteralExpression,
350 kArrayLiteralExpression
353 enum ExpressionType {
355 kThisPropertyExpression,
356 kThisPropertyExpressionWithPrivateFieldKey,
358 kPropertyExpressionWithPrivateFieldKey,
361 kCallTaggedTemplateExpression,
369 : code_(expression_code), variables_(variables) {}
372 if (variable ==
nullptr) {
375 if (variables_ ==
nullptr) {
378 variables_->Add(variable);
417 bool IsNull()
const {
return is_null_; }
440 : length_(0), variables_(
nullptr) {}
442 int length()
const {
return length_; }
445 if (expression.variables_ !=
nullptr) {
446 if (variables_ ==
nullptr) {
447 variables_ = expression.variables_;
449 variables_->Append(std::move(*expression.variables_));
489 if (expression.IsStringLiteral()) {
495 bool IsStringLiteral() {
return code_ == kStringLiteralExpressionStatement; }
497 bool IsJumpStatement() {
498 return code_ == kJumpStatement;
501 bool IsNull() {
return code_ == kNullStatement; }
503 bool IsEmptyStatement() {
505 return code_ == kEmptyStatement;
515 void set_scope(
Scope* scope) {}
528 kStringLiteralExpressionStatement,
539 : ast_node_factory_(ast_value_factory, zone), zone_(zone) {}
548 if (identifier.string_ !=
nullptr) {
549 VariableProxy* variable = ast_node_factory_.NewVariableProxy(
550 identifier.string_, NORMAL_VARIABLE);
551 expression.AddVariable(variable, zone_);
557 return PreParserExpression::Default();
560 return PreParserExpression::Default();
563 return PreParserExpression::Default();
566 int js_flags,
int pos) {
567 return PreParserExpression::Default();
570 int first_spread_index,
int pos) {
571 return PreParserExpression::ArrayLiteral(values.variables_);
575 ClassLiteralProperty::Kind kind,
577 bool is_computed_name,
579 return PreParserExpression::Default();
583 ObjectLiteralProperty::Kind kind,
584 bool is_computed_name) {
585 return PreParserExpression::Default(value.variables_);
589 bool is_computed_name) {
590 return PreParserExpression::Default(value.variables_);
594 int pos,
bool has_rest_property) {
595 return PreParserExpression::ObjectLiteral(properties.variables_);
598 return PreParserExpression::Default();
603 if (key.IsIdentifier() && key.AsIdentifier().IsPrivateName()) {
605 return PreParserExpression::ThisPropertyWithPrivateFieldKey();
607 return PreParserExpression::PropertyWithPrivateFieldKey();
611 return PreParserExpression::ThisProperty();
613 return PreParserExpression::Property();
618 return PreParserExpression::Default();
624 return PreParserExpression::BinaryOperation(left, op, right, zone_);
630 return PreParserExpression::Default();
641 return PreParserExpression::Assignment(left.variables_);
644 Suspend::OnAbruptResume on_abrupt_resume) {
645 return PreParserExpression::Default();
648 return PreParserExpression::Default();
652 return PreParserExpression::Default();
658 return PreParserExpression::Default();
663 return PreParserExpression::Default();
667 int pos, Call::PossiblyEval possibly_eval = Call::NOT_EVAL) {
668 if (possibly_eval == Call::IS_POSSIBLY_EVAL) {
669 DCHECK(expression.IsIdentifier() && expression.AsIdentifier().IsEval());
670 return PreParserExpression::CallEval();
672 return PreParserExpression::Call();
677 return PreParserExpression::CallTaggedTemplate();
682 return PreParserExpression::Default();
686 int continuation_pos = kNoSourcePosition) {
687 return PreParserStatement::Jump();
691 int continuation_pos = kNoSourcePosition) {
692 return PreParserStatement::Jump();
697 int parameter_count,
int function_length,
698 FunctionLiteral::ParameterFlag has_duplicate_parameters,
699 FunctionLiteral::FunctionType function_type,
700 FunctionLiteral::EagerCompileHint eager_compile_hint,
int position,
701 bool has_braces,
int function_literal_id,
703 DCHECK_NULL(produced_preparsed_scope_data);
704 return PreParserExpression::Default();
709 return PreParserExpression::Spread(expression);
714 result.mark_parenthesized();
721 return PreParserStatement::Default();
726 return PreParserStatement::Default();
731 return PreParserStatement::Default();
735 return PreParserStatement::Default();
740 return PreParserStatement::ExpressionStatement(expr);
749 return else_statement.IsJumpStatement() ? then_statement : else_statement;
754 int continuation_pos = kNoSourcePosition) {
755 return PreParserStatement::Jump();
760 int continuation_pos = kNoSourcePosition) {
761 return PreParserStatement::Jump();
767 return PreParserStatement::Default();
773 return PreParserStatement::Default();
779 return PreParserStatement::Default();
785 return PreParserStatement::Default();
791 return PreParserStatement::Default();
797 return PreParserStatement::Default();
801 ForEachStatement::VisitMode visit_mode,
804 return PreParserStatement::Default();
810 return PreParserStatement::Default();
816 return PreParserExpression::Default();
821 return PreParserExpression::Default();
836 bool has_duplicate()
const {
return has_duplicate_; }
837 void set_has_duplicate() { has_duplicate_ =
true; }
840 bool has_duplicate_ =
false;
859 void RemoveAsyncKeywordFromEnd()
const {}
860 void Infer()
const {}
861 void RemoveLastFunction()
const {}
868 DISALLOW_COPY_AND_ASSIGN(
State);
934 static constexpr
bool ExpressionClassifierReportErrors =
false;
959 enum PreParseResult {
960 kPreParseStackOverflow,
962 kPreParseNotIdentifiableError,
970 int script_id = -1,
bool parsing_module =
false,
971 bool parsing_on_main_thread =
true)
973 ast_value_factory, pending_error_handler,
974 runtime_call_stats, logger, script_id,
975 parsing_module, parsing_on_main_thread),
976 use_counts_(
nullptr),
977 preparsed_scope_data_builder_(
nullptr) {}
979 static bool IsPreParser() {
return true; }
987 PreParseResult PreParseProgram();
997 PreParseResult PreParseFunction(
999 FunctionLiteral::FunctionType function_type,
1005 return preparsed_scope_data_builder_;
1008 void set_preparsed_scope_data_builder(
1010 preparsed_scope_data_builder_ = preparsed_scope_data_builder;
1026 bool AllowsLazyParsingWithoutUnresolvedVariables()
const {
return false; }
1027 bool parse_lazily()
const {
return false; }
1030 return pending_error_handler_;
1033 V8_INLINE
bool SkipFunction(
1035 FunctionLiteral::FunctionType function_type,
1038 bool may_abort, FunctionLiteral::EagerCompileHint* hint) {
1044 FunctionNameValidity function_name_validity, FunctionKind kind,
1045 int function_token_pos, FunctionLiteral::FunctionType function_type,
1046 LanguageMode language_mode,
1053 LazyParsingResult ParseStatementListAndLogFunction(
1056 struct TemplateLiteralState {};
1058 V8_INLINE TemplateLiteralState OpenTemplateLiteral(
int pos) {
1059 return TemplateLiteralState();
1061 V8_INLINE
void AddTemplateExpression(TemplateLiteralState* state,
1063 V8_INLINE
void AddTemplateSpan(TemplateLiteralState* state,
bool should_cook,
1067 return PreParserExpression::Default();
1069 V8_INLINE
bool IsPropertyWithPrivateFieldKey(
1071 return expression.IsPropertyWithPrivateFieldKey();
1073 V8_INLINE
void CheckConflictingVarDeclarations(
Scope* scope) {}
1075 V8_INLINE
void SetLanguageMode(
Scope* scope, LanguageMode mode) {
1076 scope->SetLanguageMode(mode);
1078 V8_INLINE
void SetAsmModule() {}
1083 Call::PossiblyEval possibly_eval);
1088 V8_INLINE
void RewriteDestructuringAssignments() {}
1090 V8_INLINE
void PrepareGeneratorVariables() {}
1091 V8_INLINE
void RewriteAsyncFunctionBody(
1095 void DeclareAndInitializeVariables(
1097 const DeclarationDescriptor* declaration_descriptor,
1098 const DeclarationParsingResult::Declaration* declaration,
1104 DCHECK(!parsing_module_ || !expr.AsIdentifier().IsAwait());
1105 DCHECK(IsIdentifier(expr));
1116 return return_value;
1120 return PreParserStatement::Default();
1123 V8_INLINE
void RewriteCatchPattern(CatchInfo* catch_info) {
1124 const AstRawString* catch_name = catch_info->name.string_;
1125 if (catch_name ==
nullptr) {
1126 catch_name = ast_value_factory()->dot_catch_string();
1128 catch_info->scope->DeclareCatchVariableName(catch_name);
1130 if (catch_info->pattern.variables_ !=
nullptr) {
1131 for (
auto variable : *catch_info->pattern.variables_) {
1132 scope()->DeclareVariableName(variable->raw_name(), VariableMode::kLet);
1137 V8_INLINE
void ValidateCatchBlock(
const CatchInfo& catch_info) {}
1141 const SourceRange& finally_range,
const CatchInfo& catch_info,
int pos) {
1142 return PreParserStatement::Default();
1145 V8_INLINE
void GetUnexpectedTokenMessage(Token::Value token,
1146 MessageTemplate* message,
1148 const char** arg) {}
1149 V8_INLINE
void ParseAndRewriteGeneratorFunctionBody(
1151 ParseStatementList(body, Token::RBRACE);
1153 V8_INLINE
void ParseAndRewriteAsyncGeneratorFunctionBody(
1155 ParseStatementList(body, Token::RBRACE);
1157 V8_INLINE
void DeclareFunctionNameVar(
1159 FunctionLiteral::FunctionType function_type,
1161 if (function_type == FunctionLiteral::kNamedExpression &&
1162 function_scope->LookupLocal(function_name) ==
nullptr) {
1163 DCHECK_EQ(function_scope, scope());
1164 function_scope->DeclareFunctionVar(function_name);
1168 V8_INLINE
void DeclareFunctionNameVar(
1170 FunctionLiteral::FunctionType function_type,
1172 DeclareFunctionNameVar(function_name.string_, function_type,
1183 return PreParserStatement::Default();
1187 return PreParserStatement::Default();
1195 if (variable_name.string_ !=
nullptr) {
1196 scope()->DeclareVariableName(variable_name.string_, mode);
1197 if (is_sloppy_block_function) {
1198 GetDeclarationScope()->DeclareSloppyBlockFunction(variable_name.string_,
1202 return Statement::Default();
1208 int class_token_pos,
int end_pos) {
1211 if (variable_name.string_ !=
nullptr) {
1212 scope()->DeclareVariableName(variable_name.string_, VariableMode::kLet);
1214 return PreParserStatement::Default();
1217 ClassInfo* class_info,
1218 int class_token_pos) {
1219 if (name.string_ !=
nullptr) {
1220 scope()->DeclareVariableName(name.string_, VariableMode::kConst);
1226 ClassLiteralProperty::Kind kind,
1227 bool is_static,
bool is_constructor,
1228 bool is_computed_name,
bool is_private,
1229 ClassInfo* class_info) {
1230 if (kind == ClassLiteralProperty::FIELD && !is_private &&
1232 scope()->DeclareVariableName(
1233 ClassFieldVariableName(ast_value_factory(),
1234 class_info->computed_field_count),
1235 VariableMode::kConst);
1238 if (kind == ClassLiteralProperty::FIELD && is_private &&
1239 property_name.string_ !=
nullptr) {
1240 scope()->DeclareVariableName(property_name.string_, VariableMode::kConst);
1246 ClassInfo* class_info,
int pos,
int end_pos) {
1247 bool has_default_constructor = !class_info->has_seen_constructor;
1249 if (has_default_constructor) {
1255 bool has_extends = class_info->extends.IsNull();
1256 FunctionKind kind = has_extends ? FunctionKind::kDefaultDerivedConstructor
1257 : FunctionKind::kDefaultBaseConstructor;
1259 SetLanguageMode(function_scope, LanguageMode::kStrict);
1260 function_scope->set_start_position(pos);
1261 function_scope->set_end_position(pos);
1262 FunctionState function_state(&function_state_, &scope_, function_scope);
1263 GetNextFunctionLiteralId();
1265 if (class_info->has_static_class_fields) {
1266 GetNextFunctionLiteralId();
1268 if (class_info->has_instance_members) {
1269 GetNextFunctionLiteralId();
1271 return PreParserExpression::Default();
1276 return PreParserStatement::Default();
1279 V8_INLINE
void QueueDestructuringAssignmentForRewriting(
1284 return identifier.IsEval();
1288 return identifier.IsAsync();
1292 return identifier.IsArguments();
1295 V8_INLINE
bool IsEvalOrArguments(
1297 return identifier.IsEvalOrArguments();
1301 return identifier.IsAwait();
1306 return expression.IsThisProperty();
1310 return expression.IsIdentifier();
1315 return expression.AsIdentifier();
1324 return identifier.IsConstructor();
1328 return identifier.IsName();
1331 V8_INLINE
static bool IsBoilerplateProperty(
1351 return statement.IsStringLiteral();
1354 V8_INLINE
static void GetDefaultStrings(
1364 V8_INLINE
static void AddFunctionForNameInference(
1366 V8_INLINE
static void InferFunctionName() {}
1368 V8_INLINE
static void CheckAssigningFunctionLiteralToProperty(
1374 if (expression.variables_ !=
nullptr) {
1375 for (
auto variable : *expression.variables_) {
1376 variable->set_is_assigned();
1381 V8_INLINE
void MarkExpressionAsAssigned(
1383 if (IsIdentifier(expression)) {
1384 DCHECK_NOT_NULL(expression.variables_);
1385 DCHECK_EQ(1, expression.variables_->LengthForTest());
1386 expression.variables_->first()->set_is_assigned();
1390 V8_INLINE
bool ShortcutNumericLiteralBinaryExpression(
1398 Token::Value op,
int pos,
1405 return PreParserExpression::Default();
1409 BuildInitializationBlock(DeclarationParsingResult* parsing_result,
1411 for (
auto declaration : parsing_result->declarations) {
1412 DeclareAndInitializeVariables(PreParserStatement::Default(),
1413 &(parsing_result->descriptor), &declaration,
1416 return PreParserStatement::Default();
1422 MarkPatternAsAssigned(each);
1429 bool finalize, IteratorType
type,
1430 int next_result_pos = kNoSourcePosition) {
1431 MarkPatternAsAssigned(each);
1436 return PreParserStatement::Null();
1439 V8_INLINE
void DesugarBindingInForEachStatement(
1442 DCHECK_EQ(1, for_info->parsing_result.declarations.size());
1443 bool is_for_var_of =
1444 for_info->mode == ForEachStatement::ITERATE &&
1445 for_info->parsing_result.descriptor.mode == VariableMode::kVar;
1446 bool collect_names =
1447 IsLexicalVariableMode(for_info->parsing_result.descriptor.mode) ||
1450 DeclareAndInitializeVariables(
1451 PreParserStatement::Default(), &for_info->parsing_result.descriptor,
1452 &for_info->parsing_result.declarations[0],
1453 collect_names ? &for_info->bound_names :
nullptr);
1458 if (IsLexicalVariableMode(for_info.parsing_result.descriptor.mode)) {
1459 for (
auto name : for_info.bound_names) {
1460 scope()->DeclareVariableName(name, VariableMode::kLet);
1462 return PreParserStatement::Default();
1467 V8_INLINE
StatementT DesugarLexicalBindingsInForStatement(
1472 for (
auto name : for_info.bound_names) {
1473 inner_scope->DeclareVariableName(name,
1474 for_info.parsing_result.descriptor.mode);
1484 return PreParserStatement::Default();
1487 V8_INLINE
void InsertSloppyBlockFunctionVarBindings(
DeclarationScope* scope) {
1488 scope->HoistSloppyBlockFunctions(
nullptr);
1491 V8_INLINE
void InsertShadowingVarBindingInitializers(
1496 return PreParserExpression::Default();
1501 return PreParserExpression::Default();
1506 return PreParserExpression::Default();
1511 MessageTemplate message,
const char* arg =
nullptr,
1512 ParseErrorType error_type = kSyntaxError) {
1513 pending_error_handler()->ReportMessageAt(source_location.beg_pos,
1514 source_location.end_pos, message,
1516 scanner()->set_parser_error();
1519 V8_INLINE
void ReportUnidentifiableError() {
1520 pending_error_handler()->set_unidentifiable_error();
1521 scanner()->set_parser_error();
1525 MessageTemplate message,
1527 ParseErrorType error_type = kSyntaxError) {
1533 return PreParserIdentifier::Null();
1536 return PreParserExpression::Null();
1539 return PreParserExpression::Failure();
1542 return PreParserExpression::Null();
1545 return PreParserStatementList::Null();
1548 return PreParserStatement::Null();
1551 template <
typename T>
1552 V8_INLINE
static bool IsNull(
T subject) {
1553 return subject.IsNull();
1557 return PreParserIdentifier::Default();
1564 return PreParserIdentifier::Default();
1568 return PreParserIdentifier::Default();
1572 scope()->NewUnresolved(factory()->ast_node_factory(),
1573 ast_value_factory()->this_string(), pos,
1575 return PreParserExpression::This();
1579 scope()->NewUnresolved(factory()->ast_node_factory(),
1580 ast_value_factory()->this_function_string(), pos,
1582 scope()->NewUnresolved(factory()->ast_node_factory(),
1583 ast_value_factory()->this_string(), pos,
1585 return PreParserExpression::Default();
1589 scope()->NewUnresolved(factory()->ast_node_factory(),
1590 ast_value_factory()->this_function_string(), pos,
1592 scope()->NewUnresolved(factory()->ast_node_factory(),
1593 ast_value_factory()->new_target_string(), pos,
1595 scope()->NewUnresolved(factory()->ast_node_factory(),
1596 ast_value_factory()->this_string(), pos,
1598 return PreParserExpression::SuperCallReference();
1602 return PreParserExpression::NewTargetExpression();
1606 return PreParserExpression::Default();
1611 if (token != Token::STRING)
return PreParserExpression::Default();
1612 return PreParserExpression::StringLiteral();
1617 InferName infer = InferName::kYes);
1630 return PreParserExpression::Default();
1635 return PreParserStatement::Jump();
1641 int initializer_end_position,
1644 if (pattern.variables_ ==
nullptr) {
1645 scope->DeclareParameterName(ast_value_factory()->empty_string(), is_rest,
1646 ast_value_factory(),
false,
true);
1650 auto it = pattern.variables_->begin();
1651 if (!parameters->has_duplicate() &&
1652 scope->LookupLocal(it->raw_name()) !=
nullptr) {
1653 parameters->set_has_duplicate();
1655 scope->DeclareParameterName(it->raw_name(), is_rest, ast_value_factory(),
1657 for (++it; it != pattern.variables_->end(); ++it) {
1658 if (!parameters->has_duplicate() &&
1659 scope->LookupLocal(it->raw_name()) !=
nullptr) {
1660 parameters->set_has_duplicate();
1662 scope->DeclareParameterName(it->raw_name(), is_rest,
1663 ast_value_factory(),
true,
false);
1666 parameters->UpdateArityAndFunctionLength(!initializer.IsNull(), is_rest);
1669 V8_INLINE
void DeclareFormalParameters(
1671 ValidateFormalParameterInitializer();
1672 if (!parameters->is_simple) parameters->scope->SetHasNonSimpleParameters();
1675 V8_INLINE
void DeclareArrowFunctionFormalParameters(
1678 ValidateFormalParameterInitializer();
1679 if (params.variables_ !=
nullptr) {
1680 Scope* scope = parameters->scope;
1681 for (
auto variable : *params.variables_) {
1682 if (!parameters->has_duplicate() &&
1683 scope->LookupLocal(variable->raw_name())) {
1684 parameters->set_has_duplicate();
1686 scope->DeclareVariableName(variable->raw_name(), VariableMode::kVar);
1693 return PreParserExpression::Default(args.variables_);
1696 V8_INLINE
void SetFunctionNameFromPropertyName(
1699 V8_INLINE
void SetFunctionNameFromIdentifierRef(
1704 GetReportedErrorList()
const {
1705 return function_state_->GetReportedErrorList();
1708 V8_INLINE
void CountUsage(v8::Isolate::UseCounterFeature feature) {
1709 if (use_counts_ !=
nullptr) ++use_counts_[feature];
1712 V8_INLINE
bool ParsingDynamicFunctionDeclaration()
const {
return false; }
1716 #define DEFINE_RECORD_SOURCE_RANGE(Name) \ 1717 template <typename... Ts> \ 1718 V8_INLINE void Record##Name##SourceRange(Ts... args) {} 1719 AST_SOURCE_RANGE_LIST(DEFINE_RECORD_SOURCE_RANGE)
1720 #undef DEFINE_RECORD_SOURCE_RANGE 1733 Call::PossiblyEval possibly_eval) {
1734 return factory()->NewCall(
function, args, pos, possibly_eval);
1737 PreParserExpression PreParser::SpreadCallNew(
1738 const PreParserExpression&
function,
const PreParserExpressionList& args,
1740 return factory()->NewCallNew(
function, args, pos);
1746 #endif // V8_PARSING_PREPARSER_H_