Chromium Code Reviews| Index: src/scopes.cc |
| diff --git a/src/scopes.cc b/src/scopes.cc |
| index 4680a1cf6a8518e0467ae45e4571d70af3ec311e..a30d430a8b5c1087e5e84aa1e44a74e2425fb758 100644 |
| --- a/src/scopes.cc |
| +++ b/src/scopes.cc |
| @@ -152,6 +152,7 @@ void Scope::SetDefaults(ScopeType scope_type, |
| scope_name_ = ast_value_factory_->empty_string(); |
| dynamics_ = NULL; |
| receiver_ = NULL; |
| + new_target_ = nullptr; |
| function_ = NULL; |
| arguments_ = NULL; |
| illegal_redecl_ = NULL; |
| @@ -291,7 +292,7 @@ bool Scope::Analyze(CompilationInfo* info) { |
| } |
| -void Scope::Initialize(bool uninitialized_this) { |
| +void Scope::Initialize(bool subclass_constructor) { |
| DCHECK(!already_resolved()); |
| // Add this scope as a new inner scope of the outer scope. |
| @@ -311,14 +312,22 @@ void Scope::Initialize(bool uninitialized_this) { |
| // such parameter is 'this' which is passed on the stack when |
| // invoking scripts |
| if (is_declaration_scope()) { |
| - DCHECK(!uninitialized_this || is_function_scope()); |
| - DCHECK(FLAG_experimental_classes || !uninitialized_this); |
| + DCHECK(!subclass_constructor || is_function_scope()); |
| + DCHECK(FLAG_experimental_classes || !subclass_constructor); |
| Variable* var = variables_.Declare( |
| this, ast_value_factory_->this_string(), |
| - uninitialized_this ? CONST : VAR, false, Variable::THIS, |
| - uninitialized_this ? kNeedsInitialization : kCreatedInitialized); |
| + subclass_constructor ? CONST : VAR, false, Variable::THIS, |
| + subclass_constructor ? kNeedsInitialization : kCreatedInitialized); |
| var->AllocateTo(Variable::PARAMETER, -1); |
| receiver_ = var; |
| + |
| + if (subclass_constructor) { |
| + new_target_ = |
| + variables_.Declare(this, ast_value_factory_->new_target_string(), VAR, |
|
arv (Not doing code reviews)
2015/02/10 20:15:18
Shouldn't this be CONST?
Dmitry Lomov (no reviews)
2015/02/11 00:58:29
Done.
|
| + false, Variable::NEW_TARGET, kCreatedInitialized); |
| + new_target_->AllocateTo(Variable::PARAMETER, -2); |
| + new_target_->set_is_used(); |
| + } |
| } else { |
| DCHECK(outer_scope() != NULL); |
| receiver_ = outer_scope()->receiver(); |
| @@ -1206,15 +1215,10 @@ bool Scope::MustAllocate(Variable* var) { |
| // Give var a read/write use if there is a chance it might be accessed |
| // via an eval() call. This is only possible if the variable has a |
| // visible name. |
| - if ((var->is_this() || !var->raw_name()->IsEmpty()) && |
| - (var->has_forced_context_allocation() || |
| - scope_calls_eval_ || |
| - inner_scope_calls_eval_ || |
| - scope_contains_with_ || |
| - is_catch_scope() || |
| - is_block_scope() || |
| - is_module_scope() || |
| - is_script_scope())) { |
| + if ((var->is_this() || var->is_new_target() || !var->raw_name()->IsEmpty()) && |
| + (var->has_forced_context_allocation() || scope_calls_eval_ || |
| + inner_scope_calls_eval_ || scope_contains_with_ || is_catch_scope() || |
| + is_block_scope() || is_module_scope() || is_script_scope())) { |
| var->set_is_used(); |
| if (scope_calls_eval_ || inner_scope_calls_eval_) var->set_maybe_assigned(); |
| } |