| 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 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1567 } | 1563 } |
| 1568 | 1564 |
| 1569 | 1565 |
| 1570 int Scope::ContextLocalCount() const { | 1566 int Scope::ContextLocalCount() const { |
| 1571 if (num_heap_slots() == 0) return 0; | 1567 if (num_heap_slots() == 0) return 0; |
| 1572 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1568 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
| 1573 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); | 1569 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); |
| 1574 } | 1570 } |
| 1575 } // namespace internal | 1571 } // namespace internal |
| 1576 } // namespace v8 | 1572 } // namespace v8 |
| OLD | NEW |