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

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: Add test again. It got lost in last patchset Created 5 years, 5 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
« no previous file with comments | « src/mips64/builtins-mips64.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 } 1581 }
1586 1582
1587 1583
1588 int Scope::ContextLocalCount() const { 1584 int Scope::ContextLocalCount() const {
1589 if (num_heap_slots() == 0) return 0; 1585 if (num_heap_slots() == 0) return 0;
1590 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1586 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1591 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1587 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1592 } 1588 }
1593 } // namespace internal 1589 } // namespace internal
1594 } // namespace v8 1590 } // namespace v8
OLDNEW
« no previous file with comments | « src/mips64/builtins-mips64.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698