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 3319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3330 BindingPatternUnexpectedToken(classifier); | 3330 BindingPatternUnexpectedToken(classifier); |
3331 ArrowFormalParametersUnexpectedToken(classifier); | 3331 ArrowFormalParametersUnexpectedToken(classifier); |
3332 | 3332 |
3333 if (is_strong(language_mode()) && this->IsIdentifier(result) && | 3333 if (is_strong(language_mode()) && this->IsIdentifier(result) && |
3334 this->IsEval(this->AsIdentifier(result))) { | 3334 this->IsEval(this->AsIdentifier(result))) { |
3335 ReportMessage(MessageTemplate::kStrongDirectEval); | 3335 ReportMessage(MessageTemplate::kStrongDirectEval); |
3336 *ok = false; | 3336 *ok = false; |
3337 return this->EmptyExpression(); | 3337 return this->EmptyExpression(); |
3338 } | 3338 } |
3339 int pos; | 3339 int pos; |
3340 if (scanner()->current_token() == Token::IDENTIFIER) { | 3340 if (scanner()->current_token() == Token::IDENTIFIER || |
| 3341 scanner()->current_token() == Token::SUPER) { |
3341 // For call of an identifier we want to report position of | 3342 // For call of an identifier we want to report position of |
3342 // the identifier as position of the call in the stack trace. | 3343 // the identifier as position of the call in the stack trace. |
3343 pos = position(); | 3344 pos = position(); |
3344 } else { | 3345 } else { |
3345 // For other kinds of calls we record position of the parenthesis as | 3346 // For other kinds of calls we record position of the parenthesis as |
3346 // position of the call. Note that this is extremely important for | 3347 // position of the call. Note that this is extremely important for |
3347 // expressions of the form function(){...}() for which call position | 3348 // expressions of the form function(){...}() for which call position |
3348 // should not point to the closing brace otherwise it will intersect | 3349 // should not point to the closing brace otherwise it will intersect |
3349 // with positions recorded for function literal and confuse debugger. | 3350 // with positions recorded for function literal and confuse debugger. |
3350 pos = peek_position(); | 3351 pos = peek_position(); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3670 ExpressionT this_expr = this->ThisExpression(scope_, factory(), pos); | 3671 ExpressionT this_expr = this->ThisExpression(scope_, factory(), pos); |
3671 return factory()->NewAssignment(Token::INIT, this_expr, expr, pos); | 3672 return factory()->NewAssignment(Token::INIT, this_expr, expr, pos); |
3672 } | 3673 } |
3673 | 3674 |
3674 | 3675 |
3675 template <class Traits> | 3676 template <class Traits> |
3676 typename ParserBase<Traits>::ExpressionT | 3677 typename ParserBase<Traits>::ExpressionT |
3677 ParserBase<Traits>::ParseSuperExpression(bool is_new, | 3678 ParserBase<Traits>::ParseSuperExpression(bool is_new, |
3678 ExpressionClassifier* classifier, | 3679 ExpressionClassifier* classifier, |
3679 bool* ok) { | 3680 bool* ok) { |
| 3681 Expect(Token::SUPER, CHECK_OK); |
3680 int pos = position(); | 3682 int pos = position(); |
3681 Expect(Token::SUPER, CHECK_OK); | |
3682 | 3683 |
3683 Scope* scope = scope_->ReceiverScope(); | 3684 Scope* scope = scope_->ReceiverScope(); |
3684 FunctionKind kind = scope->function_kind(); | 3685 FunctionKind kind = scope->function_kind(); |
3685 if (IsConciseMethod(kind) || IsAccessorFunction(kind) || | 3686 if (IsConciseMethod(kind) || IsAccessorFunction(kind) || |
3686 IsClassConstructor(kind)) { | 3687 IsClassConstructor(kind)) { |
3687 if (peek() == Token::PERIOD || peek() == Token::LBRACK) { | 3688 if (peek() == Token::PERIOD || peek() == Token::LBRACK) { |
3688 scope->RecordSuperPropertyUsage(); | 3689 scope->RecordSuperPropertyUsage(); |
3689 return this->SuperPropertyReference(scope_, factory(), pos); | 3690 return this->SuperPropertyReference(scope_, factory(), pos); |
3690 } | 3691 } |
3691 // new super() is never allowed. | 3692 // new super() is never allowed. |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4250 return; | 4251 return; |
4251 } | 4252 } |
4252 has_seen_constructor_ = true; | 4253 has_seen_constructor_ = true; |
4253 return; | 4254 return; |
4254 } | 4255 } |
4255 } | 4256 } |
4256 } // namespace internal | 4257 } // namespace internal |
4257 } // namespace v8 | 4258 } // namespace v8 |
4258 | 4259 |
4259 #endif // V8_PREPARSER_H | 4260 #endif // V8_PREPARSER_H |
OLD | NEW |