| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #include "src/allocation.h" | 7 #include "src/allocation.h" |
| 8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
| 9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
| 10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 MessageTemplate::Template message, | 32 MessageTemplate::Template message, |
| 33 const char* arg, | 33 const char* arg, |
| 34 ParseErrorType error_type) { | 34 ParseErrorType error_type) { |
| 35 pre_parser_->log_->LogMessage(start_pos, end_pos, message, arg, error_type); | 35 pre_parser_->log_->LogMessage(start_pos, end_pos, message, arg, error_type); |
| 36 } | 36 } |
| 37 | 37 |
| 38 | 38 |
| 39 PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) { | 39 PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) { |
| 40 if (scanner->current_token() == Token::FUTURE_RESERVED_WORD) { | 40 if (scanner->current_token() == Token::FUTURE_RESERVED_WORD) { |
| 41 return PreParserIdentifier::FutureReserved(); | 41 return PreParserIdentifier::FutureReserved(); |
| 42 } else if (scanner->current_token() == | 42 } else if (scanner->current_token() == Token::FUTURE_STRICT_RESERVED_WORD) { |
| 43 Token::FUTURE_STRICT_RESERVED_WORD) { | |
| 44 return PreParserIdentifier::FutureStrictReserved(); | 43 return PreParserIdentifier::FutureStrictReserved(); |
| 45 } else if (scanner->current_token() == Token::LET) { | 44 } else if (scanner->current_token() == Token::LET) { |
| 46 return PreParserIdentifier::Let(); | 45 return PreParserIdentifier::Let(); |
| 47 } else if (scanner->current_token() == Token::STATIC) { | 46 } else if (scanner->current_token() == Token::STATIC) { |
| 48 return PreParserIdentifier::Static(); | 47 return PreParserIdentifier::Static(); |
| 49 } else if (scanner->current_token() == Token::YIELD) { | 48 } else if (scanner->current_token() == Token::YIELD) { |
| 50 return PreParserIdentifier::Yield(); | 49 return PreParserIdentifier::Yield(); |
| 51 } | 50 } |
| 52 if (scanner->UnescapedLiteralMatches("eval", 4)) { | 51 if (scanner->UnescapedLiteralMatches("eval", 4)) { |
| 53 return PreParserIdentifier::Eval(); | 52 return PreParserIdentifier::Eval(); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 250 |
| 252 if (directive_prologue) { | 251 if (directive_prologue) { |
| 253 bool use_strict_found = statement.IsUseStrictLiteral(); | 252 bool use_strict_found = statement.IsUseStrictLiteral(); |
| 254 bool use_strong_found = | 253 bool use_strong_found = |
| 255 statement.IsUseStrongLiteral() && allow_strong_mode(); | 254 statement.IsUseStrongLiteral() && allow_strong_mode(); |
| 256 | 255 |
| 257 if (use_strict_found) { | 256 if (use_strict_found) { |
| 258 scope_->SetLanguageMode( | 257 scope_->SetLanguageMode( |
| 259 static_cast<LanguageMode>(scope_->language_mode() | STRICT)); | 258 static_cast<LanguageMode>(scope_->language_mode() | STRICT)); |
| 260 } else if (use_strong_found) { | 259 } else if (use_strong_found) { |
| 261 scope_->SetLanguageMode(static_cast<LanguageMode>( | 260 scope_->SetLanguageMode( |
| 262 scope_->language_mode() | STRONG)); | 261 static_cast<LanguageMode>(scope_->language_mode() | STRONG)); |
| 263 if (IsClassConstructor(function_state_->kind())) { | 262 if (IsClassConstructor(function_state_->kind())) { |
| 264 // "use strong" cannot occur in a class constructor body, to avoid | 263 // "use strong" cannot occur in a class constructor body, to avoid |
| 265 // unintuitive strong class object semantics. | 264 // unintuitive strong class object semantics. |
| 266 PreParserTraits::ReportMessageAt( | 265 PreParserTraits::ReportMessageAt( |
| 267 token_loc, MessageTemplate::kStrongConstructorDirective); | 266 token_loc, MessageTemplate::kStrongConstructorDirective); |
| 268 *ok = false; | 267 *ok = false; |
| 269 return; | 268 return; |
| 270 } | 269 } |
| 271 } else if (!statement.IsStringLiteral()) { | 270 } else if (!statement.IsStringLiteral()) { |
| 272 directive_prologue = false; | 271 directive_prologue = false; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 298 bookmark->Reset(); | 297 bookmark->Reset(); |
| 299 return; | 298 return; |
| 300 } | 299 } |
| 301 maybe_reset = false; | 300 maybe_reset = false; |
| 302 } | 301 } |
| 303 } | 302 } |
| 304 } | 303 } |
| 305 | 304 |
| 306 | 305 |
| 307 #define CHECK_OK ok); \ | 306 #define CHECK_OK ok); \ |
| 308 if (!*ok) return Statement::Default(); \ | 307 if (!*ok) return Statement::Default(); \ |
| 309 ((void)0 | 308 ((void)0 |
| 310 #define DUMMY ) // to make indentation work | 309 #define DUMMY ) // to make indentation work |
| 311 #undef DUMMY | 310 #undef DUMMY |
| 312 | 311 |
| 313 | 312 |
| 314 PreParser::Statement PreParser::ParseStatement(bool* ok) { | 313 PreParser::Statement PreParser::ParseStatement(bool* ok) { |
| 315 // Statement :: | 314 // Statement :: |
| 316 // EmptyStatement | 315 // EmptyStatement |
| 317 // ... | 316 // ... |
| 318 | 317 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 PreParser::Statement PreParser::ParseFunctionDeclaration(bool* ok) { | 435 PreParser::Statement PreParser::ParseFunctionDeclaration(bool* ok) { |
| 437 // FunctionDeclaration :: | 436 // FunctionDeclaration :: |
| 438 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' | 437 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' |
| 439 // GeneratorDeclaration :: | 438 // GeneratorDeclaration :: |
| 440 // 'function' '*' Identifier '(' FormalParameterListopt ')' | 439 // 'function' '*' Identifier '(' FormalParameterListopt ')' |
| 441 // '{' FunctionBody '}' | 440 // '{' FunctionBody '}' |
| 442 Expect(Token::FUNCTION, CHECK_OK); | 441 Expect(Token::FUNCTION, CHECK_OK); |
| 443 int pos = position(); | 442 int pos = position(); |
| 444 bool is_generator = Check(Token::MUL); | 443 bool is_generator = Check(Token::MUL); |
| 445 bool is_strict_reserved = false; | 444 bool is_strict_reserved = false; |
| 446 Identifier name = ParseIdentifierOrStrictReservedWord( | 445 Identifier name = |
| 447 &is_strict_reserved, CHECK_OK); | 446 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); |
| 448 ParseFunctionLiteral(name, scanner()->location(), | 447 ParseFunctionLiteral(name, scanner()->location(), |
| 449 is_strict_reserved ? kFunctionNameIsStrictReserved | 448 is_strict_reserved ? kFunctionNameIsStrictReserved |
| 450 : kFunctionNameValidityUnknown, | 449 : kFunctionNameValidityUnknown, |
| 451 is_generator ? FunctionKind::kGeneratorFunction | 450 is_generator ? FunctionKind::kGeneratorFunction |
| 452 : FunctionKind::kNormalFunction, | 451 : FunctionKind::kNormalFunction, |
| 453 pos, FunctionLiteral::DECLARATION, | 452 pos, FunctionLiteral::DECLARATION, |
| 454 FunctionLiteral::NORMAL_ARITY, language_mode(), | 453 FunctionLiteral::NORMAL_ARITY, language_mode(), |
| 455 CHECK_OK); | 454 CHECK_OK); |
| 456 return Statement::FunctionDeclaration(); | 455 return Statement::FunctionDeclaration(); |
| 457 } | 456 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 483 Statement final = Statement::Default(); | 482 Statement final = Statement::Default(); |
| 484 while (peek() != Token::RBRACE) { | 483 while (peek() != Token::RBRACE) { |
| 485 final = ParseStatementListItem(CHECK_OK); | 484 final = ParseStatementListItem(CHECK_OK); |
| 486 } | 485 } |
| 487 Expect(Token::RBRACE, ok); | 486 Expect(Token::RBRACE, ok); |
| 488 return final; | 487 return final; |
| 489 } | 488 } |
| 490 | 489 |
| 491 | 490 |
| 492 PreParser::Statement PreParser::ParseVariableStatement( | 491 PreParser::Statement PreParser::ParseVariableStatement( |
| 493 VariableDeclarationContext var_context, | 492 VariableDeclarationContext var_context, bool* ok) { |
| 494 bool* ok) { | |
| 495 // VariableStatement :: | 493 // VariableStatement :: |
| 496 // VariableDeclarations ';' | 494 // VariableDeclarations ';' |
| 497 | 495 |
| 498 Statement result = ParseVariableDeclarations( | 496 Statement result = ParseVariableDeclarations( |
| 499 var_context, nullptr, nullptr, nullptr, nullptr, nullptr, CHECK_OK); | 497 var_context, nullptr, nullptr, nullptr, nullptr, nullptr, CHECK_OK); |
| 500 ExpectSemicolon(CHECK_OK); | 498 ExpectSemicolon(CHECK_OK); |
| 501 return result; | 499 return result; |
| 502 } | 500 } |
| 503 | 501 |
| 504 | 502 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 case Token::FUNCTION: | 638 case Token::FUNCTION: |
| 641 case Token::LBRACE: | 639 case Token::LBRACE: |
| 642 UNREACHABLE(); // Always handled by the callers. | 640 UNREACHABLE(); // Always handled by the callers. |
| 643 case Token::CLASS: | 641 case Token::CLASS: |
| 644 ReportUnexpectedToken(Next()); | 642 ReportUnexpectedToken(Next()); |
| 645 *ok = false; | 643 *ok = false; |
| 646 return Statement::Default(); | 644 return Statement::Default(); |
| 647 | 645 |
| 648 case Token::THIS: | 646 case Token::THIS: |
| 649 if (!FLAG_strong_this) break; | 647 if (!FLAG_strong_this) break; |
| 650 // Fall through. | 648 // Fall through. |
| 651 case Token::SUPER: | 649 case Token::SUPER: |
| 652 if (is_strong(language_mode()) && | 650 if (is_strong(language_mode()) && |
| 653 IsClassConstructor(function_state_->kind())) { | 651 IsClassConstructor(function_state_->kind())) { |
| 654 bool is_this = peek() == Token::THIS; | 652 bool is_this = peek() == Token::THIS; |
| 655 Expression expr = Expression::Default(); | 653 Expression expr = Expression::Default(); |
| 656 ExpressionClassifier classifier; | 654 ExpressionClassifier classifier; |
| 657 if (is_this) { | 655 if (is_this) { |
| 658 expr = ParseStrongInitializationExpression(&classifier, CHECK_OK); | 656 expr = ParseStrongInitializationExpression(&classifier, CHECK_OK); |
| 659 } else { | 657 } else { |
| 660 expr = ParseStrongSuperCallExpression(&classifier, CHECK_OK); | 658 expr = ParseStrongSuperCallExpression(&classifier, CHECK_OK); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 // 'if' '(' Expression ')' Statement ('else' Statement)? | 726 // 'if' '(' Expression ')' Statement ('else' Statement)? |
| 729 | 727 |
| 730 Expect(Token::IF, CHECK_OK); | 728 Expect(Token::IF, CHECK_OK); |
| 731 Expect(Token::LPAREN, CHECK_OK); | 729 Expect(Token::LPAREN, CHECK_OK); |
| 732 ParseExpression(true, CHECK_OK); | 730 ParseExpression(true, CHECK_OK); |
| 733 Expect(Token::RPAREN, CHECK_OK); | 731 Expect(Token::RPAREN, CHECK_OK); |
| 734 Statement stat = ParseSubStatement(CHECK_OK); | 732 Statement stat = ParseSubStatement(CHECK_OK); |
| 735 if (peek() == Token::ELSE) { | 733 if (peek() == Token::ELSE) { |
| 736 Next(); | 734 Next(); |
| 737 Statement else_stat = ParseSubStatement(CHECK_OK); | 735 Statement else_stat = ParseSubStatement(CHECK_OK); |
| 738 stat = (stat.IsJumpStatement() && else_stat.IsJumpStatement()) ? | 736 stat = (stat.IsJumpStatement() && else_stat.IsJumpStatement()) |
| 739 Statement::Jump() : Statement::Default(); | 737 ? Statement::Jump() |
| 738 : Statement::Default(); |
| 740 } else { | 739 } else { |
| 741 stat = Statement::Default(); | 740 stat = Statement::Default(); |
| 742 } | 741 } |
| 743 return stat; | 742 return stat; |
| 744 } | 743 } |
| 745 | 744 |
| 746 | 745 |
| 747 PreParser::Statement PreParser::ParseContinueStatement(bool* ok) { | 746 PreParser::Statement PreParser::ParseContinueStatement(bool* ok) { |
| 748 // ContinueStatement :: | 747 // ContinueStatement :: |
| 749 // 'continue' [no line terminator] Identifier? ';' | 748 // 'continue' [no line terminator] Identifier? ';' |
| 750 | 749 |
| 751 Expect(Token::CONTINUE, CHECK_OK); | 750 Expect(Token::CONTINUE, CHECK_OK); |
| 752 Token::Value tok = peek(); | 751 Token::Value tok = peek(); |
| 753 if (!scanner()->HasAnyLineTerminatorBeforeNext() && | 752 if (!scanner()->HasAnyLineTerminatorBeforeNext() && tok != Token::SEMICOLON && |
| 754 tok != Token::SEMICOLON && | 753 tok != Token::RBRACE && tok != Token::EOS) { |
| 755 tok != Token::RBRACE && | |
| 756 tok != Token::EOS) { | |
| 757 // ECMA allows "eval" or "arguments" as labels even in strict mode. | 754 // ECMA allows "eval" or "arguments" as labels even in strict mode. |
| 758 ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK); | 755 ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK); |
| 759 } | 756 } |
| 760 ExpectSemicolon(CHECK_OK); | 757 ExpectSemicolon(CHECK_OK); |
| 761 return Statement::Jump(); | 758 return Statement::Jump(); |
| 762 } | 759 } |
| 763 | 760 |
| 764 | 761 |
| 765 PreParser::Statement PreParser::ParseBreakStatement(bool* ok) { | 762 PreParser::Statement PreParser::ParseBreakStatement(bool* ok) { |
| 766 // BreakStatement :: | 763 // BreakStatement :: |
| 767 // 'break' [no line terminator] Identifier? ';' | 764 // 'break' [no line terminator] Identifier? ';' |
| 768 | 765 |
| 769 Expect(Token::BREAK, CHECK_OK); | 766 Expect(Token::BREAK, CHECK_OK); |
| 770 Token::Value tok = peek(); | 767 Token::Value tok = peek(); |
| 771 if (!scanner()->HasAnyLineTerminatorBeforeNext() && | 768 if (!scanner()->HasAnyLineTerminatorBeforeNext() && tok != Token::SEMICOLON && |
| 772 tok != Token::SEMICOLON && | 769 tok != Token::RBRACE && tok != Token::EOS) { |
| 773 tok != Token::RBRACE && | |
| 774 tok != Token::EOS) { | |
| 775 // ECMA allows "eval" or "arguments" as labels even in strict mode. | 770 // ECMA allows "eval" or "arguments" as labels even in strict mode. |
| 776 ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK); | 771 ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK); |
| 777 } | 772 } |
| 778 ExpectSemicolon(CHECK_OK); | 773 ExpectSemicolon(CHECK_OK); |
| 779 return Statement::Jump(); | 774 return Statement::Jump(); |
| 780 } | 775 } |
| 781 | 776 |
| 782 | 777 |
| 783 PreParser::Statement PreParser::ParseReturnStatement(bool* ok) { | 778 PreParser::Statement PreParser::ParseReturnStatement(bool* ok) { |
| 784 // ReturnStatement :: | 779 // ReturnStatement :: |
| 785 // 'return' [no line terminator] Expression? ';' | 780 // 'return' [no line terminator] Expression? ';' |
| 786 | 781 |
| 787 // Consume the return token. It is necessary to do before | 782 // Consume the return token. It is necessary to do before |
| 788 // reporting any errors on it, because of the way errors are | 783 // reporting any errors on it, because of the way errors are |
| 789 // reported (underlining). | 784 // reported (underlining). |
| 790 Expect(Token::RETURN, CHECK_OK); | 785 Expect(Token::RETURN, CHECK_OK); |
| 791 function_state_->set_return_location(scanner()->location()); | 786 function_state_->set_return_location(scanner()->location()); |
| 792 | 787 |
| 793 // An ECMAScript program is considered syntactically incorrect if it | 788 // An ECMAScript program is considered syntactically incorrect if it |
| 794 // contains a return statement that is not within the body of a | 789 // contains a return statement that is not within the body of a |
| 795 // function. See ECMA-262, section 12.9, page 67. | 790 // function. See ECMA-262, section 12.9, page 67. |
| 796 // This is not handled during preparsing. | 791 // This is not handled during preparsing. |
| 797 | 792 |
| 798 Token::Value tok = peek(); | 793 Token::Value tok = peek(); |
| 799 if (!scanner()->HasAnyLineTerminatorBeforeNext() && | 794 if (!scanner()->HasAnyLineTerminatorBeforeNext() && tok != Token::SEMICOLON && |
| 800 tok != Token::SEMICOLON && | 795 tok != Token::RBRACE && tok != Token::EOS) { |
| 801 tok != Token::RBRACE && | |
| 802 tok != Token::EOS) { | |
| 803 if (is_strong(language_mode()) && | 796 if (is_strong(language_mode()) && |
| 804 IsClassConstructor(function_state_->kind())) { | 797 IsClassConstructor(function_state_->kind())) { |
| 805 int pos = peek_position(); | 798 int pos = peek_position(); |
| 806 ReportMessageAt(Scanner::Location(pos, pos + 1), | 799 ReportMessageAt(Scanner::Location(pos, pos + 1), |
| 807 MessageTemplate::kStrongConstructorReturnValue); | 800 MessageTemplate::kStrongConstructorReturnValue); |
| 808 *ok = false; | 801 *ok = false; |
| 809 return Statement::Default(); | 802 return Statement::Default(); |
| 810 } | 803 } |
| 811 ParseExpression(true, CHECK_OK); | 804 ParseExpression(true, CHECK_OK); |
| 812 } | 805 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 while (token != Token::RBRACE) { | 842 while (token != Token::RBRACE) { |
| 850 if (token == Token::CASE) { | 843 if (token == Token::CASE) { |
| 851 Expect(Token::CASE, CHECK_OK); | 844 Expect(Token::CASE, CHECK_OK); |
| 852 ParseExpression(true, CHECK_OK); | 845 ParseExpression(true, CHECK_OK); |
| 853 } else { | 846 } else { |
| 854 Expect(Token::DEFAULT, CHECK_OK); | 847 Expect(Token::DEFAULT, CHECK_OK); |
| 855 } | 848 } |
| 856 Expect(Token::COLON, CHECK_OK); | 849 Expect(Token::COLON, CHECK_OK); |
| 857 token = peek(); | 850 token = peek(); |
| 858 Statement statement = Statement::Jump(); | 851 Statement statement = Statement::Jump(); |
| 859 while (token != Token::CASE && | 852 while (token != Token::CASE && token != Token::DEFAULT && |
| 860 token != Token::DEFAULT && | |
| 861 token != Token::RBRACE) { | 853 token != Token::RBRACE) { |
| 862 statement = ParseStatementListItem(CHECK_OK); | 854 statement = ParseStatementListItem(CHECK_OK); |
| 863 token = peek(); | 855 token = peek(); |
| 864 } | 856 } |
| 865 if (is_strong(language_mode()) && !statement.IsJumpStatement() && | 857 if (is_strong(language_mode()) && !statement.IsJumpStatement() && |
| 866 token != Token::RBRACE) { | 858 token != Token::RBRACE) { |
| 867 ReportMessageAt(scanner()->location(), | 859 ReportMessageAt(scanner()->location(), |
| 868 MessageTemplate::kStrongSwitchFallthrough); | 860 MessageTemplate::kStrongSwitchFallthrough); |
| 869 *ok = false; | 861 *ok = false; |
| 870 return Statement::Default(); | 862 return Statement::Default(); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 // DebuggerStatement :: | 1057 // DebuggerStatement :: |
| 1066 // 'debugger' ';' | 1058 // 'debugger' ';' |
| 1067 | 1059 |
| 1068 Expect(Token::DEBUGGER, CHECK_OK); | 1060 Expect(Token::DEBUGGER, CHECK_OK); |
| 1069 ExpectSemicolon(ok); | 1061 ExpectSemicolon(ok); |
| 1070 return Statement::Default(); | 1062 return Statement::Default(); |
| 1071 } | 1063 } |
| 1072 | 1064 |
| 1073 | 1065 |
| 1074 #undef CHECK_OK | 1066 #undef CHECK_OK |
| 1075 #define CHECK_OK ok); \ | 1067 #define CHECK_OK ok); \ |
| 1076 if (!*ok) return Expression::Default(); \ | 1068 if (!*ok) return Expression::Default(); \ |
| 1077 ((void)0 | 1069 ((void)0 |
| 1078 #define DUMMY ) // to make indentation work | 1070 #define DUMMY ) // to make indentation work |
| 1079 #undef DUMMY | 1071 #undef DUMMY |
| 1080 | 1072 |
| 1081 | 1073 |
| 1082 PreParser::Expression PreParser::ParseFunctionLiteral( | 1074 PreParser::Expression PreParser::ParseFunctionLiteral( |
| 1083 Identifier function_name, Scanner::Location function_name_location, | 1075 Identifier function_name, Scanner::Location function_name_location, |
| 1084 FunctionNameValidity function_name_validity, FunctionKind kind, | 1076 FunctionNameValidity function_name_validity, FunctionKind kind, |
| 1085 int function_token_pos, FunctionLiteral::FunctionType function_type, | 1077 int function_token_pos, FunctionLiteral::FunctionType function_type, |
| 1086 FunctionLiteral::ArityRestriction arity_restriction, | 1078 FunctionLiteral::ArityRestriction arity_restriction, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1099 ExpressionClassifier formals_classifier(&duplicate_finder); | 1091 ExpressionClassifier formals_classifier(&duplicate_finder); |
| 1100 | 1092 |
| 1101 Expect(Token::LPAREN, CHECK_OK); | 1093 Expect(Token::LPAREN, CHECK_OK); |
| 1102 int start_position = scanner()->location().beg_pos; | 1094 int start_position = scanner()->location().beg_pos; |
| 1103 function_scope->set_start_position(start_position); | 1095 function_scope->set_start_position(start_position); |
| 1104 PreParserFormalParameters formals(function_scope); | 1096 PreParserFormalParameters formals(function_scope); |
| 1105 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); | 1097 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); |
| 1106 Expect(Token::RPAREN, CHECK_OK); | 1098 Expect(Token::RPAREN, CHECK_OK); |
| 1107 int formals_end_position = scanner()->location().end_pos; | 1099 int formals_end_position = scanner()->location().end_pos; |
| 1108 | 1100 |
| 1109 CheckArityRestrictions(formals.arity, arity_restriction, | 1101 CheckArityRestrictions(formals.arity, arity_restriction, formals.has_rest, |
| 1110 formals.has_rest, start_position, | 1102 start_position, formals_end_position, CHECK_OK); |
| 1111 formals_end_position, CHECK_OK); | |
| 1112 | 1103 |
| 1113 // See Parser::ParseFunctionLiteral for more information about lazy parsing | 1104 // See Parser::ParseFunctionLiteral for more information about lazy parsing |
| 1114 // and lazy compilation. | 1105 // and lazy compilation. |
| 1115 bool is_lazily_parsed = | 1106 bool is_lazily_parsed = |
| 1116 (outer_is_script_scope && allow_lazy() && !parenthesized_function_); | 1107 (outer_is_script_scope && allow_lazy() && !parenthesized_function_); |
| 1117 parenthesized_function_ = false; | 1108 parenthesized_function_ = false; |
| 1118 | 1109 |
| 1119 Expect(Token::LBRACE, CHECK_OK); | 1110 Expect(Token::LBRACE, CHECK_OK); |
| 1120 if (is_lazily_parsed) { | 1111 if (is_lazily_parsed) { |
| 1121 ParseLazyFunctionLiteralBody(CHECK_OK); | 1112 ParseLazyFunctionLiteralBody(CHECK_OK); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 Expect(Token::RBRACE, CHECK_OK); | 1257 Expect(Token::RBRACE, CHECK_OK); |
| 1267 return PreParserExpression::Default(); | 1258 return PreParserExpression::Default(); |
| 1268 } | 1259 } |
| 1269 } | 1260 } |
| 1270 | 1261 |
| 1271 #undef CHECK_OK | 1262 #undef CHECK_OK |
| 1272 | 1263 |
| 1273 | 1264 |
| 1274 } // namespace internal | 1265 } // namespace internal |
| 1275 } // namespace v8 | 1266 } // namespace v8 |
| OLD | NEW |