| 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_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
| 6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
| 7 | 7 |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
| 10 #include "src/base/hashmap.h" | 10 #include "src/base/hashmap.h" |
| 11 #include "src/globals.h" |
| 11 #include "src/messages.h" | 12 #include "src/messages.h" |
| 12 #include "src/parsing/expression-classifier.h" | 13 #include "src/parsing/expression-classifier.h" |
| 13 #include "src/parsing/func-name-inferrer.h" | 14 #include "src/parsing/func-name-inferrer.h" |
| 14 #include "src/parsing/scanner.h" | 15 #include "src/parsing/scanner.h" |
| 15 #include "src/parsing/token.h" | 16 #include "src/parsing/token.h" |
| 16 | 17 |
| 17 namespace v8 { | 18 namespace v8 { |
| 18 namespace internal { | 19 namespace internal { |
| 19 | 20 |
| 20 | 21 |
| (...skipping 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1971 if (peek() == Token::ASSIGN) { | 1972 if (peek() == Token::ASSIGN) { |
| 1972 Consume(Token::ASSIGN); | 1973 Consume(Token::ASSIGN); |
| 1973 ExpressionClassifier rhs_classifier(this); | 1974 ExpressionClassifier rhs_classifier(this); |
| 1974 ExpressionT rhs = this->ParseAssignmentExpression( | 1975 ExpressionT rhs = this->ParseAssignmentExpression( |
| 1975 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 1976 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 1976 Traits::RewriteNonPattern(&rhs_classifier, | 1977 Traits::RewriteNonPattern(&rhs_classifier, |
| 1977 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 1978 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 1978 classifier->Accumulate(&rhs_classifier, | 1979 classifier->Accumulate(&rhs_classifier, |
| 1979 ExpressionClassifier::ExpressionProductions); | 1980 ExpressionClassifier::ExpressionProductions); |
| 1980 value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs, | 1981 value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs, |
| 1981 RelocInfo::kNoPosition); | 1982 kNoSourcePosition); |
| 1982 classifier->RecordCoverInitializedNameError( | 1983 classifier->RecordCoverInitializedNameError( |
| 1983 Scanner::Location(next_beg_pos, scanner()->location().end_pos), | 1984 Scanner::Location(next_beg_pos, scanner()->location().end_pos), |
| 1984 MessageTemplate::kInvalidCoverInitializedName); | 1985 MessageTemplate::kInvalidCoverInitializedName); |
| 1985 | 1986 |
| 1986 Traits::SetFunctionNameFromIdentifierRef(rhs, lhs); | 1987 Traits::SetFunctionNameFromIdentifierRef(rhs, lhs); |
| 1987 } else { | 1988 } else { |
| 1988 value = lhs; | 1989 value = lhs; |
| 1989 } | 1990 } |
| 1990 | 1991 |
| 1991 return factory()->NewObjectLiteralProperty( | 1992 return factory()->NewObjectLiteralProperty( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 | 2026 |
| 2026 if (in_class && !IsStaticMethod(method_kind) && | 2027 if (in_class && !IsStaticMethod(method_kind) && |
| 2027 this->IsConstructor(*name)) { | 2028 this->IsConstructor(*name)) { |
| 2028 *has_seen_constructor = true; | 2029 *has_seen_constructor = true; |
| 2029 kind = has_extends ? FunctionKind::kSubclassConstructor | 2030 kind = has_extends ? FunctionKind::kSubclassConstructor |
| 2030 : FunctionKind::kBaseConstructor; | 2031 : FunctionKind::kBaseConstructor; |
| 2031 } | 2032 } |
| 2032 | 2033 |
| 2033 value = this->ParseFunctionLiteral( | 2034 value = this->ParseFunctionLiteral( |
| 2034 *name, scanner()->location(), kSkipFunctionNameCheck, kind, | 2035 *name, scanner()->location(), kSkipFunctionNameCheck, kind, |
| 2035 RelocInfo::kNoPosition, FunctionLiteral::kAccessorOrMethod, | 2036 kNoSourcePosition, FunctionLiteral::kAccessorOrMethod, language_mode(), |
| 2036 language_mode(), CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2037 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 2037 | 2038 |
| 2038 return factory()->NewObjectLiteralProperty(name_expression, value, | 2039 return factory()->NewObjectLiteralProperty(name_expression, value, |
| 2039 ObjectLiteralProperty::COMPUTED, | 2040 ObjectLiteralProperty::COMPUTED, |
| 2040 is_static, *is_computed_name); | 2041 is_static, *is_computed_name); |
| 2041 } | 2042 } |
| 2042 | 2043 |
| 2043 if (in_class && name_token == Token::STATIC && IsNormalMethod(method_kind)) { | 2044 if (in_class && name_token == Token::STATIC && IsNormalMethod(method_kind)) { |
| 2044 // ClassElement (static) | 2045 // ClassElement (static) |
| 2045 // 'static' MethodDefinition | 2046 // 'static' MethodDefinition |
| 2046 *name = this->EmptyIdentifier(); | 2047 *name = this->EmptyIdentifier(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2064 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2065 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 2065 | 2066 |
| 2066 if (!*is_computed_name) { | 2067 if (!*is_computed_name) { |
| 2067 checker->CheckProperty(name_token, kAccessorProperty, method_kind, | 2068 checker->CheckProperty(name_token, kAccessorProperty, method_kind, |
| 2068 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2069 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 2069 } | 2070 } |
| 2070 | 2071 |
| 2071 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral( | 2072 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral( |
| 2072 *name, scanner()->location(), kSkipFunctionNameCheck, | 2073 *name, scanner()->location(), kSkipFunctionNameCheck, |
| 2073 is_get ? FunctionKind::kGetterFunction : FunctionKind::kSetterFunction, | 2074 is_get ? FunctionKind::kGetterFunction : FunctionKind::kSetterFunction, |
| 2074 RelocInfo::kNoPosition, FunctionLiteral::kAccessorOrMethod, | 2075 kNoSourcePosition, FunctionLiteral::kAccessorOrMethod, language_mode(), |
| 2075 language_mode(), CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2076 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 2076 | 2077 |
| 2077 // Make sure the name expression is a string since we need a Name for | 2078 // Make sure the name expression is a string since we need a Name for |
| 2078 // Runtime_DefineAccessorPropertyUnchecked and since we can determine this | 2079 // Runtime_DefineAccessorPropertyUnchecked and since we can determine this |
| 2079 // statically we can skip the extra runtime check. | 2080 // statically we can skip the extra runtime check. |
| 2080 if (!*is_computed_name) { | 2081 if (!*is_computed_name) { |
| 2081 name_expression = | 2082 name_expression = |
| 2082 factory()->NewStringLiteral(*name, name_expression->position()); | 2083 factory()->NewStringLiteral(*name, name_expression->position()); |
| 2083 } | 2084 } |
| 2084 | 2085 |
| 2085 return factory()->NewObjectLiteralProperty( | 2086 return factory()->NewObjectLiteralProperty( |
| (...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3358 if (is_lazily_parsed) { | 3359 if (is_lazily_parsed) { |
| 3359 body = this->NewStatementList(0, zone()); | 3360 body = this->NewStatementList(0, zone()); |
| 3360 this->SkipLazyFunctionBody(&materialized_literal_count, | 3361 this->SkipLazyFunctionBody(&materialized_literal_count, |
| 3361 &expected_property_count, CHECK_OK); | 3362 &expected_property_count, CHECK_OK); |
| 3362 if (formal_parameters.materialized_literals_count > 0) { | 3363 if (formal_parameters.materialized_literals_count > 0) { |
| 3363 materialized_literal_count += | 3364 materialized_literal_count += |
| 3364 formal_parameters.materialized_literals_count; | 3365 formal_parameters.materialized_literals_count; |
| 3365 } | 3366 } |
| 3366 } else { | 3367 } else { |
| 3367 body = this->ParseEagerFunctionBody( | 3368 body = this->ParseEagerFunctionBody( |
| 3368 this->EmptyIdentifier(), RelocInfo::kNoPosition, formal_parameters, | 3369 this->EmptyIdentifier(), kNoSourcePosition, formal_parameters, |
| 3369 arrow_kind, FunctionLiteral::kAnonymousExpression, CHECK_OK); | 3370 arrow_kind, FunctionLiteral::kAnonymousExpression, CHECK_OK); |
| 3370 materialized_literal_count = | 3371 materialized_literal_count = |
| 3371 function_state.materialized_literal_count(); | 3372 function_state.materialized_literal_count(); |
| 3372 expected_property_count = function_state.expected_property_count(); | 3373 expected_property_count = function_state.expected_property_count(); |
| 3373 } | 3374 } |
| 3374 } else { | 3375 } else { |
| 3375 // Single-expression body | 3376 // Single-expression body |
| 3376 int pos = position(); | 3377 int pos = position(); |
| 3377 DCHECK(ReturnExprContext::kInsideValidBlock == | 3378 DCHECK(ReturnExprContext::kInsideValidBlock == |
| 3378 function_state_->return_expr_context()); | 3379 function_state_->return_expr_context()); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3650 has_seen_constructor_ = true; | 3651 has_seen_constructor_ = true; |
| 3651 return; | 3652 return; |
| 3652 } | 3653 } |
| 3653 } | 3654 } |
| 3654 | 3655 |
| 3655 | 3656 |
| 3656 } // namespace internal | 3657 } // namespace internal |
| 3657 } // namespace v8 | 3658 } // namespace v8 |
| 3658 | 3659 |
| 3659 #endif // V8_PARSING_PARSER_BASE_H | 3660 #endif // V8_PARSING_PARSER_BASE_H |
| OLD | NEW |