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 2718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2729 } | 2729 } |
2730 | 2730 |
2731 result = ParseMemberExpressionContinuation(result, CHECK_OK); | 2731 result = ParseMemberExpressionContinuation(result, CHECK_OK); |
2732 return result; | 2732 return result; |
2733 } | 2733 } |
2734 | 2734 |
2735 | 2735 |
2736 template <class Traits> | 2736 template <class Traits> |
2737 typename ParserBase<Traits>::ExpressionT | 2737 typename ParserBase<Traits>::ExpressionT |
2738 ParserBase<Traits>::ParseSuperExpression(bool is_new, bool* ok) { | 2738 ParserBase<Traits>::ParseSuperExpression(bool is_new, bool* ok) { |
2739 int beg_pos = position(); | |
2740 Expect(Token::SUPER, CHECK_OK); | 2739 Expect(Token::SUPER, CHECK_OK); |
2741 | 2740 |
2742 FunctionState* function_state = function_state_; | 2741 FunctionState* function_state = function_state_; |
2743 while (IsArrowFunction(function_state->kind())) { | 2742 while (IsArrowFunction(function_state->kind())) { |
2744 function_state = function_state->outer(); | 2743 function_state = function_state->outer(); |
2745 } | 2744 } |
2746 // TODO(arv): Handle eval scopes similarly. | 2745 // TODO(arv): Handle eval scopes similarly. |
2747 | 2746 |
2748 FunctionKind kind = function_state->kind(); | 2747 FunctionKind kind = function_state->kind(); |
2749 if (IsConciseMethod(kind) || IsAccessorFunction(kind) || | 2748 if (IsConciseMethod(kind) || IsAccessorFunction(kind) || |
2750 i::IsConstructor(kind)) { | 2749 i::IsConstructor(kind)) { |
2751 if (peek() == Token::PERIOD || peek() == Token::LBRACK) { | 2750 if (peek() == Token::PERIOD || peek() == Token::LBRACK) { |
2752 scope_->RecordSuperPropertyUsage(); | 2751 scope_->RecordSuperPropertyUsage(); |
2753 return this->SuperReference(scope_, factory()); | 2752 return this->SuperReference(scope_, factory()); |
2754 } | 2753 } |
2755 // new super() is never allowed. | 2754 // new super() is never allowed. |
2756 // super() is only allowed in constructor | 2755 // super() is only allowed in constructor |
2757 if (!is_new && peek() == Token::LPAREN && i::IsConstructor(kind)) { | 2756 if (!is_new && peek() == Token::LPAREN && i::IsConstructor(kind)) { |
2758 scope_->RecordSuperConstructorCallUsage(); | 2757 scope_->RecordSuperConstructorCallUsage(); |
2759 return this->SuperReference(scope_, factory()); | 2758 return this->SuperReference(scope_, factory()); |
2760 } | 2759 } |
2761 } | 2760 } |
2762 | 2761 |
2763 ReportMessageAt(Scanner::Location(beg_pos, position()), "unexpected_super"); | 2762 ReportMessageAt(scanner()->location(), "unexpected_super"); |
2764 *ok = false; | 2763 *ok = false; |
2765 return this->EmptyExpression(); | 2764 return this->EmptyExpression(); |
2766 } | 2765 } |
2767 | 2766 |
2768 | 2767 |
2769 template <class Traits> | 2768 template <class Traits> |
2770 typename ParserBase<Traits>::ExpressionT | 2769 typename ParserBase<Traits>::ExpressionT |
2771 ParserBase<Traits>::ParseMemberExpressionContinuation(ExpressionT expression, | 2770 ParserBase<Traits>::ParseMemberExpressionContinuation(ExpressionT expression, |
2772 bool* ok) { | 2771 bool* ok) { |
2773 // Parses this part of MemberExpression: | 2772 // Parses this part of MemberExpression: |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3078 *ok = false; | 3077 *ok = false; |
3079 return; | 3078 return; |
3080 } | 3079 } |
3081 has_seen_constructor_ = true; | 3080 has_seen_constructor_ = true; |
3082 return; | 3081 return; |
3083 } | 3082 } |
3084 } | 3083 } |
3085 } } // v8::internal | 3084 } } // v8::internal |
3086 | 3085 |
3087 #endif // V8_PREPARSER_H | 3086 #endif // V8_PREPARSER_H |
OLD | NEW |