| Index: src/parser.cc
|
| diff --git a/src/parser.cc b/src/parser.cc
|
| index ec9832111aa9306ccf124ebc62237cd091fbcf1a..d7bd891df8b231b9c9e72d7aab047f31f6ac7604 100644
|
| --- a/src/parser.cc
|
| +++ b/src/parser.cc
|
| @@ -263,11 +263,16 @@ void Parser::SetCachedData() {
|
| }
|
|
|
|
|
| -Scope* Parser::NewScope(Scope* parent, ScopeType scope_type) {
|
| +Scope* Parser::NewScope(Scope* parent, ScopeType scope_type,
|
| + FunctionKind kind) {
|
| DCHECK(ast_value_factory());
|
| + DCHECK((scope_type == FUNCTION_SCOPE && IsValidFunctionKind(kind)) ||
|
| + kind == kNormalFunction);
|
| Scope* result =
|
| new (zone()) Scope(parent, scope_type, ast_value_factory(), zone());
|
| - result->Initialize();
|
| + bool uninitialized_this =
|
| + FLAG_experimental_classes && IsSubclassConstructor(kind);
|
| + result->Initialize(uninitialized_this);
|
| return result;
|
| }
|
|
|
| @@ -280,7 +285,8 @@ FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope,
|
| int parameter_count = 0;
|
| const AstRawString* name = ast_value_factory()->empty_string();
|
|
|
| - Scope* function_scope = NewScope(scope, FUNCTION_SCOPE);
|
| + Scope* function_scope =
|
| + NewScope(scope, FUNCTION_SCOPE, FunctionKind::kDefaultConstructor);
|
| function_scope->SetStrictMode(STRICT);
|
| // Set start and end position to the same value
|
| function_scope->set_start_position(pos);
|
| @@ -3608,11 +3614,11 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
|
| Scope* original_declaration_scope = original_scope_->DeclarationScope();
|
| Scope* scope =
|
| function_type == FunctionLiteral::DECLARATION &&
|
| - (!allow_harmony_scoping() || strict_mode() == SLOPPY) &&
|
| - (original_scope_ == original_declaration_scope ||
|
| - declaration_scope != original_declaration_scope)
|
| - ? NewScope(declaration_scope, FUNCTION_SCOPE)
|
| - : NewScope(scope_, FUNCTION_SCOPE);
|
| + (!allow_harmony_scoping() || strict_mode() == SLOPPY) &&
|
| + (original_scope_ == original_declaration_scope ||
|
| + declaration_scope != original_declaration_scope)
|
| + ? NewScope(declaration_scope, FUNCTION_SCOPE, kind)
|
| + : NewScope(scope_, FUNCTION_SCOPE, kind);
|
| ZoneList<Statement*>* body = NULL;
|
| int materialized_literal_count = -1;
|
| int expected_property_count = -1;
|
| @@ -4012,6 +4018,7 @@ ClassLiteral* Parser::ParseClassLiteral(const AstRawString* name,
|
| bool has_seen_constructor = false;
|
|
|
| Expect(Token::LBRACE, CHECK_OK);
|
| + const bool has_extends = extends != nullptr;
|
| while (peek() != Token::RBRACE) {
|
| if (Check(Token::SEMICOLON)) continue;
|
| if (fni_ != NULL) fni_->Enter();
|
| @@ -4019,9 +4026,9 @@ ClassLiteral* Parser::ParseClassLiteral(const AstRawString* name,
|
| const bool is_static = false;
|
| bool is_computed_name = false; // Classes do not care about computed
|
| // property names here.
|
| - ObjectLiteral::Property* property =
|
| - ParsePropertyDefinition(NULL, in_class, is_static, &is_computed_name,
|
| - &has_seen_constructor, CHECK_OK);
|
| + ObjectLiteral::Property* property = ParsePropertyDefinition(
|
| + nullptr, in_class, has_extends, is_static, &is_computed_name,
|
| + &has_seen_constructor, CHECK_OK);
|
|
|
| if (has_seen_constructor && constructor == NULL) {
|
| constructor = GetPropertyValue(property)->AsFunctionLiteral();
|
|
|