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/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 return PreParserExpression::Super(); | 1318 return PreParserExpression::Super(); |
1319 } | 1319 } |
1320 | 1320 |
1321 static PreParserExpression ClassExpression( | 1321 static PreParserExpression ClassExpression( |
1322 PreParserIdentifier name, PreParserExpression extends, | 1322 PreParserIdentifier name, PreParserExpression extends, |
1323 PreParserExpression constructor, PreParserExpressionList properties, | 1323 PreParserExpression constructor, PreParserExpressionList properties, |
1324 int start_position, int end_position, PreParserFactory* factory) { | 1324 int start_position, int end_position, PreParserFactory* factory) { |
1325 return PreParserExpression::Default(); | 1325 return PreParserExpression::Default(); |
1326 } | 1326 } |
1327 | 1327 |
| 1328 static PreParserExpression DefaultConstructor(bool call_super, |
| 1329 PreParserScope* scope) { |
| 1330 return PreParserExpression::Default(); |
| 1331 } |
| 1332 |
1328 static PreParserExpression ExpressionFromLiteral( | 1333 static PreParserExpression ExpressionFromLiteral( |
1329 Token::Value token, int pos, Scanner* scanner, | 1334 Token::Value token, int pos, Scanner* scanner, |
1330 PreParserFactory* factory) { | 1335 PreParserFactory* factory) { |
1331 return PreParserExpression::Default(); | 1336 return PreParserExpression::Default(); |
1332 } | 1337 } |
1333 | 1338 |
1334 static PreParserExpression ExpressionFromIdentifier( | 1339 static PreParserExpression ExpressionFromIdentifier( |
1335 PreParserIdentifier name, int pos, PreParserScope* scope, | 1340 PreParserIdentifier name, int pos, PreParserScope* scope, |
1336 PreParserFactory* factory) { | 1341 PreParserFactory* factory) { |
1337 return PreParserExpression::FromIdentifier(name); | 1342 return PreParserExpression::FromIdentifier(name); |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2740 ReportMessageAt(class_name_location, "unexpected_strict_reserved"); | 2745 ReportMessageAt(class_name_location, "unexpected_strict_reserved"); |
2741 *ok = false; | 2746 *ok = false; |
2742 return this->EmptyExpression(); | 2747 return this->EmptyExpression(); |
2743 } | 2748 } |
2744 if (this->IsEvalOrArguments(name)) { | 2749 if (this->IsEvalOrArguments(name)) { |
2745 ReportMessageAt(class_name_location, "strict_eval_arguments"); | 2750 ReportMessageAt(class_name_location, "strict_eval_arguments"); |
2746 *ok = false; | 2751 *ok = false; |
2747 return this->EmptyExpression(); | 2752 return this->EmptyExpression(); |
2748 } | 2753 } |
2749 | 2754 |
| 2755 bool has_extends = false; |
2750 ExpressionT extends = this->EmptyExpression(); | 2756 ExpressionT extends = this->EmptyExpression(); |
2751 if (Check(Token::EXTENDS)) { | 2757 if (Check(Token::EXTENDS)) { |
2752 typename Traits::Type::ScopePtr scope = this->NewScope(scope_, BLOCK_SCOPE); | 2758 typename Traits::Type::ScopePtr scope = this->NewScope(scope_, BLOCK_SCOPE); |
2753 BlockState block_state(&scope_, Traits::Type::ptr_to_scope(scope)); | 2759 BlockState block_state(&scope_, Traits::Type::ptr_to_scope(scope)); |
2754 scope_->SetStrictMode(STRICT); | 2760 scope_->SetStrictMode(STRICT); |
2755 extends = this->ParseLeftHandSideExpression(CHECK_OK); | 2761 extends = this->ParseLeftHandSideExpression(CHECK_OK); |
| 2762 has_extends = true; |
2756 } | 2763 } |
2757 | 2764 |
2758 // TODO(arv): Implement scopes and name binding in class body only. | 2765 // TODO(arv): Implement scopes and name binding in class body only. |
2759 typename Traits::Type::ScopePtr scope = this->NewScope(scope_, BLOCK_SCOPE); | 2766 typename Traits::Type::ScopePtr scope = this->NewScope(scope_, BLOCK_SCOPE); |
2760 BlockState block_state(&scope_, Traits::Type::ptr_to_scope(scope)); | 2767 BlockState block_state(&scope_, Traits::Type::ptr_to_scope(scope)); |
2761 scope_->SetStrictMode(STRICT); | 2768 scope_->SetStrictMode(STRICT); |
2762 scope_->SetScopeName(name); | 2769 scope_->SetScopeName(name); |
2763 | 2770 |
2764 typename Traits::Type::PropertyList properties = | 2771 typename Traits::Type::PropertyList properties = |
2765 this->NewPropertyList(4, zone_); | 2772 this->NewPropertyList(4, zone_); |
(...skipping 18 matching lines...) Expand all Loading... |
2784 | 2791 |
2785 if (fni_ != NULL) { | 2792 if (fni_ != NULL) { |
2786 fni_->Infer(); | 2793 fni_->Infer(); |
2787 fni_->Leave(); | 2794 fni_->Leave(); |
2788 } | 2795 } |
2789 } | 2796 } |
2790 | 2797 |
2791 int end_pos = peek_position(); | 2798 int end_pos = peek_position(); |
2792 Expect(Token::RBRACE, CHECK_OK); | 2799 Expect(Token::RBRACE, CHECK_OK); |
2793 | 2800 |
| 2801 if (!has_seen_constructor) { |
| 2802 constructor = this->DefaultConstructor(has_extends, scope_); |
| 2803 } |
| 2804 |
2794 return this->ClassExpression(name, extends, constructor, properties, pos, | 2805 return this->ClassExpression(name, extends, constructor, properties, pos, |
2795 end_pos + 1, factory()); | 2806 end_pos + 1, factory()); |
2796 } | 2807 } |
2797 | 2808 |
2798 | 2809 |
2799 template <typename Traits> | 2810 template <typename Traits> |
2800 typename ParserBase<Traits>::ExpressionT | 2811 typename ParserBase<Traits>::ExpressionT |
2801 ParserBase<Traits>::CheckAndRewriteReferenceExpression( | 2812 ParserBase<Traits>::CheckAndRewriteReferenceExpression( |
2802 ExpressionT expression, | 2813 ExpressionT expression, |
2803 Scanner::Location location, const char* message, bool* ok) { | 2814 Scanner::Location location, const char* message, bool* ok) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2848 DCHECK(IsAccessorAccessorConflict(old_type, type)); | 2859 DCHECK(IsAccessorAccessorConflict(old_type, type)); |
2849 // Both accessors of the same type. | 2860 // Both accessors of the same type. |
2850 parser()->ReportMessage("accessor_get_set"); | 2861 parser()->ReportMessage("accessor_get_set"); |
2851 } | 2862 } |
2852 *ok = false; | 2863 *ok = false; |
2853 } | 2864 } |
2854 } | 2865 } |
2855 } } // v8::internal | 2866 } } // v8::internal |
2856 | 2867 |
2857 #endif // V8_PREPARSER_H | 2868 #endif // V8_PREPARSER_H |
OLD | NEW |