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 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
629 function_ = | 629 function_ = |
630 new (zone()) Variable(this, name, CONST, kind, kCreatedInitialized); | 630 new (zone()) Variable(this, name, CONST, kind, kCreatedInitialized); |
631 if (calls_sloppy_eval()) { | 631 if (calls_sloppy_eval()) { |
632 NonLocal(name, DYNAMIC); | 632 NonLocal(name, DYNAMIC); |
633 } else { | 633 } else { |
634 variables_.Add(zone(), function_); | 634 variables_.Add(zone(), function_); |
635 } | 635 } |
636 return function_; | 636 return function_; |
637 } | 637 } |
638 | 638 |
639 bool Scope::HasBeenRemoved() const { | |
640 if (!is_block_scope() || is_declaration_scope()) return false; // Shortcut. | |
Toon Verwaest
2016/11/23 12:20:45
if (is_declaration_scope()) return false;
DCHECK(i
neis
2016/11/23 15:52:38
This DCHECK is failing, for instance in the follow
| |
641 | |
642 Scope* parent = outer_scope(); | |
643 if (parent == nullptr) { | |
644 DCHECK(is_script_scope()); | |
645 return false; | |
646 } | |
647 | |
648 Scope* sibling = parent->inner_scope(); | |
649 for (; sibling != nullptr; sibling = sibling->sibling()) { | |
650 if (sibling == this) return false; | |
651 } | |
652 | |
653 DCHECK_NULL(inner_scope_); | |
654 return true; | |
655 } | |
656 | |
639 Scope* Scope::FinalizeBlockScope() { | 657 Scope* Scope::FinalizeBlockScope() { |
640 DCHECK(is_block_scope()); | 658 DCHECK(is_block_scope()); |
641 | 659 |
642 if (variables_.occupancy() > 0 || | 660 if (variables_.occupancy() > 0 || |
643 (is_declaration_scope() && calls_sloppy_eval())) { | 661 (is_declaration_scope() && calls_sloppy_eval())) { |
644 return this; | 662 return this; |
645 } | 663 } |
646 | 664 |
647 // Remove this scope from outer scope. | 665 // Remove this scope from outer scope. |
648 outer_scope()->RemoveInnerScope(this); | 666 outer_scope()->RemoveInnerScope(this); |
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2027 Variable* function = | 2045 Variable* function = |
2028 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 2046 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
2029 bool is_function_var_in_context = | 2047 bool is_function_var_in_context = |
2030 function != nullptr && function->IsContextSlot(); | 2048 function != nullptr && function->IsContextSlot(); |
2031 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 2049 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
2032 (is_function_var_in_context ? 1 : 0); | 2050 (is_function_var_in_context ? 1 : 0); |
2033 } | 2051 } |
2034 | 2052 |
2035 } // namespace internal | 2053 } // namespace internal |
2036 } // namespace v8 | 2054 } // namespace v8 |
OLD | NEW |