| Index: src/preparser.h
|
| diff --git a/src/preparser.h b/src/preparser.h
|
| index 8a932582586ed15b6b5b886ccecbe6933ee6d7e1..14a9eb46523f997de64c74d2c8c1919a654c0e3d 100644
|
| --- a/src/preparser.h
|
| +++ b/src/preparser.h
|
| @@ -677,6 +677,10 @@ class PreParserExpression {
|
| return PreParserExpression(kThisExpression);
|
| }
|
|
|
| + static PreParserExpression Super() {
|
| + return PreParserExpression(kSuperExpression);
|
| + }
|
| +
|
| static PreParserExpression ThisProperty() {
|
| return PreParserExpression(kThisPropertyExpression);
|
| }
|
| @@ -798,7 +802,8 @@ class PreParserExpression {
|
| kThisExpression = (1 << 4),
|
| kThisPropertyExpression = (2 << 4),
|
| kPropertyExpression = (3 << 4),
|
| - kCallExpression = (4 << 4)
|
| + kCallExpression = (4 << 4),
|
| + kSuperExpression = (5 << 4)
|
| };
|
|
|
| explicit PreParserExpression(int expression_code) : code_(expression_code) {}
|
| @@ -1248,6 +1253,11 @@ class PreParserTraits {
|
| return PreParserExpression::This();
|
| }
|
|
|
| + static PreParserExpression SuperReference(PreParserScope* scope,
|
| + PreParserFactory* factory) {
|
| + return PreParserExpression::Super();
|
| + }
|
| +
|
| static PreParserExpression ExpressionFromLiteral(
|
| Token::Value token, int pos, Scanner* scanner,
|
| PreParserFactory* factory) {
|
| @@ -2383,7 +2393,13 @@ ParserBase<Traits>::ParseMemberWithNewPrefixesExpression(bool* ok) {
|
| if (peek() == Token::NEW) {
|
| Consume(Token::NEW);
|
| int new_pos = position();
|
| - ExpressionT result = this->ParseMemberWithNewPrefixesExpression(CHECK_OK);
|
| + ExpressionT result = this->EmptyExpression();
|
| + if (peek() == Token::SUPER) {
|
| + Consume(Token::SUPER);
|
| + result = this->SuperReference(scope_, factory());
|
| + } else {
|
| + result = this->ParseMemberWithNewPrefixesExpression(CHECK_OK);
|
| + }
|
| if (peek() == Token::LPAREN) {
|
| // NewExpression with arguments.
|
| typename Traits::Type::ExpressionList args =
|
| @@ -2397,7 +2413,7 @@ ParserBase<Traits>::ParseMemberWithNewPrefixesExpression(bool* ok) {
|
| return factory()->NewCallNew(result, this->NewExpressionList(0, zone_),
|
| new_pos);
|
| }
|
| - // No 'new' keyword.
|
| + // No 'new' or 'super' keyword.
|
| return this->ParseMemberExpression(ok);
|
| }
|
|
|
| @@ -2438,6 +2454,19 @@ ParserBase<Traits>::ParseMemberExpression(bool* ok) {
|
| function_type,
|
| FunctionLiteral::NORMAL_ARITY,
|
| CHECK_OK);
|
| + } else if (peek() == Token::SUPER) {
|
| + int beg_pos = position();
|
| + Consume(Token::SUPER);
|
| + Token::Value next = peek();
|
| + if (next == Token::PERIOD || next == Token::LBRACK ||
|
| + next == Token::LPAREN) {
|
| + result = this->SuperReference(scope_, factory());
|
| + } else {
|
| + ReportMessageAt(Scanner::Location(beg_pos, position()),
|
| + "unexpected_super");
|
| + *ok = false;
|
| + return this->EmptyExpression();
|
| + }
|
| } else {
|
| result = ParsePrimaryExpression(CHECK_OK);
|
| }
|
|
|