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

Side by Side Diff: src/scopes.cc

Issue 1203813002: [es6] Make new.target work in functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Also adjust the create memento branch Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/messages.h" 9 #include "src/messages.h"
10 #include "src/parser.h" 10 #include "src/parser.h"
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 312
313 // Declare convenience variables and the receiver. 313 // Declare convenience variables and the receiver.
314 if (is_declaration_scope() && has_this_declaration()) { 314 if (is_declaration_scope() && has_this_declaration()) {
315 Variable* var = variables_.Declare( 315 Variable* var = variables_.Declare(
316 this, ast_value_factory_->this_string(), 316 this, ast_value_factory_->this_string(),
317 subclass_constructor ? CONST : VAR, Variable::THIS, 317 subclass_constructor ? CONST : VAR, Variable::THIS,
318 subclass_constructor ? kNeedsInitialization : kCreatedInitialized); 318 subclass_constructor ? kNeedsInitialization : kCreatedInitialized);
319 receiver_ = var; 319 receiver_ = var;
320 } 320 }
321 321
322 if (is_function_scope()) { 322 if (is_function_scope() && !is_arrow_scope()) {
323 if (!is_arrow_scope()) { 323 // Declare 'arguments' variable which exists in all non arrow functions.
324 // Declare 'arguments' variable which exists in all non arrow functions. 324 // Note that it might never be accessed, in which case it won't be
325 // Note that it might never be accessed, in which case it won't be 325 // allocated during variable allocation.
326 // allocated during variable allocation. 326 variables_.Declare(this, ast_value_factory_->arguments_string(), VAR,
327 variables_.Declare(this, ast_value_factory_->arguments_string(), VAR, 327 Variable::ARGUMENTS, kCreatedInitialized);
328 Variable::ARGUMENTS, kCreatedInitialized);
329 }
330 328
331 if (subclass_constructor) { 329 if (subclass_constructor || FLAG_harmony_new_target) {
332 DCHECK(!is_arrow_scope());
333 variables_.Declare(this, ast_value_factory_->new_target_string(), CONST, 330 variables_.Declare(this, ast_value_factory_->new_target_string(), CONST,
334 Variable::NORMAL, kCreatedInitialized); 331 Variable::NORMAL, kCreatedInitialized);
335 } 332 }
336 333
337 if (IsConciseMethod(function_kind_) || IsConstructor(function_kind_) || 334 if (IsConciseMethod(function_kind_) || IsConstructor(function_kind_) ||
338 IsAccessorFunction(function_kind_)) { 335 IsAccessorFunction(function_kind_)) {
339 DCHECK(!is_arrow_scope());
340 variables_.Declare(this, ast_value_factory_->this_function_string(), 336 variables_.Declare(this, ast_value_factory_->this_function_string(),
341 CONST, Variable::NORMAL, kCreatedInitialized); 337 CONST, Variable::NORMAL, kCreatedInitialized);
342 } 338 }
343 } 339 }
344 } 340 }
345 341
346 342
347 Scope* Scope::FinalizeBlockScope() { 343 Scope* Scope::FinalizeBlockScope() {
348 DCHECK(is_block_scope()); 344 DCHECK(is_block_scope());
349 DCHECK(internals_.is_empty()); 345 DCHECK(internals_.is_empty());
(...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 } 1570 }
1575 1571
1576 1572
1577 int Scope::ContextLocalCount() const { 1573 int Scope::ContextLocalCount() const {
1578 if (num_heap_slots() == 0) return 0; 1574 if (num_heap_slots() == 0) return 0;
1579 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1575 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1580 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1576 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1581 } 1577 }
1582 } // namespace internal 1578 } // namespace internal
1583 } // namespace v8 1579 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698