Index: src/preparser.h |
diff --git a/src/preparser.h b/src/preparser.h |
index b34b04e15252ee30774e2f6ebfd339f88fd646a0..8e0834dff2a84c83ba51e2f60b578b1cb418261b 100644 |
--- a/src/preparser.h |
+++ b/src/preparser.h |
@@ -1189,6 +1189,13 @@ class PreParserTraits { |
return false; |
} |
+ bool IsConstructorProperty(PreParserExpression property) { return false; } |
+ |
+ static PreParserExpression GetPropertyValue(PreParserExpression property) { |
+ UNREACHABLE(); |
+ return PreParserExpression::Default(); |
+ } |
+ |
// Functions for encapsulating the differences between parsing and preparsing; |
// operations interleaved with the recursive descent. |
static void PushLiteralName(FuncNameInferrer* fni, PreParserIdentifier id) { |
@@ -1314,12 +1321,12 @@ class PreParserTraits { |
return PreParserExpression::Super(); |
} |
- static PreParserExpression ClassLiteral(PreParserIdentifier name, |
- PreParserExpression extends, |
- PreParserExpression constructor, |
- PreParserExpressionList properties, |
- int position, |
- PreParserFactory* factory) { |
+ static PreParserExpression ClassExpression(PreParserIdentifier name, |
+ PreParserExpression extends, |
+ PreParserExpression constructor, |
+ PreParserExpressionList properties, |
+ int position, |
+ PreParserFactory* factory) { |
return PreParserExpression::Default(); |
} |
@@ -1972,16 +1979,22 @@ typename ParserBase<Traits>::ObjectLiteralPropertyT ParserBase< |
*ok = false; |
return this->EmptyObjectLiteralProperty(); |
} |
- if (is_generator && in_class && !is_static && this->IsConstructor(name)) { |
- ReportMessageAt(scanner()->location(), "constructor_special_method"); |
- *ok = false; |
- return this->EmptyObjectLiteralProperty(); |
+ |
+ FunctionKind kind = is_generator ? FunctionKind::kConciseGeneratorMethod |
+ : FunctionKind::kConciseMethod; |
+ |
+ if (in_class && !is_static && this->IsConstructor(name)) { |
+ if (is_generator) { |
+ ReportMessageAt(scanner()->location(), "constructor_special_method"); |
+ *ok = false; |
+ return this->EmptyObjectLiteralProperty(); |
+ } |
+ |
+ kind = FunctionKind::kConstructorMethod; |
} |
checker->CheckProperty(name_token, kValueProperty, |
CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
- FunctionKind kind = is_generator ? FunctionKind::kConciseGeneratorMethod |
- : FunctionKind::kConciseMethod; |
value = this->ParseFunctionLiteral( |
name, scanner()->location(), |
@@ -2757,7 +2770,7 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseClassLiteral( |
ObjectLiteralChecker checker(this, STRICT); |
typename Traits::Type::PropertyList properties = |
this->NewPropertyList(4, zone_); |
- FunctionLiteralT constructor = this->EmptyFunctionLiteral(); |
+ ExpressionT constructor = this->EmptyExpression(); |
Expect(Token::LBRACE, CHECK_OK); |
while (peek() != Token::RBRACE) { |
@@ -2769,7 +2782,11 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseClassLiteral( |
ObjectLiteralPropertyT property = |
this->ParsePropertyDefinition(&checker, in_class, is_static, CHECK_OK); |
- properties->Add(property, zone()); |
+ if (this->IsConstructorProperty(property)) { |
+ constructor = this->GetPropertyValue(property); |
+ } else { |
+ properties->Add(property, zone()); |
+ } |
if (fni_ != NULL) { |
fni_->Infer(); |
@@ -2778,8 +2795,8 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseClassLiteral( |
} |
Expect(Token::RBRACE, CHECK_OK); |
- return this->ClassLiteral(name, extends, constructor, properties, pos, |
- factory()); |
+ return this->ClassExpression(name, extends, constructor, properties, pos, |
+ factory()); |
} |