| 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/scopes.h" | 5 #include "src/scopes.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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 Variable* Scope::DeclareDynamicGlobal(const AstRawString* name) { | 541 Variable* Scope::DeclareDynamicGlobal(const AstRawString* name) { |
| 542 DCHECK(is_script_scope()); | 542 DCHECK(is_script_scope()); |
| 543 return variables_.Declare(this, | 543 return variables_.Declare(this, |
| 544 name, | 544 name, |
| 545 DYNAMIC_GLOBAL, | 545 DYNAMIC_GLOBAL, |
| 546 Variable::NORMAL, | 546 Variable::NORMAL, |
| 547 kCreatedInitialized); | 547 kCreatedInitialized); |
| 548 } | 548 } |
| 549 | 549 |
| 550 | 550 |
| 551 void Scope::RemoveUnresolved(VariableProxy* var) { | 551 bool Scope::RemoveUnresolved(VariableProxy* var) { |
| 552 // Most likely (always?) any variable we want to remove | 552 // Most likely (always?) any variable we want to remove |
| 553 // was just added before, so we search backwards. | 553 // was just added before, so we search backwards. |
| 554 for (int i = unresolved_.length(); i-- > 0;) { | 554 for (int i = unresolved_.length(); i-- > 0;) { |
| 555 if (unresolved_[i] == var) { | 555 if (unresolved_[i] == var) { |
| 556 unresolved_.Remove(i); | 556 unresolved_.Remove(i); |
| 557 return; | 557 return true; |
| 558 } | 558 } |
| 559 } | 559 } |
| 560 return false; |
| 560 } | 561 } |
| 561 | 562 |
| 562 | 563 |
| 563 Variable* Scope::NewTemporary(const AstRawString* name) { | 564 Variable* Scope::NewTemporary(const AstRawString* name) { |
| 564 DCHECK(!already_resolved()); | 565 DCHECK(!already_resolved()); |
| 565 Scope* scope = this->ClosureScope(); | 566 Scope* scope = this->ClosureScope(); |
| 566 Variable* var = new(zone()) Variable(scope, | 567 Variable* var = new(zone()) Variable(scope, |
| 567 name, | 568 name, |
| 568 TEMPORARY, | 569 TEMPORARY, |
| 569 Variable::NORMAL, | 570 Variable::NORMAL, |
| (...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 function_ != NULL && function_->proxy()->var()->IsContextSlot(); | 1659 function_ != NULL && function_->proxy()->var()->IsContextSlot(); |
| 1659 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 1660 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - |
| 1660 (is_function_var_in_context ? 1 : 0); | 1661 (is_function_var_in_context ? 1 : 0); |
| 1661 } | 1662 } |
| 1662 | 1663 |
| 1663 | 1664 |
| 1664 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 1665 int Scope::ContextGlobalCount() const { return num_global_slots(); } |
| 1665 | 1666 |
| 1666 } // namespace internal | 1667 } // namespace internal |
| 1667 } // namespace v8 | 1668 } // namespace v8 |
| OLD | NEW |