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

Unified Diff: src/preparser.h

Issue 700523003: Classes: Partial fix for constructor not calling super (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: remove todo Created 6 years, 1 month 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') | src/runtime/runtime-classes.cc » ('j') | 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 ddf9cecc66a9b9c80c61a235ae0c3a421e5d5e78..7c9791fc9ca25223983afbfee8f4f666c709af24 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -1325,6 +1325,12 @@ class PreParserTraits {
return PreParserExpression::Default();
}
+ static PreParserExpression DefaultConstructor(bool call_super,
+ PreParserScope* scope, int pos,
+ int end_pos) {
+ return PreParserExpression::Default();
+ }
+
static PreParserExpression ExpressionFromLiteral(
Token::Value token, int pos, Scanner* scanner,
PreParserFactory* factory) {
@@ -2747,12 +2753,14 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseClassLiteral(
return this->EmptyExpression();
}
+ bool has_extends = false;
ExpressionT extends = this->EmptyExpression();
if (Check(Token::EXTENDS)) {
typename Traits::Type::ScopePtr scope = this->NewScope(scope_, BLOCK_SCOPE);
BlockState block_state(&scope_, Traits::Type::ptr_to_scope(scope));
scope_->SetStrictMode(STRICT);
extends = this->ParseLeftHandSideExpression(CHECK_OK);
+ has_extends = true;
}
// TODO(arv): Implement scopes and name binding in class body only.
@@ -2791,6 +2799,11 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseClassLiteral(
int end_pos = peek_position();
Expect(Token::RBRACE, CHECK_OK);
+ if (!has_seen_constructor) {
+ constructor =
+ this->DefaultConstructor(has_extends, scope_, pos, end_pos + 1);
+ }
+
return this->ClassExpression(name, extends, constructor, properties, pos,
end_pos + 1, factory());
}
« no previous file with comments | « src/parser.cc ('k') | src/runtime/runtime-classes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698