Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index ec9832111aa9306ccf124ebc62237cd091fbcf1a..96422327eae39517f412162fab3a8a636e811cab 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)) ? true : false; |
|
arv (Not doing code reviews)
2015/01/23 15:40:46
bool uninitialized_this = FLAG_experimental_classe
Dmitry Lomov (no reviews)
2015/01/23 21:08:28
Done (classic!)
|
| + 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; |
| @@ -4019,9 +4025,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, is_static, extends != nullptr, &is_computed_name, |
| + &has_seen_constructor, CHECK_OK); |
| if (has_seen_constructor && constructor == NULL) { |
| constructor = GetPropertyValue(property)->AsFunctionLiteral(); |