| 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 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 // These two bits only need to be explicitly set because we're | 874 // These two bits only need to be explicitly set because we're |
| 875 // not passing the ScopeInfo to the Scope constructor. | 875 // not passing the ScopeInfo to the Scope constructor. |
| 876 // TODO(adamk): Remove these calls once the above NewScope call | 876 // TODO(adamk): Remove these calls once the above NewScope call |
| 877 // passes the ScopeInfo. | 877 // passes the ScopeInfo. |
| 878 if (info->calls_eval()) { | 878 if (info->calls_eval()) { |
| 879 scope->RecordEvalCall(); | 879 scope->RecordEvalCall(); |
| 880 } | 880 } |
| 881 SetLanguageMode(scope, info->language_mode()); | 881 SetLanguageMode(scope, info->language_mode()); |
| 882 | 882 |
| 883 scope->set_start_position(info->start_position()); | 883 scope->set_start_position(info->start_position()); |
| 884 ExpressionClassifier formals_classifier(this); | 884 ExpressionClassifierWrapper wrap_formals_classifier(this); |
| 885 ParserFormalParameters formals(scope); | 885 ParserFormalParameters formals(scope); |
| 886 Checkpoint checkpoint(this); | 886 Checkpoint checkpoint(this); |
| 887 { | 887 { |
| 888 // Parsing patterns as variable reference expression creates | 888 // Parsing patterns as variable reference expression creates |
| 889 // NewUnresolved references in current scope. Entrer arrow function | 889 // NewUnresolved references in current scope. Entrer arrow function |
| 890 // scope for formal parameter parsing. | 890 // scope for formal parameter parsing. |
| 891 BlockState block_state(&scope_state_, scope); | 891 BlockState block_state(&scope_state_, scope); |
| 892 if (Check(Token::LPAREN)) { | 892 if (Check(Token::LPAREN)) { |
| 893 // '(' StrictFormalParameters ')' | 893 // '(' StrictFormalParameters ')' |
| 894 ParseFormalParameterList(&formals, &formals_classifier, &ok); | 894 ParseFormalParameterList(&formals, &ok); |
| 895 if (ok) ok = Check(Token::RPAREN); | 895 if (ok) ok = Check(Token::RPAREN); |
| 896 } else { | 896 } else { |
| 897 // BindingIdentifier | 897 // BindingIdentifier |
| 898 ParseFormalParameter(&formals, &formals_classifier, &ok); | 898 ParseFormalParameter(&formals, &ok); |
| 899 if (ok) { | 899 if (ok) DeclareFormalParameter(formals.scope, formals.at(0)); |
| 900 DeclareFormalParameter(formals.scope, formals.at(0), | |
| 901 &formals_classifier); | |
| 902 } | |
| 903 } | 900 } |
| 904 } | 901 } |
| 905 | 902 |
| 906 if (ok) { | 903 if (ok) { |
| 907 checkpoint.Restore(&formals.materialized_literals_count); | 904 checkpoint.Restore(&formals.materialized_literals_count); |
| 908 // Pass `accept_IN=true` to ParseArrowFunctionLiteral --- This should | 905 // Pass `accept_IN=true` to ParseArrowFunctionLiteral --- This should |
| 909 // not be observable, or else the preparser would have failed. | 906 // not be observable, or else the preparser would have failed. |
| 910 Expression* expression = ParseArrowFunctionLiteral( | 907 Expression* expression = |
| 911 true, formals, is_async, formals_classifier, &ok); | 908 ParseArrowFunctionLiteral(true, formals, is_async, &ok); |
| 912 if (ok) { | 909 if (ok) { |
| 913 // Scanning must end at the same position that was recorded | 910 // Scanning must end at the same position that was recorded |
| 914 // previously. If not, parsing has been interrupted due to a stack | 911 // previously. If not, parsing has been interrupted due to a stack |
| 915 // overflow, at which point the partially parsed arrow function | 912 // overflow, at which point the partially parsed arrow function |
| 916 // concise body happens to be a valid expression. This is a problem | 913 // concise body happens to be a valid expression. This is a problem |
| 917 // only for arrow functions with single expression bodies, since there | 914 // only for arrow functions with single expression bodies, since there |
| 918 // is no end token such as "}" for normal functions. | 915 // is no end token such as "}" for normal functions. |
| 919 if (scanner()->location().end_pos == info->end_position()) { | 916 if (scanner()->location().end_pos == info->end_position()) { |
| 920 // The pre-parser saw an arrow function here, so the full parser | 917 // The pre-parser saw an arrow function here, so the full parser |
| 921 // must produce a FunctionLiteral. | 918 // must produce a FunctionLiteral. |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1347 if (allow_harmony_async_await() && PeekAhead() == Token::FUNCTION && | 1344 if (allow_harmony_async_await() && PeekAhead() == Token::FUNCTION && |
| 1348 !scanner()->HasAnyLineTerminatorAfterNext()) { | 1345 !scanner()->HasAnyLineTerminatorAfterNext()) { |
| 1349 Consume(Token::ASYNC); | 1346 Consume(Token::ASYNC); |
| 1350 result = ParseAsyncFunctionDeclaration(&local_names, true, CHECK_OK); | 1347 result = ParseAsyncFunctionDeclaration(&local_names, true, CHECK_OK); |
| 1351 break; | 1348 break; |
| 1352 } | 1349 } |
| 1353 /* falls through */ | 1350 /* falls through */ |
| 1354 | 1351 |
| 1355 default: { | 1352 default: { |
| 1356 int pos = position(); | 1353 int pos = position(); |
| 1357 ExpressionClassifier classifier(this); | 1354 ExpressionClassifierWrapper wrap_classifier(this); |
| 1358 Expression* value = | 1355 Expression* value = ParseAssignmentExpression(true, CHECK_OK); |
| 1359 ParseAssignmentExpression(true, &classifier, CHECK_OK); | 1356 RewriteNonPattern(CHECK_OK); |
| 1360 RewriteNonPattern(&classifier, CHECK_OK); | |
| 1361 SetFunctionName(value, ast_value_factory()->default_string()); | 1357 SetFunctionName(value, ast_value_factory()->default_string()); |
| 1362 | 1358 |
| 1363 const AstRawString* local_name = | 1359 const AstRawString* local_name = |
| 1364 ast_value_factory()->star_default_star_string(); | 1360 ast_value_factory()->star_default_star_string(); |
| 1365 local_names.Add(local_name, zone()); | 1361 local_names.Add(local_name, zone()); |
| 1366 | 1362 |
| 1367 // It's fine to declare this as CONST because the user has no way of | 1363 // It's fine to declare this as CONST because the user has no way of |
| 1368 // writing to it. | 1364 // writing to it. |
| 1369 Declaration* decl = DeclareVariable(local_name, CONST, pos, CHECK_OK); | 1365 Declaration* decl = DeclareVariable(local_name, CONST, pos, CHECK_OK); |
| 1370 decl->proxy()->var()->set_initializer_position(position()); | 1366 decl->proxy()->var()->set_initializer_position(position()); |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1940 const AstRawString* variable_name; | 1936 const AstRawString* variable_name; |
| 1941 if (default_export && (peek() == Token::EXTENDS || peek() == Token::LBRACE)) { | 1937 if (default_export && (peek() == Token::EXTENDS || peek() == Token::LBRACE)) { |
| 1942 name = ast_value_factory()->default_string(); | 1938 name = ast_value_factory()->default_string(); |
| 1943 is_strict_reserved = false; | 1939 is_strict_reserved = false; |
| 1944 variable_name = ast_value_factory()->star_default_star_string(); | 1940 variable_name = ast_value_factory()->star_default_star_string(); |
| 1945 } else { | 1941 } else { |
| 1946 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); | 1942 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); |
| 1947 variable_name = name; | 1943 variable_name = name; |
| 1948 } | 1944 } |
| 1949 | 1945 |
| 1950 Expression* value = ParseClassLiteral(nullptr, name, scanner()->location(), | 1946 ExpressionClassifierWrapper wrap_no_classifier(this, nullptr, false); |
| 1947 Expression* value = ParseClassLiteral(name, scanner()->location(), |
| 1951 is_strict_reserved, pos, CHECK_OK); | 1948 is_strict_reserved, pos, CHECK_OK); |
| 1952 | 1949 |
| 1953 Declaration* decl = DeclareVariable(variable_name, LET, pos, CHECK_OK); | 1950 Declaration* decl = DeclareVariable(variable_name, LET, pos, CHECK_OK); |
| 1954 decl->proxy()->var()->set_initializer_position(position()); | 1951 decl->proxy()->var()->set_initializer_position(position()); |
| 1955 Assignment* assignment = | 1952 Assignment* assignment = |
| 1956 factory()->NewAssignment(Token::INIT, decl->proxy(), value, pos); | 1953 factory()->NewAssignment(Token::INIT, decl->proxy(), value, pos); |
| 1957 Statement* assignment_statement = | 1954 Statement* assignment_statement = |
| 1958 factory()->NewExpressionStatement(assignment, kNoSourcePosition); | 1955 factory()->NewExpressionStatement(assignment, kNoSourcePosition); |
| 1959 if (names) names->Add(variable_name, zone()); | 1956 if (names) names->Add(variable_name, zone()); |
| 1960 return assignment_statement; | 1957 return assignment_statement; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2080 int bindings_start = peek_position(); | 2077 int bindings_start = peek_position(); |
| 2081 do { | 2078 do { |
| 2082 FuncNameInferrer::State fni_state(fni_); | 2079 FuncNameInferrer::State fni_state(fni_); |
| 2083 | 2080 |
| 2084 // Parse name. | 2081 // Parse name. |
| 2085 if (!first_declaration) Consume(Token::COMMA); | 2082 if (!first_declaration) Consume(Token::COMMA); |
| 2086 | 2083 |
| 2087 Expression* pattern; | 2084 Expression* pattern; |
| 2088 int decl_pos = peek_position(); | 2085 int decl_pos = peek_position(); |
| 2089 { | 2086 { |
| 2090 ExpressionClassifier pattern_classifier(this); | 2087 ExpressionClassifierWrapper wrap_pattern_classifier(this); |
| 2091 pattern = ParsePrimaryExpression(&pattern_classifier, CHECK_OK); | 2088 pattern = ParsePrimaryExpression(CHECK_OK); |
| 2092 ValidateBindingPattern(&pattern_classifier, CHECK_OK); | 2089 ValidateBindingPattern(CHECK_OK); |
| 2093 if (IsLexicalVariableMode(parsing_result->descriptor.mode)) { | 2090 if (IsLexicalVariableMode(parsing_result->descriptor.mode)) { |
| 2094 ValidateLetPattern(&pattern_classifier, CHECK_OK); | 2091 ValidateLetPattern(CHECK_OK); |
| 2095 } | 2092 } |
| 2096 } | 2093 } |
| 2097 | 2094 |
| 2098 Scanner::Location variable_loc = scanner()->location(); | 2095 Scanner::Location variable_loc = scanner()->location(); |
| 2099 const AstRawString* single_name = | 2096 const AstRawString* single_name = |
| 2100 pattern->IsVariableProxy() ? pattern->AsVariableProxy()->raw_name() | 2097 pattern->IsVariableProxy() ? pattern->AsVariableProxy()->raw_name() |
| 2101 : nullptr; | 2098 : nullptr; |
| 2102 if (single_name != nullptr) { | 2099 if (single_name != nullptr) { |
| 2103 if (fni_ != NULL) fni_->PushVariableName(single_name); | 2100 if (fni_ != NULL) fni_->PushVariableName(single_name); |
| 2104 } | 2101 } |
| 2105 | 2102 |
| 2106 Expression* value = NULL; | 2103 Expression* value = NULL; |
| 2107 int initializer_position = kNoSourcePosition; | 2104 int initializer_position = kNoSourcePosition; |
| 2108 if (Check(Token::ASSIGN)) { | 2105 if (Check(Token::ASSIGN)) { |
| 2109 ExpressionClassifier classifier(this); | 2106 ExpressionClassifierWrapper wrap_classifier(this); |
| 2110 value = ParseAssignmentExpression(var_context != kForStatement, | 2107 value = ParseAssignmentExpression(var_context != kForStatement, CHECK_OK); |
| 2111 &classifier, CHECK_OK); | 2108 RewriteNonPattern(CHECK_OK); |
| 2112 RewriteNonPattern(&classifier, CHECK_OK); | |
| 2113 variable_loc.end_pos = scanner()->location().end_pos; | 2109 variable_loc.end_pos = scanner()->location().end_pos; |
| 2114 | 2110 |
| 2115 if (!parsing_result->first_initializer_loc.IsValid()) { | 2111 if (!parsing_result->first_initializer_loc.IsValid()) { |
| 2116 parsing_result->first_initializer_loc = variable_loc; | 2112 parsing_result->first_initializer_loc = variable_loc; |
| 2117 } | 2113 } |
| 2118 | 2114 |
| 2119 // Don't infer if it is "a = function(){...}();"-like expression. | 2115 // Don't infer if it is "a = function(){...}();"-like expression. |
| 2120 if (single_name) { | 2116 if (single_name) { |
| 2121 if (fni_ != NULL && value->AsCall() == NULL && | 2117 if (fni_ != NULL && value->AsCall() == NULL && |
| 2122 value->AsCallNew() == NULL) { | 2118 value->AsCallNew() == NULL) { |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2695 { | 2691 { |
| 2696 BlockState block_state(&scope_state_); | 2692 BlockState block_state(&scope_state_); |
| 2697 block_state.set_start_position(scanner()->location().beg_pos); | 2693 block_state.set_start_position(scanner()->location().beg_pos); |
| 2698 Target target(&this->target_stack_, catch_block); | 2694 Target target(&this->target_stack_, catch_block); |
| 2699 | 2695 |
| 2700 const AstRawString* name = ast_value_factory()->dot_catch_string(); | 2696 const AstRawString* name = ast_value_factory()->dot_catch_string(); |
| 2701 Expression* pattern = nullptr; | 2697 Expression* pattern = nullptr; |
| 2702 if (peek_any_identifier()) { | 2698 if (peek_any_identifier()) { |
| 2703 name = ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK); | 2699 name = ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK); |
| 2704 } else { | 2700 } else { |
| 2705 ExpressionClassifier pattern_classifier(this); | 2701 ExpressionClassifierWrapper wrap_pattern_classifier(this); |
| 2706 pattern = ParsePrimaryExpression(&pattern_classifier, CHECK_OK); | 2702 pattern = ParsePrimaryExpression(CHECK_OK); |
| 2707 ValidateBindingPattern(&pattern_classifier, CHECK_OK); | 2703 ValidateBindingPattern(CHECK_OK); |
| 2708 } | 2704 } |
| 2709 catch_variable = catch_scope->DeclareLocal( | 2705 catch_variable = catch_scope->DeclareLocal( |
| 2710 name, VAR, kCreatedInitialized, Variable::NORMAL); | 2706 name, VAR, kCreatedInitialized, Variable::NORMAL); |
| 2711 | 2707 |
| 2712 Expect(Token::RPAREN, CHECK_OK); | 2708 Expect(Token::RPAREN, CHECK_OK); |
| 2713 | 2709 |
| 2714 ZoneList<const AstRawString*> bound_names(1, zone()); | 2710 ZoneList<const AstRawString*> bound_names(1, zone()); |
| 2715 if (pattern != nullptr) { | 2711 if (pattern != nullptr) { |
| 2716 DeclarationDescriptor descriptor; | 2712 DeclarationDescriptor descriptor; |
| 2717 descriptor.declaration_kind = DeclarationDescriptor::NORMAL; | 2713 descriptor.declaration_kind = DeclarationDescriptor::NORMAL; |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3419 | 3415 |
| 3420 Variable* temp = NewTemporary(ast_value_factory()->dot_for_string()); | 3416 Variable* temp = NewTemporary(ast_value_factory()->dot_for_string()); |
| 3421 ForEachStatement* loop = | 3417 ForEachStatement* loop = |
| 3422 factory()->NewForEachStatement(mode, labels, stmt_pos); | 3418 factory()->NewForEachStatement(mode, labels, stmt_pos); |
| 3423 Target target(&this->target_stack_, loop); | 3419 Target target(&this->target_stack_, loop); |
| 3424 | 3420 |
| 3425 int each_keyword_position = scanner()->location().beg_pos; | 3421 int each_keyword_position = scanner()->location().beg_pos; |
| 3426 | 3422 |
| 3427 Expression* enumerable; | 3423 Expression* enumerable; |
| 3428 if (mode == ForEachStatement::ITERATE) { | 3424 if (mode == ForEachStatement::ITERATE) { |
| 3429 ExpressionClassifier classifier(this); | 3425 ExpressionClassifierWrapper wrap_classifier(this); |
| 3430 enumerable = ParseAssignmentExpression(true, &classifier, CHECK_OK); | 3426 enumerable = ParseAssignmentExpression(true, CHECK_OK); |
| 3431 RewriteNonPattern(&classifier, CHECK_OK); | 3427 RewriteNonPattern(CHECK_OK); |
| 3432 } else { | 3428 } else { |
| 3433 enumerable = ParseExpression(true, CHECK_OK); | 3429 enumerable = ParseExpression(true, CHECK_OK); |
| 3434 } | 3430 } |
| 3435 | 3431 |
| 3436 Expect(Token::RPAREN, CHECK_OK); | 3432 Expect(Token::RPAREN, CHECK_OK); |
| 3437 | 3433 |
| 3438 | 3434 |
| 3439 Block* body_block = | 3435 Block* body_block = |
| 3440 factory()->NewBlock(NULL, 3, false, kNoSourcePosition); | 3436 factory()->NewBlock(NULL, 3, false, kNoSourcePosition); |
| 3441 | 3437 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3534 return final_loop; | 3530 return final_loop; |
| 3535 } | 3531 } |
| 3536 } else { | 3532 } else { |
| 3537 bound_names_are_lexical = | 3533 bound_names_are_lexical = |
| 3538 IsLexicalVariableMode(parsing_result.descriptor.mode); | 3534 IsLexicalVariableMode(parsing_result.descriptor.mode); |
| 3539 init = parsing_result.BuildInitializationBlock( | 3535 init = parsing_result.BuildInitializationBlock( |
| 3540 bound_names_are_lexical ? &bound_names : nullptr, CHECK_OK); | 3536 bound_names_are_lexical ? &bound_names : nullptr, CHECK_OK); |
| 3541 } | 3537 } |
| 3542 } else { | 3538 } else { |
| 3543 int lhs_beg_pos = peek_position(); | 3539 int lhs_beg_pos = peek_position(); |
| 3544 ExpressionClassifier classifier(this); | 3540 ExpressionClassifierWrapper wrap_classifier(this); |
| 3545 Expression* expression = ParseExpression(false, &classifier, CHECK_OK); | 3541 Expression* expression = ParseExpressionNoWrap(false, CHECK_OK); |
| 3546 int lhs_end_pos = scanner()->location().end_pos; | 3542 int lhs_end_pos = scanner()->location().end_pos; |
| 3547 ForEachStatement::VisitMode mode = ForEachStatement::ENUMERATE; | 3543 ForEachStatement::VisitMode mode = ForEachStatement::ENUMERATE; |
| 3548 | 3544 |
| 3549 bool is_for_each = CheckInOrOf(&mode, CHECK_OK); | 3545 bool is_for_each = CheckInOrOf(&mode, CHECK_OK); |
| 3550 bool is_destructuring = is_for_each && (expression->IsArrayLiteral() || | 3546 bool is_destructuring = is_for_each && (expression->IsArrayLiteral() || |
| 3551 expression->IsObjectLiteral()); | 3547 expression->IsObjectLiteral()); |
| 3552 | 3548 |
| 3553 if (is_destructuring) { | 3549 if (is_destructuring) { |
| 3554 ValidateAssignmentPattern(&classifier, CHECK_OK); | 3550 ValidateAssignmentPattern(CHECK_OK); |
| 3555 } else { | 3551 } else { |
| 3556 RewriteNonPattern(&classifier, CHECK_OK); | 3552 RewriteNonPattern(CHECK_OK); |
| 3557 } | 3553 } |
| 3558 | 3554 |
| 3559 if (is_for_each) { | 3555 if (is_for_each) { |
| 3560 if (!is_destructuring) { | 3556 if (!is_destructuring) { |
| 3561 expression = CheckAndRewriteReferenceExpression( | 3557 expression = CheckAndRewriteReferenceExpression( |
| 3562 expression, lhs_beg_pos, lhs_end_pos, | 3558 expression, lhs_beg_pos, lhs_end_pos, |
| 3563 MessageTemplate::kInvalidLhsInFor, kSyntaxError, CHECK_OK); | 3559 MessageTemplate::kInvalidLhsInFor, kSyntaxError, CHECK_OK); |
| 3564 } | 3560 } |
| 3565 | 3561 |
| 3566 ForEachStatement* loop = | 3562 ForEachStatement* loop = |
| 3567 factory()->NewForEachStatement(mode, labels, stmt_pos); | 3563 factory()->NewForEachStatement(mode, labels, stmt_pos); |
| 3568 Target target(&this->target_stack_, loop); | 3564 Target target(&this->target_stack_, loop); |
| 3569 | 3565 |
| 3570 int each_keyword_position = scanner()->location().beg_pos; | 3566 int each_keyword_position = scanner()->location().beg_pos; |
| 3571 | 3567 |
| 3572 Expression* enumerable; | 3568 Expression* enumerable; |
| 3573 if (mode == ForEachStatement::ITERATE) { | 3569 if (mode == ForEachStatement::ITERATE) { |
| 3574 ExpressionClassifier classifier(this); | 3570 ExpressionClassifierWrapper wrap_classifier(this); |
| 3575 enumerable = ParseAssignmentExpression(true, &classifier, CHECK_OK); | 3571 enumerable = ParseAssignmentExpression(true, CHECK_OK); |
| 3576 RewriteNonPattern(&classifier, CHECK_OK); | 3572 RewriteNonPattern(CHECK_OK); |
| 3577 } else { | 3573 } else { |
| 3578 enumerable = ParseExpression(true, CHECK_OK); | 3574 enumerable = ParseExpression(true, CHECK_OK); |
| 3579 } | 3575 } |
| 3580 | 3576 |
| 3581 Expect(Token::RPAREN, CHECK_OK); | 3577 Expect(Token::RPAREN, CHECK_OK); |
| 3582 | 3578 |
| 3583 // For legacy compat reasons, give for loops similar treatment to | 3579 // For legacy compat reasons, give for loops similar treatment to |
| 3584 // if statements in allowing a function declaration for a body | 3580 // if statements in allowing a function declaration for a body |
| 3585 Statement* body = ParseScopedStatement(NULL, true, CHECK_OK); | 3581 Statement* body = ParseScopedStatement(NULL, true, CHECK_OK); |
| 3586 Statement* final_loop = InitializeForEachStatement( | 3582 Statement* final_loop = InitializeForEachStatement( |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3780 DCHECK(!assignment->is_compound()); | 3776 DCHECK(!assignment->is_compound()); |
| 3781 initializer = assignment->value(); | 3777 initializer = assignment->value(); |
| 3782 expr = assignment->target(); | 3778 expr = assignment->target(); |
| 3783 } | 3779 } |
| 3784 | 3780 |
| 3785 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest); | 3781 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest); |
| 3786 } | 3782 } |
| 3787 | 3783 |
| 3788 void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name, | 3784 void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name, |
| 3789 Scope* scope, ZoneList<Statement*>* body, | 3785 Scope* scope, ZoneList<Statement*>* body, |
| 3790 ExpressionClassifier* classifier, | |
| 3791 FunctionKind kind, | 3786 FunctionKind kind, |
| 3792 FunctionBodyType body_type, | 3787 FunctionBodyType body_type, |
| 3793 bool accept_IN, int pos, bool* ok) { | 3788 bool accept_IN, int pos, bool* ok) { |
| 3794 // function async_function() { | 3789 // function async_function() { |
| 3795 // .generator_object = %CreateGeneratorObject(); | 3790 // .generator_object = %CreateGeneratorObject(); |
| 3796 // BuildRejectPromiseOnException({ | 3791 // BuildRejectPromiseOnException({ |
| 3797 // ... function body ... | 3792 // ... function body ... |
| 3798 // return %ResolvePromise(.promise, expr), .promise; | 3793 // return %ResolvePromise(.promise, expr), .promise; |
| 3799 // }) | 3794 // }) |
| 3800 // } | 3795 // } |
| 3801 scope->ForceContextAllocation(); | 3796 scope->ForceContextAllocation(); |
| 3802 Variable* temp = | 3797 Variable* temp = |
| 3803 NewTemporary(ast_value_factory()->dot_generator_object_string()); | 3798 NewTemporary(ast_value_factory()->dot_generator_object_string()); |
| 3804 function_state_->set_generator_object_variable(temp); | 3799 function_state_->set_generator_object_variable(temp); |
| 3805 | 3800 |
| 3806 Expression* init_generator_variable = factory()->NewAssignment( | 3801 Expression* init_generator_variable = factory()->NewAssignment( |
| 3807 Token::INIT, factory()->NewVariableProxy(temp), | 3802 Token::INIT, factory()->NewVariableProxy(temp), |
| 3808 BuildCreateJSGeneratorObject(pos, kind), kNoSourcePosition); | 3803 BuildCreateJSGeneratorObject(pos, kind), kNoSourcePosition); |
| 3809 body->Add(factory()->NewExpressionStatement(init_generator_variable, | 3804 body->Add(factory()->NewExpressionStatement(init_generator_variable, |
| 3810 kNoSourcePosition), | 3805 kNoSourcePosition), |
| 3811 zone()); | 3806 zone()); |
| 3812 | 3807 |
| 3813 Block* block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition); | 3808 Block* block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition); |
| 3814 | 3809 |
| 3815 Expression* return_value = nullptr; | 3810 Expression* return_value = nullptr; |
| 3816 if (body_type == FunctionBodyType::kNormal) { | 3811 if (body_type == FunctionBodyType::kNormal) { |
| 3817 ParseStatementList(block->statements(), Token::RBRACE, CHECK_OK_VOID); | 3812 ParseStatementList(block->statements(), Token::RBRACE, CHECK_OK_VOID); |
| 3818 return_value = factory()->NewUndefinedLiteral(kNoSourcePosition); | 3813 return_value = factory()->NewUndefinedLiteral(kNoSourcePosition); |
| 3819 } else { | 3814 } else { |
| 3820 return_value = | 3815 return_value = ParseAssignmentExpression(accept_IN, CHECK_OK_VOID); |
| 3821 ParseAssignmentExpression(accept_IN, classifier, CHECK_OK_VOID); | 3816 RewriteNonPattern(CHECK_OK_VOID); |
| 3822 RewriteNonPattern(classifier, CHECK_OK_VOID); | |
| 3823 } | 3817 } |
| 3824 | 3818 |
| 3825 return_value = BuildResolvePromise(return_value, return_value->position()); | 3819 return_value = BuildResolvePromise(return_value, return_value->position()); |
| 3826 block->statements()->Add( | 3820 block->statements()->Add( |
| 3827 factory()->NewReturnStatement(return_value, return_value->position()), | 3821 factory()->NewReturnStatement(return_value, return_value->position()), |
| 3828 zone()); | 3822 zone()); |
| 3829 block = BuildRejectPromiseOnException(block, CHECK_OK_VOID); | 3823 block = BuildRejectPromiseOnException(block, CHECK_OK_VOID); |
| 3830 body->Add(block, zone()); | 3824 body->Add(block, zone()); |
| 3831 scope->set_end_position(scanner()->location().end_pos); | 3825 scope->set_end_position(scanner()->location().end_pos); |
| 3832 } | 3826 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3857 CHECK_OK_VOID); | 3851 CHECK_OK_VOID); |
| 3858 | 3852 |
| 3859 scope_snapshot.Reparent(parameters->scope); | 3853 scope_snapshot.Reparent(parameters->scope); |
| 3860 | 3854 |
| 3861 if (parameters->Arity() > Code::kMaxArguments) { | 3855 if (parameters->Arity() > Code::kMaxArguments) { |
| 3862 ReportMessageAt(params_loc, MessageTemplate::kMalformedArrowFunParamList); | 3856 ReportMessageAt(params_loc, MessageTemplate::kMalformedArrowFunParamList); |
| 3863 *ok = false; | 3857 *ok = false; |
| 3864 return; | 3858 return; |
| 3865 } | 3859 } |
| 3866 | 3860 |
| 3867 ExpressionClassifier classifier(this); | 3861 ExpressionClassifierWrapper wrap_classifier(this); |
| 3868 if (!parameters->is_simple) { | 3862 if (!parameters->is_simple) { |
| 3869 classifier.RecordNonSimpleParameter(); | 3863 classifier()->RecordNonSimpleParameter(); |
| 3870 } | 3864 } |
| 3871 for (int i = 0; i < parameters->Arity(); ++i) { | 3865 for (int i = 0; i < parameters->Arity(); ++i) { |
| 3872 auto parameter = parameters->at(i); | 3866 auto parameter = parameters->at(i); |
| 3873 DeclareFormalParameter(parameters->scope, parameter, &classifier); | 3867 DeclareFormalParameter(parameters->scope, parameter); |
| 3874 if (!duplicate_loc->IsValid()) { | 3868 if (!duplicate_loc->IsValid()) { |
| 3875 *duplicate_loc = classifier.duplicate_formal_parameter_error().location; | 3869 *duplicate_loc = |
| 3870 classifier()->duplicate_formal_parameter_error().location; |
| 3876 } | 3871 } |
| 3877 } | 3872 } |
| 3878 DCHECK_EQ(parameters->is_simple, parameters->scope->has_simple_parameters()); | 3873 DCHECK_EQ(parameters->is_simple, parameters->scope->has_simple_parameters()); |
| 3879 } | 3874 } |
| 3880 | 3875 |
| 3881 void Parser::ReindexLiterals(const ParserFormalParameters& parameters) { | 3876 void Parser::ReindexLiterals(const ParserFormalParameters& parameters) { |
| 3882 if (function_state_->materialized_literal_count() > 0) { | 3877 if (function_state_->materialized_literal_count() > 0) { |
| 3883 AstLiteralReindexer reindexer; | 3878 AstLiteralReindexer reindexer; |
| 3884 | 3879 |
| 3885 for (const auto p : parameters.params) { | 3880 for (const auto p : parameters.params) { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4019 if (!use_temp_zone) { | 4014 if (!use_temp_zone) { |
| 4020 main_scope = scope; | 4015 main_scope = scope; |
| 4021 } else { | 4016 } else { |
| 4022 DCHECK(main_scope->zone() != scope->zone()); | 4017 DCHECK(main_scope->zone() != scope->zone()); |
| 4023 } | 4018 } |
| 4024 | 4019 |
| 4025 FunctionState function_state(&function_state_, &scope_state_, scope, kind); | 4020 FunctionState function_state(&function_state_, &scope_state_, scope, kind); |
| 4026 #ifdef DEBUG | 4021 #ifdef DEBUG |
| 4027 scope->SetScopeName(function_name); | 4022 scope->SetScopeName(function_name); |
| 4028 #endif | 4023 #endif |
| 4029 ExpressionClassifier formals_classifier(this, &duplicate_finder); | 4024 ExpressionClassifierWrapper wrap_formals_classifier(this, |
| 4025 &duplicate_finder); |
| 4030 | 4026 |
| 4031 if (is_generator) { | 4027 if (is_generator) { |
| 4032 // For generators, allocating variables in contexts is currently a win | 4028 // For generators, allocating variables in contexts is currently a win |
| 4033 // because it minimizes the work needed to suspend and resume an | 4029 // because it minimizes the work needed to suspend and resume an |
| 4034 // activation. The machine code produced for generators (by full-codegen) | 4030 // activation. The machine code produced for generators (by full-codegen) |
| 4035 // relies on this forced context allocation, but not in an essential way. | 4031 // relies on this forced context allocation, but not in an essential way. |
| 4036 this->scope()->ForceContextAllocation(); | 4032 this->scope()->ForceContextAllocation(); |
| 4037 | 4033 |
| 4038 // Calling a generator returns a generator object. That object is stored | 4034 // Calling a generator returns a generator object. That object is stored |
| 4039 // in a temporary variable, a definition that is used by "yield" | 4035 // in a temporary variable, a definition that is used by "yield" |
| 4040 // expressions. This also marks the FunctionState as a generator. | 4036 // expressions. This also marks the FunctionState as a generator. |
| 4041 Variable* temp = | 4037 Variable* temp = |
| 4042 NewTemporary(ast_value_factory()->dot_generator_object_string()); | 4038 NewTemporary(ast_value_factory()->dot_generator_object_string()); |
| 4043 function_state.set_generator_object_variable(temp); | 4039 function_state.set_generator_object_variable(temp); |
| 4044 } | 4040 } |
| 4045 | 4041 |
| 4046 Expect(Token::LPAREN, CHECK_OK); | 4042 Expect(Token::LPAREN, CHECK_OK); |
| 4047 int start_position = scanner()->location().beg_pos; | 4043 int start_position = scanner()->location().beg_pos; |
| 4048 this->scope()->set_start_position(start_position); | 4044 this->scope()->set_start_position(start_position); |
| 4049 ParserFormalParameters formals(scope); | 4045 ParserFormalParameters formals(scope); |
| 4050 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); | 4046 ParseFormalParameterList(&formals, CHECK_OK); |
| 4051 arity = formals.Arity(); | 4047 arity = formals.Arity(); |
| 4052 Expect(Token::RPAREN, CHECK_OK); | 4048 Expect(Token::RPAREN, CHECK_OK); |
| 4053 int formals_end_position = scanner()->location().end_pos; | 4049 int formals_end_position = scanner()->location().end_pos; |
| 4054 | 4050 |
| 4055 CheckArityRestrictions(arity, kind, formals.has_rest, start_position, | 4051 CheckArityRestrictions(arity, kind, formals.has_rest, start_position, |
| 4056 formals_end_position, CHECK_OK); | 4052 formals_end_position, CHECK_OK); |
| 4057 Expect(Token::LBRACE, CHECK_OK); | 4053 Expect(Token::LBRACE, CHECK_OK); |
| 4058 // Don't include the rest parameter into the function's formal parameter | 4054 // Don't include the rest parameter into the function's formal parameter |
| 4059 // count (esp. the SharedFunctionInfo::internal_formal_parameter_count, | 4055 // count (esp. the SharedFunctionInfo::internal_formal_parameter_count, |
| 4060 // which says whether we need to create an arguments adaptor frame). | 4056 // which says whether we need to create an arguments adaptor frame). |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4102 | 4098 |
| 4103 // Parsing the body may change the language mode in our scope. | 4099 // Parsing the body may change the language mode in our scope. |
| 4104 language_mode = scope->language_mode(); | 4100 language_mode = scope->language_mode(); |
| 4105 | 4101 |
| 4106 // Validate name and parameter names. We can do this only after parsing the | 4102 // Validate name and parameter names. We can do this only after parsing the |
| 4107 // function, since the function can declare itself strict. | 4103 // function, since the function can declare itself strict. |
| 4108 CheckFunctionName(language_mode, function_name, function_name_validity, | 4104 CheckFunctionName(language_mode, function_name, function_name_validity, |
| 4109 function_name_location, CHECK_OK); | 4105 function_name_location, CHECK_OK); |
| 4110 const bool allow_duplicate_parameters = | 4106 const bool allow_duplicate_parameters = |
| 4111 is_sloppy(language_mode) && formals.is_simple && !IsConciseMethod(kind); | 4107 is_sloppy(language_mode) && formals.is_simple && !IsConciseMethod(kind); |
| 4112 ValidateFormalParameters(&formals_classifier, language_mode, | 4108 ValidateFormalParameters(language_mode, allow_duplicate_parameters, |
| 4113 allow_duplicate_parameters, CHECK_OK); | 4109 CHECK_OK); |
| 4114 | 4110 |
| 4115 if (is_strict(language_mode)) { | 4111 if (is_strict(language_mode)) { |
| 4116 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), | 4112 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), |
| 4117 CHECK_OK); | 4113 CHECK_OK); |
| 4118 CheckDecimalLiteralWithLeadingZero(use_counts_, scope->start_position(), | 4114 CheckDecimalLiteralWithLeadingZero(use_counts_, scope->start_position(), |
| 4119 scope->end_position()); | 4115 scope->end_position()); |
| 4120 } | 4116 } |
| 4121 CheckConflictingVarDeclarations(scope, CHECK_OK); | 4117 CheckConflictingVarDeclarations(scope, CHECK_OK); |
| 4122 | 4118 |
| 4123 if (body) { | 4119 if (body) { |
| 4124 // If body can be inspected, rewrite queued destructuring assignments | 4120 // If body can be inspected, rewrite queued destructuring assignments |
| 4125 RewriteDestructuringAssignments(); | 4121 RewriteDestructuringAssignments(); |
| 4126 } | 4122 } |
| 4127 has_duplicate_parameters = | 4123 has_duplicate_parameters = |
| 4128 !formals_classifier.is_valid_formal_parameter_list_without_duplicates(); | 4124 !classifier()->is_valid_formal_parameter_list_without_duplicates(); |
| 4129 | 4125 |
| 4130 if (use_temp_zone) { | 4126 if (use_temp_zone) { |
| 4131 DCHECK(main_scope != scope); | 4127 DCHECK(main_scope != scope); |
| 4132 scope->AnalyzePartially(main_scope, &previous_zone_ast_node_factory); | 4128 scope->AnalyzePartially(main_scope, &previous_zone_ast_node_factory); |
| 4133 } | 4129 } |
| 4134 } // DiscardableZoneScope goes out of scope. | 4130 } // DiscardableZoneScope goes out of scope. |
| 4135 | 4131 |
| 4136 FunctionLiteral::ParameterFlag duplicate_parameters = | 4132 FunctionLiteral::ParameterFlag duplicate_parameters = |
| 4137 has_duplicate_parameters ? FunctionLiteral::kHasDuplicateParameters | 4133 has_duplicate_parameters ? FunctionLiteral::kHasDuplicateParameters |
| 4138 : FunctionLiteral::kNoDuplicateParameters; | 4134 : FunctionLiteral::kNoDuplicateParameters; |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4619 Expression* call = factory()->NewCallRuntime( | 4615 Expression* call = factory()->NewCallRuntime( |
| 4620 Runtime::kInlineGeneratorClose, args, kNoSourcePosition); | 4616 Runtime::kInlineGeneratorClose, args, kNoSourcePosition); |
| 4621 finally_block->statements()->Add( | 4617 finally_block->statements()->Add( |
| 4622 factory()->NewExpressionStatement(call, kNoSourcePosition), zone()); | 4618 factory()->NewExpressionStatement(call, kNoSourcePosition), zone()); |
| 4623 | 4619 |
| 4624 body->Add(factory()->NewTryFinallyStatement(try_block, finally_block, | 4620 body->Add(factory()->NewTryFinallyStatement(try_block, finally_block, |
| 4625 kNoSourcePosition), | 4621 kNoSourcePosition), |
| 4626 zone()); | 4622 zone()); |
| 4627 } else if (IsAsyncFunction(kind)) { | 4623 } else if (IsAsyncFunction(kind)) { |
| 4628 const bool accept_IN = true; | 4624 const bool accept_IN = true; |
| 4629 DesugarAsyncFunctionBody(function_name, inner_scope, body, nullptr, kind, | 4625 DesugarAsyncFunctionBody(function_name, inner_scope, body, kind, |
| 4630 FunctionBodyType::kNormal, accept_IN, pos, | 4626 FunctionBodyType::kNormal, accept_IN, pos, |
| 4631 CHECK_OK); | 4627 CHECK_OK); |
| 4632 } else { | 4628 } else { |
| 4633 ParseStatementList(body, Token::RBRACE, CHECK_OK); | 4629 ParseStatementList(body, Token::RBRACE, CHECK_OK); |
| 4634 } | 4630 } |
| 4635 | 4631 |
| 4636 if (IsSubclassConstructor(kind)) { | 4632 if (IsSubclassConstructor(kind)) { |
| 4637 body->Add(factory()->NewReturnStatement(ThisExpression(kNoSourcePosition), | 4633 body->Add(factory()->NewReturnStatement(ThisExpression(kNoSourcePosition), |
| 4638 kNoSourcePosition), | 4634 kNoSourcePosition), |
| 4639 zone()); | 4635 zone()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4726 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( | 4722 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( |
| 4727 language_mode(), function_state_->kind(), | 4723 language_mode(), function_state_->kind(), |
| 4728 scope()->AsDeclarationScope()->has_simple_parameters(), parsing_module_, | 4724 scope()->AsDeclarationScope()->has_simple_parameters(), parsing_module_, |
| 4729 logger, bookmark, use_counts_); | 4725 logger, bookmark, use_counts_); |
| 4730 if (pre_parse_timer_ != NULL) { | 4726 if (pre_parse_timer_ != NULL) { |
| 4731 pre_parse_timer_->Stop(); | 4727 pre_parse_timer_->Stop(); |
| 4732 } | 4728 } |
| 4733 return result; | 4729 return result; |
| 4734 } | 4730 } |
| 4735 | 4731 |
| 4736 Expression* Parser::ParseClassLiteral(ExpressionClassifier* classifier, | 4732 Expression* Parser::ParseClassLiteral(const AstRawString* name, |
| 4737 const AstRawString* name, | |
| 4738 Scanner::Location class_name_location, | 4733 Scanner::Location class_name_location, |
| 4739 bool name_is_strict_reserved, int pos, | 4734 bool name_is_strict_reserved, int pos, |
| 4740 bool* ok) { | 4735 bool* ok) { |
| 4741 // All parts of a ClassDeclaration and ClassExpression are strict code. | 4736 // All parts of a ClassDeclaration and ClassExpression are strict code. |
| 4742 if (name_is_strict_reserved) { | 4737 if (name_is_strict_reserved) { |
| 4743 ReportMessageAt(class_name_location, | 4738 ReportMessageAt(class_name_location, |
| 4744 MessageTemplate::kUnexpectedStrictReserved); | 4739 MessageTemplate::kUnexpectedStrictReserved); |
| 4745 *ok = false; | 4740 *ok = false; |
| 4746 return nullptr; | 4741 return nullptr; |
| 4747 } | 4742 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 4763 // TODO(verwaest): declare via block_state. | 4758 // TODO(verwaest): declare via block_state. |
| 4764 Declaration* declaration = | 4759 Declaration* declaration = |
| 4765 factory()->NewVariableDeclaration(proxy, block_state.scope(), pos); | 4760 factory()->NewVariableDeclaration(proxy, block_state.scope(), pos); |
| 4766 Declare(declaration, DeclarationDescriptor::NORMAL, CONST, | 4761 Declare(declaration, DeclarationDescriptor::NORMAL, CONST, |
| 4767 DefaultInitializationFlag(CONST), CHECK_OK); | 4762 DefaultInitializationFlag(CONST), CHECK_OK); |
| 4768 } | 4763 } |
| 4769 | 4764 |
| 4770 Expression* extends = nullptr; | 4765 Expression* extends = nullptr; |
| 4771 if (Check(Token::EXTENDS)) { | 4766 if (Check(Token::EXTENDS)) { |
| 4772 block_state.set_start_position(scanner()->location().end_pos); | 4767 block_state.set_start_position(scanner()->location().end_pos); |
| 4773 ExpressionClassifier extends_classifier(this); | 4768 ExpressionClassifierWrapper wrap_extends_classifier(this); |
| 4774 extends = ParseLeftHandSideExpression(&extends_classifier, CHECK_OK); | 4769 extends = ParseLeftHandSideExpression(CHECK_OK); |
| 4775 CheckNoTailCallExpressions(&extends_classifier, CHECK_OK); | 4770 CheckNoTailCallExpressions(CHECK_OK); |
| 4776 RewriteNonPattern(&extends_classifier, CHECK_OK); | 4771 RewriteNonPattern(CHECK_OK); |
| 4777 if (classifier != nullptr) { | 4772 impl()->AccumulateFormalParameterContainmentErrors(); |
| 4778 classifier->AccumulateFormalParameterContainmentErrors( | |
| 4779 &extends_classifier); | |
| 4780 } | |
| 4781 } else { | 4773 } else { |
| 4782 block_state.set_start_position(scanner()->location().end_pos); | 4774 block_state.set_start_position(scanner()->location().end_pos); |
| 4783 } | 4775 } |
| 4784 | 4776 |
| 4785 | 4777 |
| 4786 ClassLiteralChecker checker(this); | 4778 ClassLiteralChecker checker(this); |
| 4787 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4); | 4779 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4); |
| 4788 FunctionLiteral* constructor = nullptr; | 4780 FunctionLiteral* constructor = nullptr; |
| 4789 bool has_seen_constructor = false; | 4781 bool has_seen_constructor = false; |
| 4790 | 4782 |
| 4791 Expect(Token::LBRACE, CHECK_OK); | 4783 Expect(Token::LBRACE, CHECK_OK); |
| 4792 | 4784 |
| 4793 const bool has_extends = extends != nullptr; | 4785 const bool has_extends = extends != nullptr; |
| 4794 while (peek() != Token::RBRACE) { | 4786 while (peek() != Token::RBRACE) { |
| 4795 if (Check(Token::SEMICOLON)) continue; | 4787 if (Check(Token::SEMICOLON)) continue; |
| 4796 FuncNameInferrer::State fni_state(fni_); | 4788 FuncNameInferrer::State fni_state(fni_); |
| 4797 const bool in_class = true; | 4789 const bool in_class = true; |
| 4798 bool is_computed_name = false; // Classes do not care about computed | 4790 bool is_computed_name = false; // Classes do not care about computed |
| 4799 // property names here. | 4791 // property names here. |
| 4800 ExpressionClassifier property_classifier(this); | 4792 ExpressionClassifierWrapper wrap_property_classifier(this); |
| 4801 const AstRawString* property_name = nullptr; | 4793 const AstRawString* property_name = nullptr; |
| 4802 ObjectLiteral::Property* property = ParsePropertyDefinition( | 4794 ObjectLiteral::Property* property = ParsePropertyDefinition( |
| 4803 &checker, in_class, has_extends, MethodKind::kNormal, &is_computed_name, | 4795 &checker, in_class, has_extends, MethodKind::kNormal, &is_computed_name, |
| 4804 &has_seen_constructor, &property_classifier, &property_name, CHECK_OK); | 4796 &has_seen_constructor, &property_name, CHECK_OK); |
| 4805 RewriteNonPattern(&property_classifier, CHECK_OK); | 4797 RewriteNonPattern(CHECK_OK); |
| 4806 if (classifier != nullptr) { | 4798 impl()->AccumulateFormalParameterContainmentErrors(); |
| 4807 classifier->AccumulateFormalParameterContainmentErrors( | |
| 4808 &property_classifier); | |
| 4809 } | |
| 4810 | 4799 |
| 4811 if (has_seen_constructor && constructor == nullptr) { | 4800 if (has_seen_constructor && constructor == nullptr) { |
| 4812 constructor = GetPropertyValue(property)->AsFunctionLiteral(); | 4801 constructor = GetPropertyValue(property)->AsFunctionLiteral(); |
| 4813 DCHECK_NOT_NULL(constructor); | 4802 DCHECK_NOT_NULL(constructor); |
| 4814 constructor->set_raw_name( | 4803 constructor->set_raw_name( |
| 4815 name != nullptr ? name : ast_value_factory()->empty_string()); | 4804 name != nullptr ? name : ast_value_factory()->empty_string()); |
| 4816 } else { | 4805 } else { |
| 4817 properties->Add(property, zone()); | 4806 properties->Add(property, zone()); |
| 4818 } | 4807 } |
| 4819 | 4808 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4861 Expression* Parser::ParseV8Intrinsic(bool* ok) { | 4850 Expression* Parser::ParseV8Intrinsic(bool* ok) { |
| 4862 // CallRuntime :: | 4851 // CallRuntime :: |
| 4863 // '%' Identifier Arguments | 4852 // '%' Identifier Arguments |
| 4864 | 4853 |
| 4865 int pos = peek_position(); | 4854 int pos = peek_position(); |
| 4866 Expect(Token::MOD, CHECK_OK); | 4855 Expect(Token::MOD, CHECK_OK); |
| 4867 // Allow "eval" or "arguments" for backward compatibility. | 4856 // Allow "eval" or "arguments" for backward compatibility. |
| 4868 const AstRawString* name = ParseIdentifier(kAllowRestrictedIdentifiers, | 4857 const AstRawString* name = ParseIdentifier(kAllowRestrictedIdentifiers, |
| 4869 CHECK_OK); | 4858 CHECK_OK); |
| 4870 Scanner::Location spread_pos; | 4859 Scanner::Location spread_pos; |
| 4871 ExpressionClassifier classifier(this); | 4860 ExpressionClassifierWrapper wrap_classifier(this); |
| 4872 ZoneList<Expression*>* args = | 4861 ZoneList<Expression*>* args = ParseArguments(&spread_pos, CHECK_OK); |
| 4873 ParseArguments(&spread_pos, &classifier, CHECK_OK); | |
| 4874 | 4862 |
| 4875 DCHECK(!spread_pos.IsValid()); | 4863 DCHECK(!spread_pos.IsValid()); |
| 4876 | 4864 |
| 4877 if (extension_ != NULL) { | 4865 if (extension_ != NULL) { |
| 4878 // The extension structures are only accessible while parsing the | 4866 // The extension structures are only accessible while parsing the |
| 4879 // very first time not when reparsing because of lazy compilation. | 4867 // very first time not when reparsing because of lazy compilation. |
| 4880 GetClosureScope()->ForceEagerCompilation(); | 4868 GetClosureScope()->ForceEagerCompilation(); |
| 4881 } | 4869 } |
| 4882 | 4870 |
| 4883 const Runtime::Function* function = Runtime::FunctionForName(name->string()); | 4871 const Runtime::Function* function = Runtime::FunctionForName(name->string()); |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5582 | 5570 |
| 5583 void VisitObjectLiteralProperty(ObjectLiteralProperty* property) override { | 5571 void VisitObjectLiteralProperty(ObjectLiteralProperty* property) override { |
| 5584 if (property == nullptr) return; | 5572 if (property == nullptr) return; |
| 5585 // Do not rewrite (computed) key expressions | 5573 // Do not rewrite (computed) key expressions |
| 5586 AST_REWRITE_PROPERTY(Expression, property, value); | 5574 AST_REWRITE_PROPERTY(Expression, property, value); |
| 5587 } | 5575 } |
| 5588 | 5576 |
| 5589 Parser* parser_; | 5577 Parser* parser_; |
| 5590 }; | 5578 }; |
| 5591 | 5579 |
| 5592 | 5580 void Parser::RewriteNonPattern(bool* ok) { |
| 5593 void Parser::RewriteNonPattern(ExpressionClassifier* classifier, bool* ok) { | 5581 ValidateExpression(CHECK_OK_VOID); |
| 5594 ValidateExpression(classifier, CHECK_OK_VOID); | |
| 5595 auto non_patterns_to_rewrite = function_state_->non_patterns_to_rewrite(); | 5582 auto non_patterns_to_rewrite = function_state_->non_patterns_to_rewrite(); |
| 5596 int begin = classifier->GetNonPatternBegin(); | 5583 int begin = classifier()->GetNonPatternBegin(); |
| 5597 int end = non_patterns_to_rewrite->length(); | 5584 int end = non_patterns_to_rewrite->length(); |
| 5598 if (begin < end) { | 5585 if (begin < end) { |
| 5599 NonPatternRewriter rewriter(stack_limit_, this); | 5586 NonPatternRewriter rewriter(stack_limit_, this); |
| 5600 for (int i = begin; i < end; i++) { | 5587 for (int i = begin; i < end; i++) { |
| 5601 DCHECK(non_patterns_to_rewrite->at(i)->IsRewritableExpression()); | 5588 DCHECK(non_patterns_to_rewrite->at(i)->IsRewritableExpression()); |
| 5602 rewriter.Rewrite(non_patterns_to_rewrite->at(i)); | 5589 rewriter.Rewrite(non_patterns_to_rewrite->at(i)); |
| 5603 } | 5590 } |
| 5604 non_patterns_to_rewrite->Rewind(begin); | 5591 non_patterns_to_rewrite->Rewind(begin); |
| 5605 } | 5592 } |
| 5606 } | 5593 } |
| (...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6741 node->Print(Isolate::Current()); | 6728 node->Print(Isolate::Current()); |
| 6742 } | 6729 } |
| 6743 #endif // DEBUG | 6730 #endif // DEBUG |
| 6744 | 6731 |
| 6745 #undef CHECK_OK | 6732 #undef CHECK_OK |
| 6746 #undef CHECK_OK_VOID | 6733 #undef CHECK_OK_VOID |
| 6747 #undef CHECK_FAILED | 6734 #undef CHECK_FAILED |
| 6748 | 6735 |
| 6749 } // namespace internal | 6736 } // namespace internal |
| 6750 } // namespace v8 | 6737 } // namespace v8 |
| OLD | NEW |