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 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1708 static PreParserIdentifier GetNextSymbol(Scanner* scanner) { | 1708 static PreParserIdentifier GetNextSymbol(Scanner* scanner) { |
1709 return PreParserIdentifier::Default(); | 1709 return PreParserIdentifier::Default(); |
1710 } | 1710 } |
1711 | 1711 |
1712 static PreParserExpression ThisExpression(Scope* scope, | 1712 static PreParserExpression ThisExpression(Scope* scope, |
1713 PreParserFactory* factory, | 1713 PreParserFactory* factory, |
1714 int pos) { | 1714 int pos) { |
1715 return PreParserExpression::This(); | 1715 return PreParserExpression::This(); |
1716 } | 1716 } |
1717 | 1717 |
1718 static PreParserExpression SuperReference(Scope* scope, | 1718 static PreParserExpression SuperPropertyReference(Scope* scope, |
1719 PreParserFactory* factory, | 1719 PreParserFactory* factory, |
1720 int pos) { | 1720 int pos) { |
1721 return PreParserExpression::Default(); | 1721 return PreParserExpression::Default(); |
1722 } | 1722 } |
1723 | 1723 |
| 1724 static PreParserExpression SuperCallReference(Scope* scope, |
| 1725 PreParserFactory* factory, |
| 1726 int pos) { |
| 1727 return PreParserExpression::Default(); |
| 1728 } |
| 1729 |
1724 static PreParserExpression DefaultConstructor(bool call_super, Scope* scope, | 1730 static PreParserExpression DefaultConstructor(bool call_super, Scope* scope, |
1725 int pos, int end_pos) { | 1731 int pos, int end_pos) { |
1726 return PreParserExpression::Default(); | 1732 return PreParserExpression::Default(); |
1727 } | 1733 } |
1728 | 1734 |
1729 static PreParserExpression ExpressionFromLiteral( | 1735 static PreParserExpression ExpressionFromLiteral( |
1730 Token::Value token, int pos, Scanner* scanner, | 1736 Token::Value token, int pos, Scanner* scanner, |
1731 PreParserFactory* factory) { | 1737 PreParserFactory* factory) { |
1732 return PreParserExpression::Default(); | 1738 return PreParserExpression::Default(); |
1733 } | 1739 } |
(...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3508 typename ParserBase<Traits>::ExpressionT | 3514 typename ParserBase<Traits>::ExpressionT |
3509 ParserBase<Traits>::ParseStrongSuperCallExpression( | 3515 ParserBase<Traits>::ParseStrongSuperCallExpression( |
3510 ExpressionClassifier* classifier, bool* ok) { | 3516 ExpressionClassifier* classifier, bool* ok) { |
3511 // SuperCallExpression :: (strong mode) | 3517 // SuperCallExpression :: (strong mode) |
3512 // 'super' '(' ExpressionList ')' | 3518 // 'super' '(' ExpressionList ')' |
3513 BindingPatternUnexpectedToken(classifier); | 3519 BindingPatternUnexpectedToken(classifier); |
3514 | 3520 |
3515 Consume(Token::SUPER); | 3521 Consume(Token::SUPER); |
3516 int pos = position(); | 3522 int pos = position(); |
3517 Scanner::Location super_loc = scanner()->location(); | 3523 Scanner::Location super_loc = scanner()->location(); |
3518 ExpressionT expr = this->SuperReference(scope_, factory(), pos); | 3524 ExpressionT expr = this->SuperCallReference(scope_, factory(), pos); |
3519 | 3525 |
3520 if (peek() != Token::LPAREN) { | 3526 if (peek() != Token::LPAREN) { |
3521 ReportMessage(MessageTemplate::kStrongConstructorSuper); | 3527 ReportMessage(MessageTemplate::kStrongConstructorSuper); |
3522 *ok = false; | 3528 *ok = false; |
3523 return this->EmptyExpression(); | 3529 return this->EmptyExpression(); |
3524 } | 3530 } |
3525 | 3531 |
3526 Scanner::Location spread_pos; | 3532 Scanner::Location spread_pos; |
3527 typename Traits::Type::ExpressionList args = | 3533 typename Traits::Type::ExpressionList args = |
3528 ParseArguments(&spread_pos, classifier, CHECK_OK); | 3534 ParseArguments(&spread_pos, classifier, CHECK_OK); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3573 scope = scope->outer_scope(); | 3579 scope = scope->outer_scope(); |
3574 DCHECK_NOT_NULL(scope); | 3580 DCHECK_NOT_NULL(scope); |
3575 scope = scope->DeclarationScope(); | 3581 scope = scope->DeclarationScope(); |
3576 } | 3582 } |
3577 | 3583 |
3578 FunctionKind kind = scope->function_kind(); | 3584 FunctionKind kind = scope->function_kind(); |
3579 if (IsConciseMethod(kind) || IsAccessorFunction(kind) || | 3585 if (IsConciseMethod(kind) || IsAccessorFunction(kind) || |
3580 i::IsConstructor(kind)) { | 3586 i::IsConstructor(kind)) { |
3581 if (peek() == Token::PERIOD || peek() == Token::LBRACK) { | 3587 if (peek() == Token::PERIOD || peek() == Token::LBRACK) { |
3582 scope->RecordSuperPropertyUsage(); | 3588 scope->RecordSuperPropertyUsage(); |
3583 return this->SuperReference(scope_, factory(), pos); | 3589 return this->SuperPropertyReference(scope_, factory(), pos); |
3584 } | 3590 } |
3585 // new super() is never allowed. | 3591 // new super() is never allowed. |
3586 // super() is only allowed in derived constructor | 3592 // super() is only allowed in derived constructor |
3587 if (!is_new && peek() == Token::LPAREN && IsSubclassConstructor(kind)) { | 3593 if (!is_new && peek() == Token::LPAREN && IsSubclassConstructor(kind)) { |
3588 if (is_strong(language_mode())) { | 3594 if (is_strong(language_mode())) { |
3589 // Super calls in strong mode are parsed separately. | 3595 // Super calls in strong mode are parsed separately. |
3590 ReportMessageAt(scanner()->location(), | 3596 ReportMessageAt(scanner()->location(), |
3591 MessageTemplate::kStrongConstructorSuper); | 3597 MessageTemplate::kStrongConstructorSuper); |
3592 *ok = false; | 3598 *ok = false; |
3593 return this->EmptyExpression(); | 3599 return this->EmptyExpression(); |
3594 } | 3600 } |
3595 // TODO(rossberg): This might not be the correct FunctionState for the | 3601 // TODO(rossberg): This might not be the correct FunctionState for the |
3596 // method here. | 3602 // method here. |
3597 function_state_->set_super_location(scanner()->location()); | 3603 function_state_->set_super_location(scanner()->location()); |
3598 return this->SuperReference(scope_, factory(), pos); | 3604 return this->SuperCallReference(scope_, factory(), pos); |
3599 } | 3605 } |
3600 } | 3606 } |
3601 | 3607 |
3602 ReportMessageAt(scanner()->location(), MessageTemplate::kUnexpectedSuper); | 3608 ReportMessageAt(scanner()->location(), MessageTemplate::kUnexpectedSuper); |
3603 *ok = false; | 3609 *ok = false; |
3604 return this->EmptyExpression(); | 3610 return this->EmptyExpression(); |
3605 } | 3611 } |
3606 | 3612 |
3607 | 3613 |
3608 template <class Traits> | 3614 template <class Traits> |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4039 *ok = false; | 4045 *ok = false; |
4040 return; | 4046 return; |
4041 } | 4047 } |
4042 has_seen_constructor_ = true; | 4048 has_seen_constructor_ = true; |
4043 return; | 4049 return; |
4044 } | 4050 } |
4045 } | 4051 } |
4046 } } // v8::internal | 4052 } } // v8::internal |
4047 | 4053 |
4048 #endif // V8_PREPARSER_H | 4054 #endif // V8_PREPARSER_H |
OLD | NEW |