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

Unified Diff: src/parser.cc

Issue 703603005: Classes: Fix issue with default constructor crash (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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/ast.h ('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/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 7a88c5270da7ddc02f0564b2cfb91e1085cbe7fd..120bd68ce343f35300ccdfa246318b45e05c72d0 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -644,10 +644,23 @@ Expression* ParserTraits::ClassExpression(
const AstRawString* name, Expression* extends, Expression* constructor,
ZoneList<ObjectLiteral::Property*>* properties, int start_position,
int end_position, AstNodeFactory<AstConstructionVisitor>* factory) {
+ if (constructor == NULL) {
+ // Create default constructor.
+ Scope* scope = NewScope(parser_->scope_, FUNCTION_SCOPE);
+ // Set position and force eager compilation since lazy parsing tries to
arv (Not doing code reviews) 2014/11/04 17:53:05 This is not very good. Suggestions welcome.
Dmitry Lomov (no reviews) 2014/11/04 18:06:07 I believe we need a new kind of function: a flag o
+ // parse the content which does not exist.
+ scope->set_start_position(0);
+ scope->set_end_position(0);
+ scope->SetScopeName(name);
+ scope->ForceEagerCompilation();
+ constructor = factory->NewDefaultConstructor(name, ast_value_factory(),
+ scope, RelocInfo::kNoPosition);
+ }
return factory->NewClassLiteral(name, extends, constructor, properties,
start_position, end_position);
}
+
Literal* ParserTraits::ExpressionFromLiteral(
Token::Value token, int pos,
Scanner* scanner,
« no previous file with comments | « src/ast.h ('k') | src/runtime/runtime-classes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698