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" |
(...skipping 3030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3041 bool* ok) { | 3041 bool* ok) { |
3042 Expect(Token::SUPER, CHECK_OK); | 3042 Expect(Token::SUPER, CHECK_OK); |
3043 int pos = position(); | 3043 int pos = position(); |
3044 | 3044 |
3045 Scope* scope = scope_->ReceiverScope(); | 3045 Scope* scope = scope_->ReceiverScope(); |
3046 FunctionKind kind = scope->function_kind(); | 3046 FunctionKind kind = scope->function_kind(); |
3047 if (IsConciseMethod(kind) || IsAccessorFunction(kind) || | 3047 if (IsConciseMethod(kind) || IsAccessorFunction(kind) || |
3048 IsClassConstructor(kind)) { | 3048 IsClassConstructor(kind)) { |
3049 if (peek() == Token::PERIOD || peek() == Token::LBRACK) { | 3049 if (peek() == Token::PERIOD || peek() == Token::LBRACK) { |
3050 scope->RecordSuperPropertyUsage(); | 3050 scope->RecordSuperPropertyUsage(); |
3051 return this->SuperPropertyReference(scope_, factory(), pos); | 3051 return this->NewSuperPropertyReference(scope_, factory(), pos); |
3052 } | 3052 } |
3053 // new super() is never allowed. | 3053 // new super() is never allowed. |
3054 // super() is only allowed in derived constructor | 3054 // super() is only allowed in derived constructor |
3055 if (!is_new && peek() == Token::LPAREN && IsSubclassConstructor(kind)) { | 3055 if (!is_new && peek() == Token::LPAREN && IsSubclassConstructor(kind)) { |
3056 // TODO(rossberg): This might not be the correct FunctionState for the | 3056 // TODO(rossberg): This might not be the correct FunctionState for the |
3057 // method here. | 3057 // method here. |
3058 function_state_->set_super_location(scanner()->location()); | 3058 function_state_->set_super_location(scanner()->location()); |
3059 return this->SuperCallReference(scope_, factory(), pos); | 3059 return this->NewSuperCallReference(scope_, factory(), pos); |
3060 } | 3060 } |
3061 } | 3061 } |
3062 | 3062 |
3063 ReportMessageAt(scanner()->location(), MessageTemplate::kUnexpectedSuper); | 3063 ReportMessageAt(scanner()->location(), MessageTemplate::kUnexpectedSuper); |
3064 *ok = false; | 3064 *ok = false; |
3065 return this->EmptyExpression(); | 3065 return this->EmptyExpression(); |
3066 } | 3066 } |
3067 | 3067 |
3068 template <class Traits> | 3068 template <class Traits> |
3069 void ParserBase<Traits>::ExpectMetaProperty(Vector<const char> property_name, | 3069 void ParserBase<Traits>::ExpectMetaProperty(Vector<const char> property_name, |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3651 has_seen_constructor_ = true; | 3651 has_seen_constructor_ = true; |
3652 return; | 3652 return; |
3653 } | 3653 } |
3654 } | 3654 } |
3655 | 3655 |
3656 | 3656 |
3657 } // namespace internal | 3657 } // namespace internal |
3658 } // namespace v8 | 3658 } // namespace v8 |
3659 | 3659 |
3660 #endif // V8_PARSING_PARSER_BASE_H | 3660 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |