| 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/hashmap.h" | 10 #include "src/hashmap.h" |
| (...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 | 1728 |
| 1729 FunctionKind kind = is_generator ? FunctionKind::kConciseGeneratorMethod | 1729 FunctionKind kind = is_generator ? FunctionKind::kConciseGeneratorMethod |
| 1730 : FunctionKind::kConciseMethod; | 1730 : FunctionKind::kConciseMethod; |
| 1731 | 1731 |
| 1732 if (in_class && !is_static && this->IsConstructor(*name)) { | 1732 if (in_class && !is_static && this->IsConstructor(*name)) { |
| 1733 *has_seen_constructor = true; | 1733 *has_seen_constructor = true; |
| 1734 kind = has_extends ? FunctionKind::kSubclassConstructor | 1734 kind = has_extends ? FunctionKind::kSubclassConstructor |
| 1735 : FunctionKind::kBaseConstructor; | 1735 : FunctionKind::kBaseConstructor; |
| 1736 } | 1736 } |
| 1737 | 1737 |
| 1738 if (!in_class) kind = WithObjectLiteralBit(kind); | |
| 1739 | |
| 1740 value = this->ParseFunctionLiteral( | 1738 value = this->ParseFunctionLiteral( |
| 1741 *name, scanner()->location(), kSkipFunctionNameCheck, kind, | 1739 *name, scanner()->location(), kSkipFunctionNameCheck, kind, |
| 1742 RelocInfo::kNoPosition, FunctionLiteral::kAnonymousExpression, | 1740 RelocInfo::kNoPosition, FunctionLiteral::kAnonymousExpression, |
| 1743 FunctionLiteral::kNormalArity, language_mode(), | 1741 FunctionLiteral::kNormalArity, language_mode(), |
| 1744 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 1742 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 1745 | 1743 |
| 1746 return factory()->NewObjectLiteralProperty(name_expression, value, | 1744 return factory()->NewObjectLiteralProperty(name_expression, value, |
| 1747 ObjectLiteralProperty::COMPUTED, | 1745 ObjectLiteralProperty::COMPUTED, |
| 1748 is_static, *is_computed_name); | 1746 is_static, *is_computed_name); |
| 1749 } | 1747 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1771 name_expression = ParsePropertyName( | 1769 name_expression = ParsePropertyName( |
| 1772 name, &dont_care, &dont_care, is_computed_name, classifier, | 1770 name, &dont_care, &dont_care, is_computed_name, classifier, |
| 1773 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 1771 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 1774 | 1772 |
| 1775 if (!*is_computed_name) { | 1773 if (!*is_computed_name) { |
| 1776 checker->CheckProperty(name_token, kAccessorProperty, is_static, | 1774 checker->CheckProperty(name_token, kAccessorProperty, is_static, |
| 1777 is_generator, | 1775 is_generator, |
| 1778 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 1776 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 1779 } | 1777 } |
| 1780 | 1778 |
| 1781 FunctionKind kind = FunctionKind::kAccessorFunction; | |
| 1782 if (!in_class) kind = WithObjectLiteralBit(kind); | |
| 1783 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral( | 1779 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral( |
| 1784 *name, scanner()->location(), kSkipFunctionNameCheck, kind, | 1780 *name, scanner()->location(), kSkipFunctionNameCheck, |
| 1785 RelocInfo::kNoPosition, FunctionLiteral::kAnonymousExpression, | 1781 FunctionKind::kAccessorFunction, RelocInfo::kNoPosition, |
| 1782 FunctionLiteral::kAnonymousExpression, |
| 1786 is_get ? FunctionLiteral::kGetterArity : FunctionLiteral::kSetterArity, | 1783 is_get ? FunctionLiteral::kGetterArity : FunctionLiteral::kSetterArity, |
| 1787 language_mode(), CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 1784 language_mode(), CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 1788 | 1785 |
| 1789 // Make sure the name expression is a string since we need a Name for | 1786 // Make sure the name expression is a string since we need a Name for |
| 1790 // Runtime_DefineAccessorPropertyUnchecked and since we can determine this | 1787 // Runtime_DefineAccessorPropertyUnchecked and since we can determine this |
| 1791 // statically we can skip the extra runtime check. | 1788 // statically we can skip the extra runtime check. |
| 1792 if (!*is_computed_name) { | 1789 if (!*is_computed_name) { |
| 1793 name_expression = | 1790 name_expression = |
| 1794 factory()->NewStringLiteral(*name, name_expression->position()); | 1791 factory()->NewStringLiteral(*name, name_expression->position()); |
| 1795 } | 1792 } |
| (...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3363 return; | 3360 return; |
| 3364 } | 3361 } |
| 3365 has_seen_constructor_ = true; | 3362 has_seen_constructor_ = true; |
| 3366 return; | 3363 return; |
| 3367 } | 3364 } |
| 3368 } | 3365 } |
| 3369 } // namespace internal | 3366 } // namespace internal |
| 3370 } // namespace v8 | 3367 } // namespace v8 |
| 3371 | 3368 |
| 3372 #endif // V8_PARSING_PARSER_BASE_H | 3369 #endif // V8_PARSING_PARSER_BASE_H |
| OLD | NEW |