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

Unified Diff: src/preparser.h

Issue 575083002: Cleanup class parsing a bit (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Git rebase Created 6 years, 3 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
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index f9a3fbea0bde935f3e50121eae7c935bcaa70fba..bdcc42ba16c87336dfc300b176d5ca2bd4ac0ed1 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -64,7 +64,6 @@ class ParserBase : public Traits {
typedef typename Traits::Type::Expression ExpressionT;
typedef typename Traits::Type::Identifier IdentifierT;
typedef typename Traits::Type::FunctionLiteral FunctionLiteralT;
- typedef typename Traits::Type::ClassLiteral ClassLiteralT;
typedef typename Traits::Type::Literal LiteralT;
typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT;
@@ -502,10 +501,10 @@ class ParserBase : public Traits {
bool* ok);
ExpressionT ParseArrowFunctionLiteral(int start_pos, ExpressionT params_ast,
bool* ok);
- ClassLiteralT ParseClassLiteral(IdentifierT name,
- Scanner::Location function_name_location,
- bool name_is_strict_reserved, int pos,
- bool* ok);
+ ExpressionT ParseClassLiteral(IdentifierT name,
+ Scanner::Location function_name_location,
+ bool name_is_strict_reserved, int pos,
+ bool* ok);
// Checks if the expression is a valid reference expression (e.g., on the
// left-hand side of assignments). Although ruled out by ECMA as early errors,
@@ -1087,7 +1086,6 @@ class PreParserFactory {
PreParserExpression extends,
PreParserExpression constructor,
PreParserExpressionList properties,
- AstValueFactory* ast_value_factory,
int position) {
return PreParserExpression::Default();
}
@@ -1287,9 +1285,6 @@ class PreParserTraits {
static PreParserExpression EmptyFunctionLiteral() {
return PreParserExpression::Default();
}
- static PreParserExpression EmptyClassLiteral() {
- return PreParserExpression::Default();
- }
static PreParserExpressionList NullExpressionList() {
return PreParserExpressionList();
}
@@ -1318,6 +1313,15 @@ class PreParserTraits {
return PreParserExpression::Super();
}
+ static PreParserExpression ClassLiteral(PreParserIdentifier name,
+ PreParserExpression extends,
+ PreParserExpression constructor,
+ PreParserExpressionList properties,
+ int position,
+ PreParserFactory* factory) {
+ return PreParserExpression::Default();
+ }
+
static PreParserExpression ExpressionFromLiteral(
Token::Value token, int pos, Scanner* scanner,
PreParserFactory* factory) {
@@ -2713,21 +2717,19 @@ typename ParserBase<Traits>::ExpressionT ParserBase<
template <class Traits>
-typename ParserBase<Traits>::ClassLiteralT
-ParserBase<Traits>::ParseClassLiteral(IdentifierT name,
- Scanner::Location class_name_location,
- bool name_is_strict_reserved, int pos,
- bool* ok) {
+typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseClassLiteral(
+ IdentifierT name, Scanner::Location class_name_location,
+ bool name_is_strict_reserved, int pos, bool* ok) {
// All parts of a ClassDeclaration or a ClassExpression are strict code.
if (name_is_strict_reserved) {
ReportMessageAt(class_name_location, "unexpected_strict_reserved");
*ok = false;
- return this->EmptyClassLiteral();
+ return this->EmptyExpression();
}
if (this->IsEvalOrArguments(name)) {
ReportMessageAt(class_name_location, "strict_eval_arguments");
*ok = false;
- return this->EmptyClassLiteral();
+ return this->EmptyExpression();
}
// TODO(arv): Implement scopes and name binding in class body only.
@@ -2742,8 +2744,7 @@ ParserBase<Traits>::ParseClassLiteral(IdentifierT name,
ExpressionT extends = this->EmptyExpression();
if (Check(Token::EXTENDS)) {
- extends =
- this->ParseLeftHandSideExpression(CHECK_OK_CUSTOM(EmptyClassLiteral));
+ extends = this->ParseLeftHandSideExpression(CHECK_OK);
}
ObjectLiteralChecker checker(this, STRICT);
@@ -2751,15 +2752,15 @@ ParserBase<Traits>::ParseClassLiteral(IdentifierT name,
this->NewPropertyList(4, zone_);
FunctionLiteralT constructor = this->EmptyFunctionLiteral();
- Expect(Token::LBRACE, CHECK_OK_CUSTOM(EmptyClassLiteral));
+ Expect(Token::LBRACE, CHECK_OK);
while (peek() != Token::RBRACE) {
if (Check(Token::SEMICOLON)) continue;
if (fni_ != NULL) fni_->Enter();
const bool in_class = true;
const bool is_static = false;
- ObjectLiteralPropertyT property = this->ParsePropertyDefinition(
- &checker, in_class, is_static, CHECK_OK_CUSTOM(EmptyClassLiteral));
+ ObjectLiteralPropertyT property =
+ this->ParsePropertyDefinition(&checker, in_class, is_static, CHECK_OK);
properties->Add(property, zone());
@@ -2768,10 +2769,10 @@ ParserBase<Traits>::ParseClassLiteral(IdentifierT name,
fni_->Leave();
}
}
- Expect(Token::RBRACE, CHECK_OK_CUSTOM(EmptyClassLiteral));
+ Expect(Token::RBRACE, CHECK_OK);
- return factory()->NewClassLiteral(name, extends, constructor, properties,
- this->ast_value_factory(), pos);
+ return this->ClassLiteral(name, extends, constructor, properties, pos,
+ factory());
}
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698