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

Side by Side Diff: src/scopes.cc

Issue 1188383002: Work In Progress: support new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
« no previous file with comments | « src/objects.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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 309
310 // Declare convenience variables and the receiver. 310 // Declare convenience variables and the receiver.
311 if (is_declaration_scope() && has_this_declaration()) { 311 if (is_declaration_scope() && has_this_declaration()) {
312 Variable* var = variables_.Declare( 312 Variable* var = variables_.Declare(
313 this, ast_value_factory_->this_string(), 313 this, ast_value_factory_->this_string(),
314 subclass_constructor ? CONST : VAR, Variable::THIS, 314 subclass_constructor ? CONST : VAR, Variable::THIS,
315 subclass_constructor ? kNeedsInitialization : kCreatedInitialized); 315 subclass_constructor ? kNeedsInitialization : kCreatedInitialized);
316 receiver_ = var; 316 receiver_ = var;
317 } 317 }
318 318
319 if (is_function_scope()) { 319 if (is_function_scope() && !is_arrow_scope()) {
320 if (!is_arrow_scope()) { 320 // Declare 'arguments' variable which exists in all non arrow functions.
321 // Declare 'arguments' variable which exists in all non arrow functions. 321 // Note that it might never be accessed, in which case it won't be
322 // Note that it might never be accessed, in which case it won't be 322 // allocated during variable allocation.
323 // allocated during variable allocation. 323 variables_.Declare(this, ast_value_factory_->arguments_string(), VAR,
324 variables_.Declare(this, ast_value_factory_->arguments_string(), VAR, 324 Variable::ARGUMENTS, kCreatedInitialized);
325 Variable::ARGUMENTS, kCreatedInitialized);
326 }
327 325
328 if (subclass_constructor) { 326 if (subclass_constructor || FLAG_harmony_new_target) {
329 DCHECK(!is_arrow_scope());
330 variables_.Declare(this, ast_value_factory_->new_target_string(), CONST, 327 variables_.Declare(this, ast_value_factory_->new_target_string(), CONST,
331 Variable::NORMAL, kCreatedInitialized); 328 Variable::NORMAL, kCreatedInitialized);
332 } 329 }
333 330
334 if (IsConciseMethod(function_kind_) || IsConstructor(function_kind_) || 331 if (IsConciseMethod(function_kind_) || IsConstructor(function_kind_) ||
335 IsAccessorFunction(function_kind_)) { 332 IsAccessorFunction(function_kind_)) {
336 DCHECK(!is_arrow_scope());
337 variables_.Declare(this, ast_value_factory_->this_function_string(), 333 variables_.Declare(this, ast_value_factory_->this_function_string(),
338 CONST, Variable::NORMAL, kCreatedInitialized); 334 CONST, Variable::NORMAL, kCreatedInitialized);
339 } 335 }
340 } 336 }
341 } 337 }
342 338
343 339
344 Scope* Scope::FinalizeBlockScope() { 340 Scope* Scope::FinalizeBlockScope() {
345 DCHECK(is_block_scope()); 341 DCHECK(is_block_scope());
346 DCHECK(internals_.is_empty()); 342 DCHECK(internals_.is_empty());
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 } 1560 }
1565 1561
1566 1562
1567 int Scope::ContextLocalCount() const { 1563 int Scope::ContextLocalCount() const {
1568 if (num_heap_slots() == 0) return 0; 1564 if (num_heap_slots() == 0) return 0;
1569 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1565 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1570 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1566 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1571 } 1567 }
1572 } // namespace internal 1568 } // namespace internal
1573 } // namespace v8 1569 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698