| 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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 scope != NULL; | 445 scope != NULL; |
| 446 scope = scope->outer_scope()) { | 446 scope = scope->outer_scope()) { |
| 447 Variable* var = scope->LookupLocal(name); | 447 Variable* var = scope->LookupLocal(name); |
| 448 if (var != NULL) return var; | 448 if (var != NULL) return var; |
| 449 } | 449 } |
| 450 return NULL; | 450 return NULL; |
| 451 } | 451 } |
| 452 | 452 |
| 453 | 453 |
| 454 Variable* Scope::DeclareParameter(const AstRawString* name, VariableMode mode, | 454 Variable* Scope::DeclareParameter(const AstRawString* name, VariableMode mode, |
| 455 bool is_rest) { | 455 ParameterKind kind) { |
| 456 DCHECK(!already_resolved()); | 456 DCHECK(!already_resolved()); |
| 457 DCHECK(is_function_scope()); | 457 DCHECK(is_function_scope()); |
| 458 Variable* var = variables_.Declare(this, name, mode, Variable::NORMAL, | 458 Variable* var = variables_.Declare(this, name, mode, Variable::NORMAL, |
| 459 kCreatedInitialized); | 459 kCreatedInitialized); |
| 460 if (is_rest) { | 460 var->set_parameter_kind(kind); |
| 461 if (kind.isRestParameter()) { |
| 461 DCHECK_NULL(rest_parameter_); | 462 DCHECK_NULL(rest_parameter_); |
| 462 rest_parameter_ = var; | 463 rest_parameter_ = var; |
| 463 rest_index_ = num_parameters(); | 464 rest_index_ = num_parameters(); |
| 464 } | 465 } |
| 465 params_.Add(var, zone()); | 466 params_.Add(var, zone()); |
| 466 return var; | 467 return var; |
| 467 } | 468 } |
| 468 | 469 |
| 469 | 470 |
| 470 Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode, | 471 Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode, |
| (...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1464 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0); | 1465 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0); |
| 1465 } | 1466 } |
| 1466 | 1467 |
| 1467 | 1468 |
| 1468 int Scope::ContextLocalCount() const { | 1469 int Scope::ContextLocalCount() const { |
| 1469 if (num_heap_slots() == 0) return 0; | 1470 if (num_heap_slots() == 0) return 0; |
| 1470 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1471 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
| 1471 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); | 1472 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); |
| 1472 } | 1473 } |
| 1473 } } // namespace v8::internal | 1474 } } // namespace v8::internal |
| OLD | NEW |