| 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/ast/scopes.h" | 5 #include "src/ast/scopes.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
| 10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 NonLocal(name, DYNAMIC); | 631 NonLocal(name, DYNAMIC); |
| 632 } else { | 632 } else { |
| 633 variables_.Add(zone(), function_); | 633 variables_.Add(zone(), function_); |
| 634 } | 634 } |
| 635 return function_; | 635 return function_; |
| 636 } | 636 } |
| 637 | 637 |
| 638 bool Scope::HasBeenRemoved() const { | 638 bool Scope::HasBeenRemoved() const { |
| 639 // TODO(neis): Store this information somewhere instead of calculating it. | 639 // TODO(neis): Store this information somewhere instead of calculating it. |
| 640 | 640 |
| 641 if (!is_block_scope() || is_declaration_scope()) return false; | 641 if (!is_block_scope()) return false; // Shortcut. |
| 642 | 642 |
| 643 Scope* parent = outer_scope(); | 643 Scope* parent = outer_scope(); |
| 644 if (parent == nullptr) { | 644 if (parent == nullptr) { |
| 645 DCHECK(is_script_scope()); | 645 DCHECK(is_script_scope()); |
| 646 return false; | 646 return false; |
| 647 } | 647 } |
| 648 | 648 |
| 649 Scope* sibling = parent->inner_scope(); | 649 Scope* sibling = parent->inner_scope(); |
| 650 for (; sibling != nullptr; sibling = sibling->sibling()) { | 650 for (; sibling != nullptr; sibling = sibling->sibling()) { |
| 651 if (sibling == this) return false; | 651 if (sibling == this) return false; |
| (...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2030 Variable* function = | 2030 Variable* function = |
| 2031 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 2031 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
| 2032 bool is_function_var_in_context = | 2032 bool is_function_var_in_context = |
| 2033 function != nullptr && function->IsContextSlot(); | 2033 function != nullptr && function->IsContextSlot(); |
| 2034 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 2034 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
| 2035 (is_function_var_in_context ? 1 : 0); | 2035 (is_function_var_in_context ? 1 : 0); |
| 2036 } | 2036 } |
| 2037 | 2037 |
| 2038 } // namespace internal | 2038 } // namespace internal |
| 2039 } // namespace v8 | 2039 } // namespace v8 |
| OLD | NEW |