| 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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 685 | 685 | 
| 686 bool Scope::HasTrivialContext() const { | 686 bool Scope::HasTrivialContext() const { | 
| 687   // A function scope has a trivial context if it always is the global | 687   // A function scope has a trivial context if it always is the global | 
| 688   // context. We iteratively scan out the context chain to see if | 688   // context. We iteratively scan out the context chain to see if | 
| 689   // there is anything that makes this scope non-trivial; otherwise we | 689   // there is anything that makes this scope non-trivial; otherwise we | 
| 690   // return true. | 690   // return true. | 
| 691   for (const Scope* scope = this; scope != NULL; scope = scope->outer_scope_) { | 691   for (const Scope* scope = this; scope != NULL; scope = scope->outer_scope_) { | 
| 692     if (scope->is_eval_scope()) return false; | 692     if (scope->is_eval_scope()) return false; | 
| 693     if (scope->scope_inside_with_) return false; | 693     if (scope->scope_inside_with_) return false; | 
| 694     if (scope->ContextLocalCount() > 0) return false; | 694     if (scope->ContextLocalCount() > 0) return false; | 
|  | 695     if (scope->ContextGlobalCount() > 0) return false; | 
| 695   } | 696   } | 
| 696   return true; | 697   return true; | 
| 697 } | 698 } | 
| 698 | 699 | 
| 699 | 700 | 
| 700 bool Scope::HasTrivialOuterContext() const { | 701 bool Scope::HasTrivialOuterContext() const { | 
| 701   Scope* outer = outer_scope_; | 702   Scope* outer = outer_scope_; | 
| 702   if (outer == NULL) return true; | 703   if (outer == NULL) return true; | 
| 703   // Note that the outer context may be trivial in general, but the current | 704   // Note that the outer context may be trivial in general, but the current | 
| 704   // scope may be inside a 'with' statement in which case the outer context | 705   // scope may be inside a 'with' statement in which case the outer context | 
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1599       function_ != NULL && function_->proxy()->var()->IsContextSlot(); | 1600       function_ != NULL && function_->proxy()->var()->IsContextSlot(); | 
| 1600   return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 1601   return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 
| 1601          (is_function_var_in_context ? 1 : 0); | 1602          (is_function_var_in_context ? 1 : 0); | 
| 1602 } | 1603 } | 
| 1603 | 1604 | 
| 1604 | 1605 | 
| 1605 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 1606 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 
| 1606 | 1607 | 
| 1607 }  // namespace internal | 1608 }  // namespace internal | 
| 1608 }  // namespace v8 | 1609 }  // namespace v8 | 
| OLD | NEW | 
|---|