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 2638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2649 | 2649 |
| 2650 return factory()->NewObjectLiteralProperty(name_expression, value, | 2650 return factory()->NewObjectLiteralProperty(name_expression, value, |
| 2651 ObjectLiteralProperty::COMPUTED, | 2651 ObjectLiteralProperty::COMPUTED, |
| 2652 is_static, *is_computed_name); | 2652 is_static, *is_computed_name); |
| 2653 | 2653 |
| 2654 } else if (in_class && name_is_static && !is_static) { | 2654 } else if (in_class && name_is_static && !is_static) { |
| 2655 // static MethodDefinition | 2655 // static MethodDefinition |
| 2656 return ParsePropertyDefinition(checker, true, has_extends, true, | 2656 return ParsePropertyDefinition(checker, true, has_extends, true, |
| 2657 is_computed_name, nullptr, classifier, ok); | 2657 is_computed_name, nullptr, classifier, ok); |
| 2658 } else if (is_get || is_set) { | 2658 } else if (is_get || is_set) { |
| 2659 name_token = peek(); | |
| 2660 if (!in_class && | |
| 2661 (name_token == Token::ASSIGN || name_token == Token::COMMA || | |
| 2662 name_token == Token::RBRACE)) { | |
| 2663 goto shorthand_property; | |
|
adamk
2015/09/08 23:17:17
Can't you just do without the goto?
} else if ((i
caitp (gmail)
2015/09/08 23:35:13
That's true. I think this is still a confusing hac
| |
| 2664 } | |
| 2665 | |
| 2659 // Accessor | 2666 // Accessor |
| 2660 name = this->EmptyIdentifier(); | 2667 name = this->EmptyIdentifier(); |
| 2661 bool dont_care = false; | 2668 bool dont_care = false; |
| 2662 name_token = peek(); | |
| 2663 | 2669 |
| 2664 name_expression = ParsePropertyName( | 2670 name_expression = ParsePropertyName( |
| 2665 &name, &dont_care, &dont_care, &dont_care, is_computed_name, classifier, | 2671 &name, &dont_care, &dont_care, &dont_care, is_computed_name, classifier, |
| 2666 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2672 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 2667 | 2673 |
| 2668 if (!*is_computed_name) { | 2674 if (!*is_computed_name) { |
| 2669 checker->CheckProperty(name_token, kAccessorProperty, is_static, | 2675 checker->CheckProperty(name_token, kAccessorProperty, is_static, |
| 2670 is_generator, | 2676 is_generator, |
| 2671 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2677 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 2672 } | 2678 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2687 factory()->NewStringLiteral(name, name_expression->position()); | 2693 factory()->NewStringLiteral(name, name_expression->position()); |
| 2688 } | 2694 } |
| 2689 | 2695 |
| 2690 return factory()->NewObjectLiteralProperty( | 2696 return factory()->NewObjectLiteralProperty( |
| 2691 name_expression, value, | 2697 name_expression, value, |
| 2692 is_get ? ObjectLiteralProperty::GETTER : ObjectLiteralProperty::SETTER, | 2698 is_get ? ObjectLiteralProperty::GETTER : ObjectLiteralProperty::SETTER, |
| 2693 is_static, *is_computed_name); | 2699 is_static, *is_computed_name); |
| 2694 | 2700 |
| 2695 } else if (!in_class && Token::IsIdentifier(name_token, language_mode(), | 2701 } else if (!in_class && Token::IsIdentifier(name_token, language_mode(), |
| 2696 this->is_generator())) { | 2702 this->is_generator())) { |
| 2703 shorthand_property: | |
| 2697 DCHECK(!*is_computed_name); | 2704 DCHECK(!*is_computed_name); |
| 2698 DCHECK(!is_static); | 2705 DCHECK(!is_static); |
| 2699 | 2706 |
| 2700 if (classifier->duplicate_finder() != nullptr && | 2707 if (classifier->duplicate_finder() != nullptr && |
| 2701 scanner()->FindSymbol(classifier->duplicate_finder(), 1) != 0) { | 2708 scanner()->FindSymbol(classifier->duplicate_finder(), 1) != 0) { |
| 2702 classifier->RecordDuplicateFormalParameterError(scanner()->location()); | 2709 classifier->RecordDuplicateFormalParameterError(scanner()->location()); |
| 2703 } | 2710 } |
| 2704 | 2711 |
| 2705 ExpressionT lhs = this->ExpressionFromIdentifier( | 2712 ExpressionT lhs = this->ExpressionFromIdentifier( |
| 2706 name, next_beg_pos, next_end_pos, scope_, factory()); | 2713 name, next_beg_pos, next_end_pos, scope_, factory()); |
| (...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4157 *ok = false; | 4164 *ok = false; |
| 4158 return; | 4165 return; |
| 4159 } | 4166 } |
| 4160 has_seen_constructor_ = true; | 4167 has_seen_constructor_ = true; |
| 4161 return; | 4168 return; |
| 4162 } | 4169 } |
| 4163 } | 4170 } |
| 4164 } } // v8::internal | 4171 } } // v8::internal |
| 4165 | 4172 |
| 4166 #endif // V8_PREPARSER_H | 4173 #endif // V8_PREPARSER_H |
| OLD | NEW |