| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/ast/ast-expression-rewriter.h" | 10 #include "src/ast/ast-expression-rewriter.h" |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 ExpressionClassifier formals_classifier(this); | 873 ExpressionClassifier formals_classifier(this); |
| 874 ParserFormalParameters formals(scope); | 874 ParserFormalParameters formals(scope); |
| 875 Checkpoint checkpoint(this); | 875 Checkpoint checkpoint(this); |
| 876 { | 876 { |
| 877 // Parsing patterns as variable reference expression creates | 877 // Parsing patterns as variable reference expression creates |
| 878 // NewUnresolved references in current scope. Entrer arrow function | 878 // NewUnresolved references in current scope. Entrer arrow function |
| 879 // scope for formal parameter parsing. | 879 // scope for formal parameter parsing. |
| 880 BlockState block_state(&scope_state_, scope); | 880 BlockState block_state(&scope_state_, scope); |
| 881 if (Check(Token::LPAREN)) { | 881 if (Check(Token::LPAREN)) { |
| 882 // '(' StrictFormalParameters ')' | 882 // '(' StrictFormalParameters ')' |
| 883 ParseFormalParameterList(&formals, &formals_classifier, &ok); | 883 ParseFormalParameterList(&formals, &ok); |
| 884 if (ok) ok = Check(Token::RPAREN); | 884 if (ok) ok = Check(Token::RPAREN); |
| 885 } else { | 885 } else { |
| 886 // BindingIdentifier | 886 // BindingIdentifier |
| 887 ParseFormalParameter(&formals, &formals_classifier, &ok); | 887 ParseFormalParameter(&formals, &ok); |
| 888 if (ok) { | 888 if (ok) DeclareFormalParameter(formals.scope, formals.at(0)); |
| 889 DeclareFormalParameter(formals.scope, formals.at(0), | |
| 890 &formals_classifier); | |
| 891 } | |
| 892 } | 889 } |
| 893 } | 890 } |
| 894 | 891 |
| 895 if (ok) { | 892 if (ok) { |
| 896 checkpoint.Restore(&formals.materialized_literals_count); | 893 checkpoint.Restore(&formals.materialized_literals_count); |
| 897 // Pass `accept_IN=true` to ParseArrowFunctionLiteral --- This should | 894 // Pass `accept_IN=true` to ParseArrowFunctionLiteral --- This should |
| 898 // not be observable, or else the preparser would have failed. | 895 // not be observable, or else the preparser would have failed. |
| 899 Expression* expression = ParseArrowFunctionLiteral( | 896 Expression* expression = |
| 900 true, formals, is_async, formals_classifier, &ok); | 897 ParseArrowFunctionLiteral(true, formals, is_async, &ok); |
| 901 if (ok) { | 898 if (ok) { |
| 902 // Scanning must end at the same position that was recorded | 899 // Scanning must end at the same position that was recorded |
| 903 // previously. If not, parsing has been interrupted due to a stack | 900 // previously. If not, parsing has been interrupted due to a stack |
| 904 // overflow, at which point the partially parsed arrow function | 901 // overflow, at which point the partially parsed arrow function |
| 905 // concise body happens to be a valid expression. This is a problem | 902 // concise body happens to be a valid expression. This is a problem |
| 906 // only for arrow functions with single expression bodies, since there | 903 // only for arrow functions with single expression bodies, since there |
| 907 // is no end token such as "}" for normal functions. | 904 // is no end token such as "}" for normal functions. |
| 908 if (scanner()->location().end_pos == info->end_position()) { | 905 if (scanner()->location().end_pos == info->end_position()) { |
| 909 // The pre-parser saw an arrow function here, so the full parser | 906 // The pre-parser saw an arrow function here, so the full parser |
| 910 // must produce a FunctionLiteral. | 907 // must produce a FunctionLiteral. |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 !scanner()->HasAnyLineTerminatorAfterNext()) { | 1334 !scanner()->HasAnyLineTerminatorAfterNext()) { |
| 1338 Consume(Token::ASYNC); | 1335 Consume(Token::ASYNC); |
| 1339 result = ParseAsyncFunctionDeclaration(&local_names, true, CHECK_OK); | 1336 result = ParseAsyncFunctionDeclaration(&local_names, true, CHECK_OK); |
| 1340 break; | 1337 break; |
| 1341 } | 1338 } |
| 1342 /* falls through */ | 1339 /* falls through */ |
| 1343 | 1340 |
| 1344 default: { | 1341 default: { |
| 1345 int pos = position(); | 1342 int pos = position(); |
| 1346 ExpressionClassifier classifier(this); | 1343 ExpressionClassifier classifier(this); |
| 1347 Expression* value = | 1344 Expression* value = ParseAssignmentExpression(true, CHECK_OK); |
| 1348 ParseAssignmentExpression(true, &classifier, CHECK_OK); | 1345 RewriteNonPattern(CHECK_OK); |
| 1349 RewriteNonPattern(&classifier, CHECK_OK); | |
| 1350 SetFunctionName(value, ast_value_factory()->default_string()); | 1346 SetFunctionName(value, ast_value_factory()->default_string()); |
| 1351 | 1347 |
| 1352 const AstRawString* local_name = | 1348 const AstRawString* local_name = |
| 1353 ast_value_factory()->star_default_star_string(); | 1349 ast_value_factory()->star_default_star_string(); |
| 1354 local_names.Add(local_name, zone()); | 1350 local_names.Add(local_name, zone()); |
| 1355 | 1351 |
| 1356 // It's fine to declare this as CONST because the user has no way of | 1352 // It's fine to declare this as CONST because the user has no way of |
| 1357 // writing to it. | 1353 // writing to it. |
| 1358 Declaration* decl = DeclareVariable(local_name, CONST, pos, CHECK_OK); | 1354 Declaration* decl = DeclareVariable(local_name, CONST, pos, CHECK_OK); |
| 1359 decl->proxy()->var()->set_initializer_position(position()); | 1355 decl->proxy()->var()->set_initializer_position(position()); |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1847 const AstRawString* variable_name; | 1843 const AstRawString* variable_name; |
| 1848 if (default_export && (peek() == Token::EXTENDS || peek() == Token::LBRACE)) { | 1844 if (default_export && (peek() == Token::EXTENDS || peek() == Token::LBRACE)) { |
| 1849 name = ast_value_factory()->default_string(); | 1845 name = ast_value_factory()->default_string(); |
| 1850 is_strict_reserved = false; | 1846 is_strict_reserved = false; |
| 1851 variable_name = ast_value_factory()->star_default_star_string(); | 1847 variable_name = ast_value_factory()->star_default_star_string(); |
| 1852 } else { | 1848 } else { |
| 1853 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); | 1849 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); |
| 1854 variable_name = name; | 1850 variable_name = name; |
| 1855 } | 1851 } |
| 1856 | 1852 |
| 1857 Expression* value = ParseClassLiteral(nullptr, name, scanner()->location(), | 1853 ExpressionClassifier no_classifier(this); |
| 1854 Expression* value = ParseClassLiteral(name, scanner()->location(), |
| 1858 is_strict_reserved, pos, CHECK_OK); | 1855 is_strict_reserved, pos, CHECK_OK); |
| 1859 | 1856 |
| 1860 Declaration* decl = DeclareVariable(variable_name, LET, pos, CHECK_OK); | 1857 Declaration* decl = DeclareVariable(variable_name, LET, pos, CHECK_OK); |
| 1861 decl->proxy()->var()->set_initializer_position(position()); | 1858 decl->proxy()->var()->set_initializer_position(position()); |
| 1862 Assignment* assignment = | 1859 Assignment* assignment = |
| 1863 factory()->NewAssignment(Token::INIT, decl->proxy(), value, pos); | 1860 factory()->NewAssignment(Token::INIT, decl->proxy(), value, pos); |
| 1864 Statement* assignment_statement = | 1861 Statement* assignment_statement = |
| 1865 factory()->NewExpressionStatement(assignment, kNoSourcePosition); | 1862 factory()->NewExpressionStatement(assignment, kNoSourcePosition); |
| 1866 if (names) names->Add(variable_name, zone()); | 1863 if (names) names->Add(variable_name, zone()); |
| 1867 return assignment_statement; | 1864 return assignment_statement; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1988 do { | 1985 do { |
| 1989 FuncNameInferrer::State fni_state(fni_); | 1986 FuncNameInferrer::State fni_state(fni_); |
| 1990 | 1987 |
| 1991 // Parse name. | 1988 // Parse name. |
| 1992 if (!first_declaration) Consume(Token::COMMA); | 1989 if (!first_declaration) Consume(Token::COMMA); |
| 1993 | 1990 |
| 1994 Expression* pattern; | 1991 Expression* pattern; |
| 1995 int decl_pos = peek_position(); | 1992 int decl_pos = peek_position(); |
| 1996 { | 1993 { |
| 1997 ExpressionClassifier pattern_classifier(this); | 1994 ExpressionClassifier pattern_classifier(this); |
| 1998 pattern = ParsePrimaryExpression(&pattern_classifier, CHECK_OK); | 1995 pattern = ParsePrimaryExpression(CHECK_OK); |
| 1999 ValidateBindingPattern(&pattern_classifier, CHECK_OK); | 1996 ValidateBindingPattern(CHECK_OK); |
| 2000 if (IsLexicalVariableMode(parsing_result->descriptor.mode)) { | 1997 if (IsLexicalVariableMode(parsing_result->descriptor.mode)) { |
| 2001 ValidateLetPattern(&pattern_classifier, CHECK_OK); | 1998 ValidateLetPattern(CHECK_OK); |
| 2002 } | 1999 } |
| 2003 } | 2000 } |
| 2004 | 2001 |
| 2005 Scanner::Location variable_loc = scanner()->location(); | 2002 Scanner::Location variable_loc = scanner()->location(); |
| 2006 const AstRawString* single_name = | 2003 const AstRawString* single_name = |
| 2007 pattern->IsVariableProxy() ? pattern->AsVariableProxy()->raw_name() | 2004 pattern->IsVariableProxy() ? pattern->AsVariableProxy()->raw_name() |
| 2008 : nullptr; | 2005 : nullptr; |
| 2009 if (single_name != nullptr) { | 2006 if (single_name != nullptr) { |
| 2010 if (fni_ != NULL) fni_->PushVariableName(single_name); | 2007 if (fni_ != NULL) fni_->PushVariableName(single_name); |
| 2011 } | 2008 } |
| 2012 | 2009 |
| 2013 Expression* value = NULL; | 2010 Expression* value = NULL; |
| 2014 int initializer_position = kNoSourcePosition; | 2011 int initializer_position = kNoSourcePosition; |
| 2015 if (Check(Token::ASSIGN)) { | 2012 if (Check(Token::ASSIGN)) { |
| 2016 ExpressionClassifier classifier(this); | 2013 ExpressionClassifier classifier(this); |
| 2017 value = ParseAssignmentExpression(var_context != kForStatement, | 2014 value = ParseAssignmentExpression(var_context != kForStatement, CHECK_OK); |
| 2018 &classifier, CHECK_OK); | 2015 RewriteNonPattern(CHECK_OK); |
| 2019 RewriteNonPattern(&classifier, CHECK_OK); | |
| 2020 variable_loc.end_pos = scanner()->location().end_pos; | 2016 variable_loc.end_pos = scanner()->location().end_pos; |
| 2021 | 2017 |
| 2022 if (!parsing_result->first_initializer_loc.IsValid()) { | 2018 if (!parsing_result->first_initializer_loc.IsValid()) { |
| 2023 parsing_result->first_initializer_loc = variable_loc; | 2019 parsing_result->first_initializer_loc = variable_loc; |
| 2024 } | 2020 } |
| 2025 | 2021 |
| 2026 // Don't infer if it is "a = function(){...}();"-like expression. | 2022 // Don't infer if it is "a = function(){...}();"-like expression. |
| 2027 if (single_name) { | 2023 if (single_name) { |
| 2028 if (fni_ != NULL && value->AsCall() == NULL && | 2024 if (fni_ != NULL && value->AsCall() == NULL && |
| 2029 value->AsCallNew() == NULL) { | 2025 value->AsCallNew() == NULL) { |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2604 BlockState block_state(&scope_state_); | 2600 BlockState block_state(&scope_state_); |
| 2605 block_state.set_start_position(scanner()->location().beg_pos); | 2601 block_state.set_start_position(scanner()->location().beg_pos); |
| 2606 Target target(&this->target_stack_, catch_block); | 2602 Target target(&this->target_stack_, catch_block); |
| 2607 | 2603 |
| 2608 const AstRawString* name = ast_value_factory()->dot_catch_string(); | 2604 const AstRawString* name = ast_value_factory()->dot_catch_string(); |
| 2609 Expression* pattern = nullptr; | 2605 Expression* pattern = nullptr; |
| 2610 if (peek_any_identifier()) { | 2606 if (peek_any_identifier()) { |
| 2611 name = ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK); | 2607 name = ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK); |
| 2612 } else { | 2608 } else { |
| 2613 ExpressionClassifier pattern_classifier(this); | 2609 ExpressionClassifier pattern_classifier(this); |
| 2614 pattern = ParsePrimaryExpression(&pattern_classifier, CHECK_OK); | 2610 pattern = ParsePrimaryExpression(CHECK_OK); |
| 2615 ValidateBindingPattern(&pattern_classifier, CHECK_OK); | 2611 ValidateBindingPattern(CHECK_OK); |
| 2616 } | 2612 } |
| 2617 catch_variable = catch_scope->DeclareLocal( | 2613 catch_variable = catch_scope->DeclareLocal( |
| 2618 name, VAR, kCreatedInitialized, Variable::NORMAL); | 2614 name, VAR, kCreatedInitialized, Variable::NORMAL); |
| 2619 | 2615 |
| 2620 Expect(Token::RPAREN, CHECK_OK); | 2616 Expect(Token::RPAREN, CHECK_OK); |
| 2621 | 2617 |
| 2622 ZoneList<const AstRawString*> bound_names(1, zone()); | 2618 ZoneList<const AstRawString*> bound_names(1, zone()); |
| 2623 if (pattern != nullptr) { | 2619 if (pattern != nullptr) { |
| 2624 DeclarationDescriptor descriptor; | 2620 DeclarationDescriptor descriptor; |
| 2625 descriptor.declaration_kind = DeclarationDescriptor::NORMAL; | 2621 descriptor.declaration_kind = DeclarationDescriptor::NORMAL; |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3327 Variable* temp = NewTemporary(ast_value_factory()->dot_for_string()); | 3323 Variable* temp = NewTemporary(ast_value_factory()->dot_for_string()); |
| 3328 ForEachStatement* loop = | 3324 ForEachStatement* loop = |
| 3329 factory()->NewForEachStatement(mode, labels, stmt_pos); | 3325 factory()->NewForEachStatement(mode, labels, stmt_pos); |
| 3330 Target target(&this->target_stack_, loop); | 3326 Target target(&this->target_stack_, loop); |
| 3331 | 3327 |
| 3332 int each_keyword_position = scanner()->location().beg_pos; | 3328 int each_keyword_position = scanner()->location().beg_pos; |
| 3333 | 3329 |
| 3334 Expression* enumerable; | 3330 Expression* enumerable; |
| 3335 if (mode == ForEachStatement::ITERATE) { | 3331 if (mode == ForEachStatement::ITERATE) { |
| 3336 ExpressionClassifier classifier(this); | 3332 ExpressionClassifier classifier(this); |
| 3337 enumerable = ParseAssignmentExpression(true, &classifier, CHECK_OK); | 3333 enumerable = ParseAssignmentExpression(true, CHECK_OK); |
| 3338 RewriteNonPattern(&classifier, CHECK_OK); | 3334 RewriteNonPattern(CHECK_OK); |
| 3339 } else { | 3335 } else { |
| 3340 enumerable = ParseExpression(true, CHECK_OK); | 3336 enumerable = ParseExpression(true, CHECK_OK); |
| 3341 } | 3337 } |
| 3342 | 3338 |
| 3343 Expect(Token::RPAREN, CHECK_OK); | 3339 Expect(Token::RPAREN, CHECK_OK); |
| 3344 | 3340 |
| 3345 | 3341 |
| 3346 Block* body_block = | 3342 Block* body_block = |
| 3347 factory()->NewBlock(NULL, 3, false, kNoSourcePosition); | 3343 factory()->NewBlock(NULL, 3, false, kNoSourcePosition); |
| 3348 | 3344 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3443 } else { | 3439 } else { |
| 3444 bound_names_are_lexical = | 3440 bound_names_are_lexical = |
| 3445 IsLexicalVariableMode(parsing_result.descriptor.mode); | 3441 IsLexicalVariableMode(parsing_result.descriptor.mode); |
| 3446 init = BuildInitializationBlock( | 3442 init = BuildInitializationBlock( |
| 3447 &parsing_result, bound_names_are_lexical ? &bound_names : nullptr, | 3443 &parsing_result, bound_names_are_lexical ? &bound_names : nullptr, |
| 3448 CHECK_OK); | 3444 CHECK_OK); |
| 3449 } | 3445 } |
| 3450 } else { | 3446 } else { |
| 3451 int lhs_beg_pos = peek_position(); | 3447 int lhs_beg_pos = peek_position(); |
| 3452 ExpressionClassifier classifier(this); | 3448 ExpressionClassifier classifier(this); |
| 3453 Expression* expression = ParseExpression(false, &classifier, CHECK_OK); | 3449 Expression* expression = ParseExpressionCoverGrammar(false, CHECK_OK); |
| 3454 int lhs_end_pos = scanner()->location().end_pos; | 3450 int lhs_end_pos = scanner()->location().end_pos; |
| 3455 ForEachStatement::VisitMode mode = ForEachStatement::ENUMERATE; | 3451 ForEachStatement::VisitMode mode = ForEachStatement::ENUMERATE; |
| 3456 | 3452 |
| 3457 bool is_for_each = CheckInOrOf(&mode, CHECK_OK); | 3453 bool is_for_each = CheckInOrOf(&mode, CHECK_OK); |
| 3458 bool is_destructuring = is_for_each && (expression->IsArrayLiteral() || | 3454 bool is_destructuring = is_for_each && (expression->IsArrayLiteral() || |
| 3459 expression->IsObjectLiteral()); | 3455 expression->IsObjectLiteral()); |
| 3460 | 3456 |
| 3461 if (is_destructuring) { | 3457 if (is_destructuring) { |
| 3462 ValidateAssignmentPattern(&classifier, CHECK_OK); | 3458 ValidateAssignmentPattern(CHECK_OK); |
| 3463 } else { | 3459 } else { |
| 3464 RewriteNonPattern(&classifier, CHECK_OK); | 3460 RewriteNonPattern(CHECK_OK); |
| 3465 } | 3461 } |
| 3466 | 3462 |
| 3467 if (is_for_each) { | 3463 if (is_for_each) { |
| 3468 if (!is_destructuring) { | 3464 if (!is_destructuring) { |
| 3469 expression = CheckAndRewriteReferenceExpression( | 3465 expression = CheckAndRewriteReferenceExpression( |
| 3470 expression, lhs_beg_pos, lhs_end_pos, | 3466 expression, lhs_beg_pos, lhs_end_pos, |
| 3471 MessageTemplate::kInvalidLhsInFor, kSyntaxError, CHECK_OK); | 3467 MessageTemplate::kInvalidLhsInFor, kSyntaxError, CHECK_OK); |
| 3472 } | 3468 } |
| 3473 | 3469 |
| 3474 ForEachStatement* loop = | 3470 ForEachStatement* loop = |
| 3475 factory()->NewForEachStatement(mode, labels, stmt_pos); | 3471 factory()->NewForEachStatement(mode, labels, stmt_pos); |
| 3476 Target target(&this->target_stack_, loop); | 3472 Target target(&this->target_stack_, loop); |
| 3477 | 3473 |
| 3478 int each_keyword_position = scanner()->location().beg_pos; | 3474 int each_keyword_position = scanner()->location().beg_pos; |
| 3479 | 3475 |
| 3480 Expression* enumerable; | 3476 Expression* enumerable; |
| 3481 if (mode == ForEachStatement::ITERATE) { | 3477 if (mode == ForEachStatement::ITERATE) { |
| 3482 ExpressionClassifier classifier(this); | 3478 ExpressionClassifier classifier(this); |
| 3483 enumerable = ParseAssignmentExpression(true, &classifier, CHECK_OK); | 3479 enumerable = ParseAssignmentExpression(true, CHECK_OK); |
| 3484 RewriteNonPattern(&classifier, CHECK_OK); | 3480 RewriteNonPattern(CHECK_OK); |
| 3485 } else { | 3481 } else { |
| 3486 enumerable = ParseExpression(true, CHECK_OK); | 3482 enumerable = ParseExpression(true, CHECK_OK); |
| 3487 } | 3483 } |
| 3488 | 3484 |
| 3489 Expect(Token::RPAREN, CHECK_OK); | 3485 Expect(Token::RPAREN, CHECK_OK); |
| 3490 | 3486 |
| 3491 // For legacy compat reasons, give for loops similar treatment to | 3487 // For legacy compat reasons, give for loops similar treatment to |
| 3492 // if statements in allowing a function declaration for a body | 3488 // if statements in allowing a function declaration for a body |
| 3493 Statement* body = ParseScopedStatement(NULL, true, CHECK_OK); | 3489 Statement* body = ParseScopedStatement(NULL, true, CHECK_OK); |
| 3494 Statement* final_loop = InitializeForEachStatement( | 3490 Statement* final_loop = InitializeForEachStatement( |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3688 DCHECK(!assignment->is_compound()); | 3684 DCHECK(!assignment->is_compound()); |
| 3689 initializer = assignment->value(); | 3685 initializer = assignment->value(); |
| 3690 expr = assignment->target(); | 3686 expr = assignment->target(); |
| 3691 } | 3687 } |
| 3692 | 3688 |
| 3693 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest); | 3689 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest); |
| 3694 } | 3690 } |
| 3695 | 3691 |
| 3696 void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name, | 3692 void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name, |
| 3697 Scope* scope, ZoneList<Statement*>* body, | 3693 Scope* scope, ZoneList<Statement*>* body, |
| 3698 ExpressionClassifier* classifier, | |
| 3699 FunctionKind kind, | 3694 FunctionKind kind, |
| 3700 FunctionBodyType body_type, | 3695 FunctionBodyType body_type, |
| 3701 bool accept_IN, int pos, bool* ok) { | 3696 bool accept_IN, int pos, bool* ok) { |
| 3702 // function async_function() { | 3697 // function async_function() { |
| 3703 // .generator_object = %CreateGeneratorObject(); | 3698 // .generator_object = %CreateGeneratorObject(); |
| 3704 // BuildRejectPromiseOnException({ | 3699 // BuildRejectPromiseOnException({ |
| 3705 // ... function body ... | 3700 // ... function body ... |
| 3706 // return %ResolvePromise(.promise, expr), .promise; | 3701 // return %ResolvePromise(.promise, expr), .promise; |
| 3707 // }) | 3702 // }) |
| 3708 // } | 3703 // } |
| 3709 scope->ForceContextAllocation(); | 3704 scope->ForceContextAllocation(); |
| 3710 Variable* temp = | 3705 Variable* temp = |
| 3711 NewTemporary(ast_value_factory()->dot_generator_object_string()); | 3706 NewTemporary(ast_value_factory()->dot_generator_object_string()); |
| 3712 function_state_->set_generator_object_variable(temp); | 3707 function_state_->set_generator_object_variable(temp); |
| 3713 | 3708 |
| 3714 Expression* init_generator_variable = factory()->NewAssignment( | 3709 Expression* init_generator_variable = factory()->NewAssignment( |
| 3715 Token::INIT, factory()->NewVariableProxy(temp), | 3710 Token::INIT, factory()->NewVariableProxy(temp), |
| 3716 BuildCreateJSGeneratorObject(pos, kind), kNoSourcePosition); | 3711 BuildCreateJSGeneratorObject(pos, kind), kNoSourcePosition); |
| 3717 body->Add(factory()->NewExpressionStatement(init_generator_variable, | 3712 body->Add(factory()->NewExpressionStatement(init_generator_variable, |
| 3718 kNoSourcePosition), | 3713 kNoSourcePosition), |
| 3719 zone()); | 3714 zone()); |
| 3720 | 3715 |
| 3721 Block* block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition); | 3716 Block* block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition); |
| 3722 | 3717 |
| 3723 Expression* return_value = nullptr; | 3718 Expression* return_value = nullptr; |
| 3724 if (body_type == FunctionBodyType::kNormal) { | 3719 if (body_type == FunctionBodyType::kNormal) { |
| 3725 ParseStatementList(block->statements(), Token::RBRACE, CHECK_OK_VOID); | 3720 ParseStatementList(block->statements(), Token::RBRACE, CHECK_OK_VOID); |
| 3726 return_value = factory()->NewUndefinedLiteral(kNoSourcePosition); | 3721 return_value = factory()->NewUndefinedLiteral(kNoSourcePosition); |
| 3727 } else { | 3722 } else { |
| 3728 return_value = | 3723 return_value = ParseAssignmentExpression(accept_IN, CHECK_OK_VOID); |
| 3729 ParseAssignmentExpression(accept_IN, classifier, CHECK_OK_VOID); | 3724 RewriteNonPattern(CHECK_OK_VOID); |
| 3730 RewriteNonPattern(classifier, CHECK_OK_VOID); | |
| 3731 } | 3725 } |
| 3732 | 3726 |
| 3733 return_value = BuildResolvePromise(return_value, return_value->position()); | 3727 return_value = BuildResolvePromise(return_value, return_value->position()); |
| 3734 block->statements()->Add( | 3728 block->statements()->Add( |
| 3735 factory()->NewReturnStatement(return_value, return_value->position()), | 3729 factory()->NewReturnStatement(return_value, return_value->position()), |
| 3736 zone()); | 3730 zone()); |
| 3737 block = BuildRejectPromiseOnException(block, CHECK_OK_VOID); | 3731 block = BuildRejectPromiseOnException(block, CHECK_OK_VOID); |
| 3738 body->Add(block, zone()); | 3732 body->Add(block, zone()); |
| 3739 scope->set_end_position(scanner()->location().end_pos); | 3733 scope->set_end_position(scanner()->location().end_pos); |
| 3740 } | 3734 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3767 scope_snapshot.Reparent(parameters->scope); | 3761 scope_snapshot.Reparent(parameters->scope); |
| 3768 | 3762 |
| 3769 if (parameters->Arity() > Code::kMaxArguments) { | 3763 if (parameters->Arity() > Code::kMaxArguments) { |
| 3770 ReportMessageAt(params_loc, MessageTemplate::kMalformedArrowFunParamList); | 3764 ReportMessageAt(params_loc, MessageTemplate::kMalformedArrowFunParamList); |
| 3771 *ok = false; | 3765 *ok = false; |
| 3772 return; | 3766 return; |
| 3773 } | 3767 } |
| 3774 | 3768 |
| 3775 ExpressionClassifier classifier(this); | 3769 ExpressionClassifier classifier(this); |
| 3776 if (!parameters->is_simple) { | 3770 if (!parameters->is_simple) { |
| 3777 classifier.RecordNonSimpleParameter(); | 3771 this->classifier()->RecordNonSimpleParameter(); |
| 3778 } | 3772 } |
| 3779 for (int i = 0; i < parameters->Arity(); ++i) { | 3773 for (int i = 0; i < parameters->Arity(); ++i) { |
| 3780 auto parameter = parameters->at(i); | 3774 auto parameter = parameters->at(i); |
| 3781 DeclareFormalParameter(parameters->scope, parameter, &classifier); | 3775 DeclareFormalParameter(parameters->scope, parameter); |
| 3782 if (!duplicate_loc->IsValid()) { | 3776 if (!duplicate_loc->IsValid()) { |
| 3783 *duplicate_loc = classifier.duplicate_formal_parameter_error().location; | 3777 *duplicate_loc = |
| 3778 this->classifier()->duplicate_formal_parameter_error().location; |
| 3784 } | 3779 } |
| 3785 } | 3780 } |
| 3786 DCHECK_EQ(parameters->is_simple, parameters->scope->has_simple_parameters()); | 3781 DCHECK_EQ(parameters->is_simple, parameters->scope->has_simple_parameters()); |
| 3787 } | 3782 } |
| 3788 | 3783 |
| 3789 void Parser::ReindexLiterals(const ParserFormalParameters& parameters) { | 3784 void Parser::ReindexLiterals(const ParserFormalParameters& parameters) { |
| 3790 if (function_state_->materialized_literal_count() > 0) { | 3785 if (function_state_->materialized_literal_count() > 0) { |
| 3791 AstLiteralReindexer reindexer; | 3786 AstLiteralReindexer reindexer; |
| 3792 | 3787 |
| 3793 for (const auto p : parameters.params) { | 3788 for (const auto p : parameters.params) { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3948 // expressions. This also marks the FunctionState as a generator. | 3943 // expressions. This also marks the FunctionState as a generator. |
| 3949 Variable* temp = | 3944 Variable* temp = |
| 3950 NewTemporary(ast_value_factory()->dot_generator_object_string()); | 3945 NewTemporary(ast_value_factory()->dot_generator_object_string()); |
| 3951 function_state.set_generator_object_variable(temp); | 3946 function_state.set_generator_object_variable(temp); |
| 3952 } | 3947 } |
| 3953 | 3948 |
| 3954 Expect(Token::LPAREN, CHECK_OK); | 3949 Expect(Token::LPAREN, CHECK_OK); |
| 3955 int start_position = scanner()->location().beg_pos; | 3950 int start_position = scanner()->location().beg_pos; |
| 3956 this->scope()->set_start_position(start_position); | 3951 this->scope()->set_start_position(start_position); |
| 3957 ParserFormalParameters formals(scope); | 3952 ParserFormalParameters formals(scope); |
| 3958 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); | 3953 ParseFormalParameterList(&formals, CHECK_OK); |
| 3959 arity = formals.Arity(); | 3954 arity = formals.Arity(); |
| 3960 Expect(Token::RPAREN, CHECK_OK); | 3955 Expect(Token::RPAREN, CHECK_OK); |
| 3961 int formals_end_position = scanner()->location().end_pos; | 3956 int formals_end_position = scanner()->location().end_pos; |
| 3962 | 3957 |
| 3963 CheckArityRestrictions(arity, kind, formals.has_rest, start_position, | 3958 CheckArityRestrictions(arity, kind, formals.has_rest, start_position, |
| 3964 formals_end_position, CHECK_OK); | 3959 formals_end_position, CHECK_OK); |
| 3965 Expect(Token::LBRACE, CHECK_OK); | 3960 Expect(Token::LBRACE, CHECK_OK); |
| 3966 // Don't include the rest parameter into the function's formal parameter | 3961 // Don't include the rest parameter into the function's formal parameter |
| 3967 // count (esp. the SharedFunctionInfo::internal_formal_parameter_count, | 3962 // count (esp. the SharedFunctionInfo::internal_formal_parameter_count, |
| 3968 // which says whether we need to create an arguments adaptor frame). | 3963 // which says whether we need to create an arguments adaptor frame). |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4010 | 4005 |
| 4011 // Parsing the body may change the language mode in our scope. | 4006 // Parsing the body may change the language mode in our scope. |
| 4012 language_mode = scope->language_mode(); | 4007 language_mode = scope->language_mode(); |
| 4013 | 4008 |
| 4014 // Validate name and parameter names. We can do this only after parsing the | 4009 // Validate name and parameter names. We can do this only after parsing the |
| 4015 // function, since the function can declare itself strict. | 4010 // function, since the function can declare itself strict. |
| 4016 CheckFunctionName(language_mode, function_name, function_name_validity, | 4011 CheckFunctionName(language_mode, function_name, function_name_validity, |
| 4017 function_name_location, CHECK_OK); | 4012 function_name_location, CHECK_OK); |
| 4018 const bool allow_duplicate_parameters = | 4013 const bool allow_duplicate_parameters = |
| 4019 is_sloppy(language_mode) && formals.is_simple && !IsConciseMethod(kind); | 4014 is_sloppy(language_mode) && formals.is_simple && !IsConciseMethod(kind); |
| 4020 ValidateFormalParameters(&formals_classifier, language_mode, | 4015 ValidateFormalParameters(language_mode, allow_duplicate_parameters, |
| 4021 allow_duplicate_parameters, CHECK_OK); | 4016 CHECK_OK); |
| 4022 | 4017 |
| 4023 if (is_strict(language_mode)) { | 4018 if (is_strict(language_mode)) { |
| 4024 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), | 4019 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), |
| 4025 CHECK_OK); | 4020 CHECK_OK); |
| 4026 CheckDecimalLiteralWithLeadingZero(use_counts_, scope->start_position(), | 4021 CheckDecimalLiteralWithLeadingZero(use_counts_, scope->start_position(), |
| 4027 scope->end_position()); | 4022 scope->end_position()); |
| 4028 } | 4023 } |
| 4029 CheckConflictingVarDeclarations(scope, CHECK_OK); | 4024 CheckConflictingVarDeclarations(scope, CHECK_OK); |
| 4030 | 4025 |
| 4031 if (body) { | 4026 if (body) { |
| 4032 // If body can be inspected, rewrite queued destructuring assignments | 4027 // If body can be inspected, rewrite queued destructuring assignments |
| 4033 RewriteDestructuringAssignments(); | 4028 RewriteDestructuringAssignments(); |
| 4034 } | 4029 } |
| 4035 has_duplicate_parameters = | 4030 has_duplicate_parameters = |
| 4036 !formals_classifier.is_valid_formal_parameter_list_without_duplicates(); | 4031 !classifier()->is_valid_formal_parameter_list_without_duplicates(); |
| 4037 | 4032 |
| 4038 if (use_temp_zone) { | 4033 if (use_temp_zone) { |
| 4039 DCHECK(main_scope != scope); | 4034 DCHECK(main_scope != scope); |
| 4040 scope->AnalyzePartially(main_scope, &previous_zone_ast_node_factory); | 4035 scope->AnalyzePartially(main_scope, &previous_zone_ast_node_factory); |
| 4041 } | 4036 } |
| 4042 } // DiscardableZoneScope goes out of scope. | 4037 } // DiscardableZoneScope goes out of scope. |
| 4043 | 4038 |
| 4044 FunctionLiteral::ParameterFlag duplicate_parameters = | 4039 FunctionLiteral::ParameterFlag duplicate_parameters = |
| 4045 has_duplicate_parameters ? FunctionLiteral::kHasDuplicateParameters | 4040 has_duplicate_parameters ? FunctionLiteral::kHasDuplicateParameters |
| 4046 : FunctionLiteral::kNoDuplicateParameters; | 4041 : FunctionLiteral::kNoDuplicateParameters; |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4526 Expression* call = factory()->NewCallRuntime( | 4521 Expression* call = factory()->NewCallRuntime( |
| 4527 Runtime::kInlineGeneratorClose, args, kNoSourcePosition); | 4522 Runtime::kInlineGeneratorClose, args, kNoSourcePosition); |
| 4528 finally_block->statements()->Add( | 4523 finally_block->statements()->Add( |
| 4529 factory()->NewExpressionStatement(call, kNoSourcePosition), zone()); | 4524 factory()->NewExpressionStatement(call, kNoSourcePosition), zone()); |
| 4530 | 4525 |
| 4531 body->Add(factory()->NewTryFinallyStatement(try_block, finally_block, | 4526 body->Add(factory()->NewTryFinallyStatement(try_block, finally_block, |
| 4532 kNoSourcePosition), | 4527 kNoSourcePosition), |
| 4533 zone()); | 4528 zone()); |
| 4534 } else if (IsAsyncFunction(kind)) { | 4529 } else if (IsAsyncFunction(kind)) { |
| 4535 const bool accept_IN = true; | 4530 const bool accept_IN = true; |
| 4536 DesugarAsyncFunctionBody(function_name, inner_scope, body, nullptr, kind, | 4531 DesugarAsyncFunctionBody(function_name, inner_scope, body, kind, |
| 4537 FunctionBodyType::kNormal, accept_IN, pos, | 4532 FunctionBodyType::kNormal, accept_IN, pos, |
| 4538 CHECK_OK); | 4533 CHECK_OK); |
| 4539 } else { | 4534 } else { |
| 4540 ParseStatementList(body, Token::RBRACE, CHECK_OK); | 4535 ParseStatementList(body, Token::RBRACE, CHECK_OK); |
| 4541 } | 4536 } |
| 4542 | 4537 |
| 4543 if (IsSubclassConstructor(kind)) { | 4538 if (IsSubclassConstructor(kind)) { |
| 4544 body->Add(factory()->NewReturnStatement(ThisExpression(kNoSourcePosition), | 4539 body->Add(factory()->NewReturnStatement(ThisExpression(kNoSourcePosition), |
| 4545 kNoSourcePosition), | 4540 kNoSourcePosition), |
| 4546 zone()); | 4541 zone()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4633 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( | 4628 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( |
| 4634 language_mode(), function_state_->kind(), | 4629 language_mode(), function_state_->kind(), |
| 4635 scope()->AsDeclarationScope()->has_simple_parameters(), parsing_module_, | 4630 scope()->AsDeclarationScope()->has_simple_parameters(), parsing_module_, |
| 4636 logger, bookmark, use_counts_); | 4631 logger, bookmark, use_counts_); |
| 4637 if (pre_parse_timer_ != NULL) { | 4632 if (pre_parse_timer_ != NULL) { |
| 4638 pre_parse_timer_->Stop(); | 4633 pre_parse_timer_->Stop(); |
| 4639 } | 4634 } |
| 4640 return result; | 4635 return result; |
| 4641 } | 4636 } |
| 4642 | 4637 |
| 4643 Expression* Parser::ParseClassLiteral(ExpressionClassifier* classifier, | 4638 Expression* Parser::ParseClassLiteral(const AstRawString* name, |
| 4644 const AstRawString* name, | |
| 4645 Scanner::Location class_name_location, | 4639 Scanner::Location class_name_location, |
| 4646 bool name_is_strict_reserved, int pos, | 4640 bool name_is_strict_reserved, int pos, |
| 4647 bool* ok) { | 4641 bool* ok) { |
| 4648 // All parts of a ClassDeclaration and ClassExpression are strict code. | 4642 // All parts of a ClassDeclaration and ClassExpression are strict code. |
| 4649 if (name_is_strict_reserved) { | 4643 if (name_is_strict_reserved) { |
| 4650 ReportMessageAt(class_name_location, | 4644 ReportMessageAt(class_name_location, |
| 4651 MessageTemplate::kUnexpectedStrictReserved); | 4645 MessageTemplate::kUnexpectedStrictReserved); |
| 4652 *ok = false; | 4646 *ok = false; |
| 4653 return nullptr; | 4647 return nullptr; |
| 4654 } | 4648 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4671 Declaration* declaration = | 4665 Declaration* declaration = |
| 4672 factory()->NewVariableDeclaration(proxy, block_state.scope(), pos); | 4666 factory()->NewVariableDeclaration(proxy, block_state.scope(), pos); |
| 4673 Declare(declaration, DeclarationDescriptor::NORMAL, CONST, | 4667 Declare(declaration, DeclarationDescriptor::NORMAL, CONST, |
| 4674 DefaultInitializationFlag(CONST), CHECK_OK); | 4668 DefaultInitializationFlag(CONST), CHECK_OK); |
| 4675 } | 4669 } |
| 4676 | 4670 |
| 4677 Expression* extends = nullptr; | 4671 Expression* extends = nullptr; |
| 4678 if (Check(Token::EXTENDS)) { | 4672 if (Check(Token::EXTENDS)) { |
| 4679 block_state.set_start_position(scanner()->location().end_pos); | 4673 block_state.set_start_position(scanner()->location().end_pos); |
| 4680 ExpressionClassifier extends_classifier(this); | 4674 ExpressionClassifier extends_classifier(this); |
| 4681 extends = ParseLeftHandSideExpression(&extends_classifier, CHECK_OK); | 4675 extends = ParseLeftHandSideExpression(CHECK_OK); |
| 4682 CheckNoTailCallExpressions(&extends_classifier, CHECK_OK); | 4676 CheckNoTailCallExpressions(CHECK_OK); |
| 4683 RewriteNonPattern(&extends_classifier, CHECK_OK); | 4677 RewriteNonPattern(CHECK_OK); |
| 4684 if (classifier != nullptr) { | 4678 impl()->AccumulateFormalParameterContainmentErrors(); |
| 4685 classifier->AccumulateFormalParameterContainmentErrors( | |
| 4686 &extends_classifier); | |
| 4687 } | |
| 4688 } else { | 4679 } else { |
| 4689 block_state.set_start_position(scanner()->location().end_pos); | 4680 block_state.set_start_position(scanner()->location().end_pos); |
| 4690 } | 4681 } |
| 4691 | 4682 |
| 4692 | 4683 |
| 4693 ClassLiteralChecker checker(this); | 4684 ClassLiteralChecker checker(this); |
| 4694 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4); | 4685 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4); |
| 4695 FunctionLiteral* constructor = nullptr; | 4686 FunctionLiteral* constructor = nullptr; |
| 4696 bool has_seen_constructor = false; | 4687 bool has_seen_constructor = false; |
| 4697 | 4688 |
| 4698 Expect(Token::LBRACE, CHECK_OK); | 4689 Expect(Token::LBRACE, CHECK_OK); |
| 4699 | 4690 |
| 4700 const bool has_extends = extends != nullptr; | 4691 const bool has_extends = extends != nullptr; |
| 4701 while (peek() != Token::RBRACE) { | 4692 while (peek() != Token::RBRACE) { |
| 4702 if (Check(Token::SEMICOLON)) continue; | 4693 if (Check(Token::SEMICOLON)) continue; |
| 4703 FuncNameInferrer::State fni_state(fni_); | 4694 FuncNameInferrer::State fni_state(fni_); |
| 4704 const bool in_class = true; | 4695 const bool in_class = true; |
| 4705 bool is_computed_name = false; // Classes do not care about computed | 4696 bool is_computed_name = false; // Classes do not care about computed |
| 4706 // property names here. | 4697 // property names here. |
| 4707 ExpressionClassifier property_classifier(this); | 4698 ExpressionClassifier property_classifier(this); |
| 4708 const AstRawString* property_name = nullptr; | 4699 const AstRawString* property_name = nullptr; |
| 4709 ObjectLiteral::Property* property = ParsePropertyDefinition( | 4700 ObjectLiteral::Property* property = ParsePropertyDefinition( |
| 4710 &checker, in_class, has_extends, &is_computed_name, | 4701 &checker, in_class, has_extends, &is_computed_name, |
| 4711 &has_seen_constructor, &property_classifier, &property_name, CHECK_OK); | 4702 &has_seen_constructor, &property_name, CHECK_OK); |
| 4712 RewriteNonPattern(&property_classifier, CHECK_OK); | 4703 RewriteNonPattern(CHECK_OK); |
| 4713 if (classifier != nullptr) { | 4704 impl()->AccumulateFormalParameterContainmentErrors(); |
| 4714 classifier->AccumulateFormalParameterContainmentErrors( | |
| 4715 &property_classifier); | |
| 4716 } | |
| 4717 | 4705 |
| 4718 if (has_seen_constructor && constructor == nullptr) { | 4706 if (has_seen_constructor && constructor == nullptr) { |
| 4719 constructor = GetPropertyValue(property)->AsFunctionLiteral(); | 4707 constructor = GetPropertyValue(property)->AsFunctionLiteral(); |
| 4720 DCHECK_NOT_NULL(constructor); | 4708 DCHECK_NOT_NULL(constructor); |
| 4721 constructor->set_raw_name( | 4709 constructor->set_raw_name( |
| 4722 name != nullptr ? name : ast_value_factory()->empty_string()); | 4710 name != nullptr ? name : ast_value_factory()->empty_string()); |
| 4723 } else { | 4711 } else { |
| 4724 properties->Add(property, zone()); | 4712 properties->Add(property, zone()); |
| 4725 } | 4713 } |
| 4726 | 4714 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4769 // CallRuntime :: | 4757 // CallRuntime :: |
| 4770 // '%' Identifier Arguments | 4758 // '%' Identifier Arguments |
| 4771 | 4759 |
| 4772 int pos = peek_position(); | 4760 int pos = peek_position(); |
| 4773 Expect(Token::MOD, CHECK_OK); | 4761 Expect(Token::MOD, CHECK_OK); |
| 4774 // Allow "eval" or "arguments" for backward compatibility. | 4762 // Allow "eval" or "arguments" for backward compatibility. |
| 4775 const AstRawString* name = ParseIdentifier(kAllowRestrictedIdentifiers, | 4763 const AstRawString* name = ParseIdentifier(kAllowRestrictedIdentifiers, |
| 4776 CHECK_OK); | 4764 CHECK_OK); |
| 4777 Scanner::Location spread_pos; | 4765 Scanner::Location spread_pos; |
| 4778 ExpressionClassifier classifier(this); | 4766 ExpressionClassifier classifier(this); |
| 4779 ZoneList<Expression*>* args = | 4767 ZoneList<Expression*>* args = ParseArguments(&spread_pos, CHECK_OK); |
| 4780 ParseArguments(&spread_pos, &classifier, CHECK_OK); | |
| 4781 | 4768 |
| 4782 DCHECK(!spread_pos.IsValid()); | 4769 DCHECK(!spread_pos.IsValid()); |
| 4783 | 4770 |
| 4784 if (extension_ != NULL) { | 4771 if (extension_ != NULL) { |
| 4785 // The extension structures are only accessible while parsing the | 4772 // The extension structures are only accessible while parsing the |
| 4786 // very first time not when reparsing because of lazy compilation. | 4773 // very first time not when reparsing because of lazy compilation. |
| 4787 GetClosureScope()->ForceEagerCompilation(); | 4774 GetClosureScope()->ForceEagerCompilation(); |
| 4788 } | 4775 } |
| 4789 | 4776 |
| 4790 const Runtime::Function* function = Runtime::FunctionForName(name->string()); | 4777 const Runtime::Function* function = Runtime::FunctionForName(name->string()); |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5489 | 5476 |
| 5490 void VisitObjectLiteralProperty(ObjectLiteralProperty* property) override { | 5477 void VisitObjectLiteralProperty(ObjectLiteralProperty* property) override { |
| 5491 if (property == nullptr) return; | 5478 if (property == nullptr) return; |
| 5492 // Do not rewrite (computed) key expressions | 5479 // Do not rewrite (computed) key expressions |
| 5493 AST_REWRITE_PROPERTY(Expression, property, value); | 5480 AST_REWRITE_PROPERTY(Expression, property, value); |
| 5494 } | 5481 } |
| 5495 | 5482 |
| 5496 Parser* parser_; | 5483 Parser* parser_; |
| 5497 }; | 5484 }; |
| 5498 | 5485 |
| 5499 | 5486 void Parser::RewriteNonPattern(bool* ok) { |
| 5500 void Parser::RewriteNonPattern(ExpressionClassifier* classifier, bool* ok) { | 5487 ValidateExpression(CHECK_OK_VOID); |
| 5501 ValidateExpression(classifier, CHECK_OK_VOID); | |
| 5502 auto non_patterns_to_rewrite = function_state_->non_patterns_to_rewrite(); | 5488 auto non_patterns_to_rewrite = function_state_->non_patterns_to_rewrite(); |
| 5503 int begin = classifier->GetNonPatternBegin(); | 5489 int begin = classifier()->GetNonPatternBegin(); |
| 5504 int end = non_patterns_to_rewrite->length(); | 5490 int end = non_patterns_to_rewrite->length(); |
| 5505 if (begin < end) { | 5491 if (begin < end) { |
| 5506 NonPatternRewriter rewriter(stack_limit_, this); | 5492 NonPatternRewriter rewriter(stack_limit_, this); |
| 5507 for (int i = begin; i < end; i++) { | 5493 for (int i = begin; i < end; i++) { |
| 5508 DCHECK(non_patterns_to_rewrite->at(i)->IsRewritableExpression()); | 5494 DCHECK(non_patterns_to_rewrite->at(i)->IsRewritableExpression()); |
| 5509 rewriter.Rewrite(non_patterns_to_rewrite->at(i)); | 5495 rewriter.Rewrite(non_patterns_to_rewrite->at(i)); |
| 5510 } | 5496 } |
| 5511 non_patterns_to_rewrite->Rewind(begin); | 5497 non_patterns_to_rewrite->Rewind(begin); |
| 5512 } | 5498 } |
| 5513 } | 5499 } |
| (...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6648 node->Print(Isolate::Current()); | 6634 node->Print(Isolate::Current()); |
| 6649 } | 6635 } |
| 6650 #endif // DEBUG | 6636 #endif // DEBUG |
| 6651 | 6637 |
| 6652 #undef CHECK_OK | 6638 #undef CHECK_OK |
| 6653 #undef CHECK_OK_VOID | 6639 #undef CHECK_OK_VOID |
| 6654 #undef CHECK_FAILED | 6640 #undef CHECK_FAILED |
| 6655 | 6641 |
| 6656 } // namespace internal | 6642 } // namespace internal |
| 6657 } // namespace v8 | 6643 } // namespace v8 |
| OLD | NEW |