OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |