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

Unified Diff: src/scopes.cc

Issue 908883002: new classes: implement new.target passing to superclass constructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix x64 arithmetic Created 5 years, 10 months 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/scopes.h ('k') | src/variables.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index fa95bde2b2ff0f6062427003850bf94d2af5db8b..16d2c111b9a86b179562839e61a32dee928824aa 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -148,6 +148,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;
@@ -287,7 +288,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.
@@ -307,14 +308,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(), CONST, 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();
@@ -1201,15 +1210,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();
}
« no previous file with comments | « src/scopes.h ('k') | src/variables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698