Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Unified Diff: src/preparser.h

Issue 418143007: FYI Implementing 'super' keyword (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: one more test Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index d1d1c53e0b16979d91c4d233b1dd0e3096e1f1f1..314daabfc9fb440c3d4cdd782716e240e216f4eb 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -652,6 +652,10 @@ class PreParserExpression {
return PreParserExpression(kThisExpression);
}
+ static PreParserExpression Super() {
+ return PreParserExpression(kSuperExpression);
+ }
+
static PreParserExpression ThisProperty() {
return PreParserExpression(kThisPropertyExpression);
}
@@ -773,7 +777,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) {}
@@ -1216,6 +1221,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) {
@@ -2340,7 +2350,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 =
@@ -2354,7 +2370,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);
}
@@ -2395,6 +2411,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);
}

Powered by Google App Engine
This is Rietveld 408576698