Chromium Code Reviews| 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 #ifndef V8_PREPARSER_H | 5 #ifndef V8_PREPARSER_H |
| 6 #define V8_PREPARSER_H | 6 #define V8_PREPARSER_H |
| 7 | 7 |
| 8 #include "src/bailout-reason.h" | 8 #include "src/bailout-reason.h" |
| 9 #include "src/expression-classifier.h" | 9 #include "src/expression-classifier.h" |
| 10 #include "src/func-name-inferrer.h" | 10 #include "src/func-name-inferrer.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 kFunctionNameValidityUnknown | 24 kFunctionNameValidityUnknown |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 | 27 |
| 28 struct FormalParametersBase { | 28 struct FormalParametersBase { |
| 29 explicit FormalParametersBase(Scope* scope) : scope(scope) {} | 29 explicit FormalParametersBase(Scope* scope) : scope(scope) {} |
| 30 Scope* scope; | 30 Scope* scope; |
| 31 bool has_rest = false; | 31 bool has_rest = false; |
| 32 bool is_simple = true; | 32 bool is_simple = true; |
| 33 int materialized_literals_count = 0; | 33 int materialized_literals_count = 0; |
| 34 mutable int rest_array_literal_index = -1; | |
|
wingo
2015/09/01 14:41:20
Is mutable needed? I think not, according to uses
caitp (gmail)
2015/09/01 15:17:24
It is needed by the pattern rewriter, because I wa
adamk
2015/09/01 15:43:12
To be clear about the conflicting requests: I only
| |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 | 37 |
| 37 // Common base class shared between parser and pre-parser. Traits encapsulate | 38 // Common base class shared between parser and pre-parser. Traits encapsulate |
| 38 // the differences between Parser and PreParser: | 39 // the differences between Parser and PreParser: |
| 39 | 40 |
| 40 // - Return types: For example, Parser functions return Expression* and | 41 // - Return types: For example, Parser functions return Expression* and |
| 41 // PreParser functions return PreParserExpression. | 42 // PreParser functions return PreParserExpression. |
| 42 | 43 |
| 43 // - Creating parse tree nodes: Parser generates an AST during the recursive | 44 // - Creating parse tree nodes: Parser generates an AST during the recursive |
| (...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 934 } | 935 } |
| 935 | 936 |
| 936 static PreParserExpression FromIdentifier(PreParserIdentifier id) { | 937 static PreParserExpression FromIdentifier(PreParserIdentifier id) { |
| 937 return PreParserExpression(TypeField::encode(kIdentifierExpression) | | 938 return PreParserExpression(TypeField::encode(kIdentifierExpression) | |
| 938 IdentifierTypeField::encode(id.type_)); | 939 IdentifierTypeField::encode(id.type_)); |
| 939 } | 940 } |
| 940 | 941 |
| 941 static PreParserExpression BinaryOperation(PreParserExpression left, | 942 static PreParserExpression BinaryOperation(PreParserExpression left, |
| 942 Token::Value op, | 943 Token::Value op, |
| 943 PreParserExpression right) { | 944 PreParserExpression right) { |
| 944 return PreParserExpression(TypeField::encode(kBinaryOperationExpression)); | 945 return PreParserExpression( |
| 946 TypeField::encode(kBinaryOperationExpression) | | |
| 947 HasRestField::encode(op == Token::COMMA && | |
| 948 right->IsSpreadExpression())); | |
| 945 } | 949 } |
| 946 | 950 |
| 947 static PreParserExpression StringLiteral() { | 951 static PreParserExpression StringLiteral() { |
| 948 return PreParserExpression(TypeField::encode(kStringLiteralExpression)); | 952 return PreParserExpression(TypeField::encode(kStringLiteralExpression)); |
| 949 } | 953 } |
| 950 | 954 |
| 951 static PreParserExpression UseStrictStringLiteral() { | 955 static PreParserExpression UseStrictStringLiteral() { |
| 952 return PreParserExpression(TypeField::encode(kStringLiteralExpression) | | 956 return PreParserExpression(TypeField::encode(kStringLiteralExpression) | |
| 953 IsUseStrictField::encode(true)); | 957 IsUseStrictField::encode(true)); |
| 954 } | 958 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1051 | 1055 |
| 1052 bool IsNoTemplateTag() const { | 1056 bool IsNoTemplateTag() const { |
| 1053 return TypeField::decode(code_) == kExpression && | 1057 return TypeField::decode(code_) == kExpression && |
| 1054 ExpressionTypeField::decode(code_) == kNoTemplateTagExpression; | 1058 ExpressionTypeField::decode(code_) == kNoTemplateTagExpression; |
| 1055 } | 1059 } |
| 1056 | 1060 |
| 1057 bool IsSpreadExpression() const { | 1061 bool IsSpreadExpression() const { |
| 1058 return TypeField::decode(code_) == kSpreadExpression; | 1062 return TypeField::decode(code_) == kSpreadExpression; |
| 1059 } | 1063 } |
| 1060 | 1064 |
| 1065 bool IsArrowFunctionFormalParametersWithRestParameter() const { | |
| 1066 // Preparser's way of determining if an arrow function has a rest parameter. | |
| 1067 // Depends on `ExpressionClassifier::is_valid_arrow_formal_parameters()` | |
|
wingo
2015/09/01 14:41:20
I apologize for nitpicking but can we have sentenc
caitp (gmail)
2015/09/01 15:17:24
Done.
| |
| 1068 return IsSpreadExpression() || | |
| 1069 (IsBinaryOperation() && HasRestField::decode(code_)); | |
| 1070 } | |
| 1071 | |
| 1061 PreParserExpression AsFunctionLiteral() { return *this; } | 1072 PreParserExpression AsFunctionLiteral() { return *this; } |
| 1062 | 1073 |
| 1063 bool IsBinaryOperation() const { | 1074 bool IsBinaryOperation() const { |
| 1064 return TypeField::decode(code_) == kBinaryOperationExpression; | 1075 return TypeField::decode(code_) == kBinaryOperationExpression; |
| 1065 } | 1076 } |
| 1066 | 1077 |
| 1067 // Dummy implementation for making expression->somefunc() work in both Parser | 1078 // Dummy implementation for making expression->somefunc() work in both Parser |
| 1068 // and PreParser. | 1079 // and PreParser. |
| 1069 PreParserExpression* operator->() { return this; } | 1080 PreParserExpression* operator->() { return this; } |
| 1070 | 1081 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1099 // The first three bits are for the Type. | 1110 // The first three bits are for the Type. |
| 1100 typedef BitField<Type, 0, 3> TypeField; | 1111 typedef BitField<Type, 0, 3> TypeField; |
| 1101 | 1112 |
| 1102 // The rest of the bits are interpreted depending on the value | 1113 // The rest of the bits are interpreted depending on the value |
| 1103 // of the Type field, so they can share the storage. | 1114 // of the Type field, so they can share the storage. |
| 1104 typedef BitField<ExpressionType, TypeField::kNext, 3> ExpressionTypeField; | 1115 typedef BitField<ExpressionType, TypeField::kNext, 3> ExpressionTypeField; |
| 1105 typedef BitField<bool, TypeField::kNext, 1> IsUseStrictField; | 1116 typedef BitField<bool, TypeField::kNext, 1> IsUseStrictField; |
| 1106 typedef BitField<bool, IsUseStrictField::kNext, 1> IsUseStrongField; | 1117 typedef BitField<bool, IsUseStrictField::kNext, 1> IsUseStrongField; |
| 1107 typedef BitField<PreParserIdentifier::Type, TypeField::kNext, 10> | 1118 typedef BitField<PreParserIdentifier::Type, TypeField::kNext, 10> |
| 1108 IdentifierTypeField; | 1119 IdentifierTypeField; |
| 1120 typedef BitField<bool, TypeField::kNext, 1> HasRestField; | |
| 1109 | 1121 |
| 1110 uint32_t code_; | 1122 uint32_t code_; |
| 1111 }; | 1123 }; |
| 1112 | 1124 |
| 1113 | 1125 |
| 1114 // The pre-parser doesn't need to build lists of expressions, identifiers, or | 1126 // The pre-parser doesn't need to build lists of expressions, identifiers, or |
| 1115 // the like. | 1127 // the like. |
| 1116 template <typename T> | 1128 template <typename T> |
| 1117 class PreParserList { | 1129 class PreParserList { |
| 1118 public: | 1130 public: |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1871 return pre_parser_->factory()->NewCallNew(function, args, pos); | 1883 return pre_parser_->factory()->NewCallNew(function, args, pos); |
| 1872 } | 1884 } |
| 1873 | 1885 |
| 1874 | 1886 |
| 1875 void PreParserTraits::ParseArrowFunctionFormalParameterList( | 1887 void PreParserTraits::ParseArrowFunctionFormalParameterList( |
| 1876 PreParserFormalParameters* parameters, | 1888 PreParserFormalParameters* parameters, |
| 1877 PreParserExpression params, const Scanner::Location& params_loc, | 1889 PreParserExpression params, const Scanner::Location& params_loc, |
| 1878 Scanner::Location* duplicate_loc, bool* ok) { | 1890 Scanner::Location* duplicate_loc, bool* ok) { |
| 1879 // TODO(wingo): Detect duplicated identifiers in paramlists. Detect parameter | 1891 // TODO(wingo): Detect duplicated identifiers in paramlists. Detect parameter |
| 1880 // lists that are too long. | 1892 // lists that are too long. |
| 1893 | |
| 1894 // Accomodate array literal for rest parameter. | |
| 1895 if (params.IsArrowFunctionFormalParametersWithRestParameter()) { | |
| 1896 ++parameters->materialized_literals_count; | |
| 1897 pre_parser_->function_state_->NextMaterializedLiteralIndex(); | |
| 1898 } | |
|
wingo
2015/09/01 14:41:20
I am OK with this I guess. Is it possible, possib
caitp (gmail)
2015/09/01 15:17:25
I think we'd be better off getting rid of FormalPa
| |
| 1881 } | 1899 } |
| 1882 | 1900 |
| 1883 | 1901 |
| 1884 PreParserStatementList PreParser::ParseEagerFunctionBody( | 1902 PreParserStatementList PreParser::ParseEagerFunctionBody( |
| 1885 PreParserIdentifier function_name, int pos, | 1903 PreParserIdentifier function_name, int pos, |
| 1886 const PreParserFormalParameters& parameters, FunctionKind kind, | 1904 const PreParserFormalParameters& parameters, FunctionKind kind, |
| 1887 FunctionLiteral::FunctionType function_type, bool* ok) { | 1905 FunctionLiteral::FunctionType function_type, bool* ok) { |
| 1888 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 1906 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
| 1889 | 1907 |
| 1890 ParseStatementList(Token::RBRACE, ok); | 1908 ParseStatementList(Token::RBRACE, ok); |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2409 // AssignmentExpression | 2427 // AssignmentExpression |
| 2410 // Expression ',' AssignmentExpression | 2428 // Expression ',' AssignmentExpression |
| 2411 | 2429 |
| 2412 ExpressionClassifier binding_classifier; | 2430 ExpressionClassifier binding_classifier; |
| 2413 ExpressionT result = | 2431 ExpressionT result = |
| 2414 this->ParseAssignmentExpression(accept_IN, &binding_classifier, CHECK_OK); | 2432 this->ParseAssignmentExpression(accept_IN, &binding_classifier, CHECK_OK); |
| 2415 classifier->Accumulate(binding_classifier, | 2433 classifier->Accumulate(binding_classifier, |
| 2416 ExpressionClassifier::AllProductions); | 2434 ExpressionClassifier::AllProductions); |
| 2417 bool is_simple_parameter_list = this->IsIdentifier(result); | 2435 bool is_simple_parameter_list = this->IsIdentifier(result); |
| 2418 bool seen_rest = false; | 2436 bool seen_rest = false; |
| 2437 | |
| 2419 while (peek() == Token::COMMA) { | 2438 while (peek() == Token::COMMA) { |
| 2420 if (seen_rest) { | 2439 if (seen_rest) { |
| 2421 // At this point the production can't possibly be valid, but we don't know | 2440 // At this point the production can't possibly be valid, but we don't know |
| 2422 // which error to signal. | 2441 // which error to signal. |
| 2423 classifier->RecordArrowFormalParametersError( | 2442 classifier->RecordArrowFormalParametersError( |
| 2424 scanner()->peek_location(), MessageTemplate::kParamAfterRest); | 2443 scanner()->peek_location(), MessageTemplate::kParamAfterRest); |
| 2425 } | 2444 } |
| 2426 Consume(Token::COMMA); | 2445 Consume(Token::COMMA); |
| 2446 Token::Value next = peek(); | |
| 2447 Scanner::Location next_location = scanner()->peek_location(); | |
| 2427 bool is_rest = false; | 2448 bool is_rest = false; |
| 2428 if (allow_harmony_rest_parameters() && peek() == Token::ELLIPSIS) { | 2449 if (allow_harmony_rest_parameters() && peek() == Token::ELLIPSIS) { |
| 2429 // 'x, y, ...z' in CoverParenthesizedExpressionAndArrowParameterList only | 2450 // 'x, y, ...z' in CoverParenthesizedExpressionAndArrowParameterList only |
| 2430 // as the formal parameters of'(x, y, ...z) => foo', and is not itself a | 2451 // as the formal parameters of'(x, y, ...z) => foo', and is not itself a |
| 2431 // valid expression or binding pattern. | 2452 // valid expression or binding pattern. |
| 2432 ExpressionUnexpectedToken(classifier); | 2453 ExpressionUnexpectedToken(classifier); |
| 2433 BindingPatternUnexpectedToken(classifier); | 2454 BindingPatternUnexpectedToken(classifier); |
| 2434 Consume(Token::ELLIPSIS); | 2455 Consume(Token::ELLIPSIS); |
| 2435 seen_rest = is_rest = true; | 2456 seen_rest = is_rest = true; |
| 2436 } | 2457 } |
| 2437 int pos = position(); | 2458 int pos = position(); |
| 2438 ExpressionT right = this->ParseAssignmentExpression( | 2459 ExpressionT right = this->ParseAssignmentExpression( |
| 2439 accept_IN, &binding_classifier, CHECK_OK); | 2460 accept_IN, &binding_classifier, CHECK_OK); |
| 2440 if (is_rest) right = factory()->NewSpread(right, pos); | 2461 if (is_rest) { |
| 2462 if (!this->IsIdentifier(right)) { | |
| 2463 ReportUnexpectedTokenAt(next_location, next); | |
|
wingo
2015/09/01 14:41:20
Why is this here? I can't reproduce this bug but
caitp (gmail)
2015/09/01 15:17:24
It produces a better error message --- it was move
| |
| 2464 *ok = false; | |
| 2465 return this->EmptyExpression(); | |
| 2466 } | |
| 2467 right = factory()->NewSpread(right, pos); | |
| 2468 } | |
| 2469 | |
| 2441 is_simple_parameter_list = | 2470 is_simple_parameter_list = |
| 2442 is_simple_parameter_list && this->IsIdentifier(right); | 2471 is_simple_parameter_list && this->IsIdentifier(right); |
| 2443 classifier->Accumulate(binding_classifier, | 2472 classifier->Accumulate(binding_classifier, |
| 2444 ExpressionClassifier::AllProductions); | 2473 ExpressionClassifier::AllProductions); |
| 2445 result = factory()->NewBinaryOperation(Token::COMMA, result, right, pos); | 2474 result = factory()->NewBinaryOperation(Token::COMMA, result, right, pos); |
| 2446 } | 2475 } |
| 2447 if (!is_simple_parameter_list || seen_rest) { | 2476 if (!is_simple_parameter_list || seen_rest) { |
| 2448 classifier->RecordNonSimpleParameter(); | 2477 classifier->RecordNonSimpleParameter(); |
| 2449 } | 2478 } |
| 2450 return result; | 2479 return result; |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2879 ValidateArrowFormalParameters(&arrow_formals_classifier, expression, | 2908 ValidateArrowFormalParameters(&arrow_formals_classifier, expression, |
| 2880 parenthesized_formals, CHECK_OK); | 2909 parenthesized_formals, CHECK_OK); |
| 2881 Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos); | 2910 Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos); |
| 2882 Scope* scope = | 2911 Scope* scope = |
| 2883 this->NewScope(scope_, ARROW_SCOPE, FunctionKind::kArrowFunction); | 2912 this->NewScope(scope_, ARROW_SCOPE, FunctionKind::kArrowFunction); |
| 2884 FormalParametersT parameters(scope); | 2913 FormalParametersT parameters(scope); |
| 2885 if (!arrow_formals_classifier.is_simple_parameter_list()) { | 2914 if (!arrow_formals_classifier.is_simple_parameter_list()) { |
| 2886 scope->SetHasNonSimpleParameters(); | 2915 scope->SetHasNonSimpleParameters(); |
| 2887 parameters.is_simple = false; | 2916 parameters.is_simple = false; |
| 2888 } | 2917 } |
| 2918 | |
| 2919 Scanner::Location duplicate_loc = Scanner::Location::invalid(); | |
| 2920 this->ParseArrowFunctionFormalParameterList(¶meters, expression, loc, | |
|
wingo
2015/09/01 14:41:20
Yeah moving this before the checkpoint just sounds
caitp (gmail)
2015/09/01 15:17:24
It's not currently possible with the FormalParamet
| |
| 2921 &duplicate_loc, CHECK_OK); | |
| 2922 | |
| 2889 checkpoint.Restore(¶meters.materialized_literals_count); | 2923 checkpoint.Restore(¶meters.materialized_literals_count); |
| 2890 | 2924 |
| 2891 scope->set_start_position(lhs_beg_pos); | 2925 scope->set_start_position(lhs_beg_pos); |
| 2892 Scanner::Location duplicate_loc = Scanner::Location::invalid(); | |
| 2893 this->ParseArrowFunctionFormalParameterList(¶meters, expression, loc, | |
| 2894 &duplicate_loc, CHECK_OK); | |
| 2895 if (duplicate_loc.IsValid()) { | 2926 if (duplicate_loc.IsValid()) { |
| 2896 arrow_formals_classifier.RecordDuplicateFormalParameterError( | 2927 arrow_formals_classifier.RecordDuplicateFormalParameterError( |
| 2897 duplicate_loc); | 2928 duplicate_loc); |
| 2898 } | 2929 } |
| 2930 | |
| 2899 expression = this->ParseArrowFunctionLiteral( | 2931 expression = this->ParseArrowFunctionLiteral( |
| 2900 parameters, arrow_formals_classifier, CHECK_OK); | 2932 parameters, arrow_formals_classifier, CHECK_OK); |
| 2901 return expression; | 2933 return expression; |
| 2902 } | 2934 } |
| 2903 | 2935 |
| 2904 // "expression" was not itself an arrow function parameter list, but it might | 2936 // "expression" was not itself an arrow function parameter list, but it might |
| 2905 // form part of one. Propagate speculative formal parameter error locations. | 2937 // form part of one. Propagate speculative formal parameter error locations. |
| 2906 classifier->Accumulate(arrow_formals_classifier, | 2938 classifier->Accumulate(arrow_formals_classifier, |
| 2907 ExpressionClassifier::StandardProductions | | 2939 ExpressionClassifier::StandardProductions | |
| 2908 ExpressionClassifier::FormalParametersProductions); | 2940 ExpressionClassifier::FormalParametersProductions); |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3674 default: | 3706 default: |
| 3675 return expression; | 3707 return expression; |
| 3676 } | 3708 } |
| 3677 } | 3709 } |
| 3678 DCHECK(false); | 3710 DCHECK(false); |
| 3679 return this->EmptyExpression(); | 3711 return this->EmptyExpression(); |
| 3680 } | 3712 } |
| 3681 | 3713 |
| 3682 | 3714 |
| 3683 template <class Traits> | 3715 template <class Traits> |
| 3684 void ParserBase<Traits>::ParseFormalParameter( | 3716 void ParserBase<Traits>::ParseFormalParameter(FormalParametersT* parameters, |
| 3685 FormalParametersT* parameters, ExpressionClassifier* classifier, bool* ok) { | 3717 ExpressionClassifier* classifier, |
| 3718 bool* ok) { | |
| 3686 // FormalParameter[Yield,GeneratorParameter] : | 3719 // FormalParameter[Yield,GeneratorParameter] : |
| 3687 // BindingElement[?Yield, ?GeneratorParameter] | 3720 // BindingElement[?Yield, ?GeneratorParameter] |
| 3688 bool is_rest = parameters->has_rest; | 3721 bool is_rest = parameters->has_rest; |
| 3689 | 3722 |
| 3690 Token::Value next = peek(); | 3723 Token::Value next = peek(); |
| 3691 ExpressionT pattern = ParsePrimaryExpression(classifier, ok); | 3724 ExpressionT pattern = ParsePrimaryExpression(classifier, ok); |
| 3692 if (!*ok) return; | 3725 if (!*ok) return; |
| 3693 | 3726 |
| 3694 ValidateBindingPattern(classifier, ok); | 3727 ValidateBindingPattern(classifier, ok); |
| 3695 if (!*ok) return; | 3728 if (!*ok) return; |
| 3696 | 3729 |
| 3697 if (!Traits::IsIdentifier(pattern)) { | 3730 if (!Traits::IsIdentifier(pattern)) { |
| 3698 if (is_rest || !allow_harmony_destructuring()) { | 3731 if (is_rest || !allow_harmony_destructuring()) { |
| 3699 ReportUnexpectedToken(next); | 3732 ReportUnexpectedToken(next); |
| 3700 *ok = false; | 3733 *ok = false; |
| 3701 return; | 3734 return; |
| 3702 } | 3735 } |
| 3703 parameters->is_simple = false; | 3736 parameters->is_simple = false; |
| 3704 ValidateFormalParameterInitializer(classifier, ok); | 3737 ValidateFormalParameterInitializer(classifier, ok); |
| 3705 if (!*ok) return; | 3738 if (!*ok) return; |
| 3706 classifier->RecordNonSimpleParameter(); | 3739 classifier->RecordNonSimpleParameter(); |
| 3707 } | 3740 } |
| 3708 | 3741 |
| 3742 if (is_rest) { | |
| 3743 parameters->rest_array_literal_index = | |
| 3744 function_state_->NextMaterializedLiteralIndex(); | |
| 3745 ++parameters->materialized_literals_count; | |
| 3746 } | |
| 3747 | |
| 3709 ExpressionT initializer = Traits::EmptyExpression(); | 3748 ExpressionT initializer = Traits::EmptyExpression(); |
| 3710 if (!is_rest && allow_harmony_default_parameters() && Check(Token::ASSIGN)) { | 3749 if (!is_rest && allow_harmony_default_parameters() && Check(Token::ASSIGN)) { |
| 3711 ExpressionClassifier init_classifier; | 3750 ExpressionClassifier init_classifier; |
| 3712 initializer = ParseAssignmentExpression(true, &init_classifier, ok); | 3751 initializer = ParseAssignmentExpression(true, &init_classifier, ok); |
| 3713 if (!*ok) return; | 3752 if (!*ok) return; |
| 3714 ValidateExpression(&init_classifier, ok); | 3753 ValidateExpression(&init_classifier, ok); |
| 3715 ValidateFormalParameterInitializer(&init_classifier, ok); | 3754 ValidateFormalParameterInitializer(&init_classifier, ok); |
| 3716 if (!*ok) return; | 3755 if (!*ok) return; |
| 3717 parameters->is_simple = false; | 3756 parameters->is_simple = false; |
| 3718 classifier->RecordNonSimpleParameter(); | 3757 classifier->RecordNonSimpleParameter(); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3859 | 3898 |
| 3860 if (peek() == Token::LBRACE) { | 3899 if (peek() == Token::LBRACE) { |
| 3861 // Multiple statement body | 3900 // Multiple statement body |
| 3862 Consume(Token::LBRACE); | 3901 Consume(Token::LBRACE); |
| 3863 bool is_lazily_parsed = | 3902 bool is_lazily_parsed = |
| 3864 (mode() == PARSE_LAZILY && scope_->AllowsLazyCompilation()); | 3903 (mode() == PARSE_LAZILY && scope_->AllowsLazyCompilation()); |
| 3865 if (is_lazily_parsed) { | 3904 if (is_lazily_parsed) { |
| 3866 body = this->NewStatementList(0, zone()); | 3905 body = this->NewStatementList(0, zone()); |
| 3867 this->SkipLazyFunctionBody(&materialized_literal_count, | 3906 this->SkipLazyFunctionBody(&materialized_literal_count, |
| 3868 &expected_property_count, CHECK_OK); | 3907 &expected_property_count, CHECK_OK); |
| 3908 | |
| 3909 if (formal_parameters.materialized_literals_count > 0) { | |
| 3910 materialized_literal_count += | |
| 3911 formal_parameters.materialized_literals_count; | |
| 3912 } | |
| 3869 } else { | 3913 } else { |
| 3870 body = this->ParseEagerFunctionBody( | 3914 body = this->ParseEagerFunctionBody( |
| 3871 this->EmptyIdentifier(), RelocInfo::kNoPosition, formal_parameters, | 3915 this->EmptyIdentifier(), RelocInfo::kNoPosition, formal_parameters, |
| 3872 kArrowFunction, FunctionLiteral::ANONYMOUS_EXPRESSION, CHECK_OK); | 3916 kArrowFunction, FunctionLiteral::ANONYMOUS_EXPRESSION, CHECK_OK); |
| 3873 materialized_literal_count = | 3917 materialized_literal_count = |
| 3874 function_state.materialized_literal_count(); | 3918 function_state.materialized_literal_count(); |
| 3875 expected_property_count = function_state.expected_property_count(); | 3919 expected_property_count = function_state.expected_property_count(); |
| 3876 } | 3920 } |
| 3877 } else { | 3921 } else { |
| 3878 // Single-expression body | 3922 // Single-expression body |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4125 *ok = false; | 4169 *ok = false; |
| 4126 return; | 4170 return; |
| 4127 } | 4171 } |
| 4128 has_seen_constructor_ = true; | 4172 has_seen_constructor_ = true; |
| 4129 return; | 4173 return; |
| 4130 } | 4174 } |
| 4131 } | 4175 } |
| 4132 } } // v8::internal | 4176 } } // v8::internal |
| 4133 | 4177 |
| 4134 #endif // V8_PREPARSER_H | 4178 #endif // V8_PREPARSER_H |
| OLD | NEW |