Chromium Code Reviews| 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 Scope* parent = outer_scope(); | |
|
Toon Verwaest
2016/11/22 08:30:18
if (is_declaration_scope()) return false; ?
Dan Ehrenberg
2016/11/22 16:07:00
Or, that could be an assertion before the return t
Toon Verwaest
2016/11/22 16:18:37
That's what I was originally thinking of suggestin
neis
2016/11/23 12:51:08
Done.
| |
| 641 if (parent == nullptr) { | |
| 642 DCHECK(is_script_scope()); | |
| 643 return false; | |
| 644 } | |
| 645 | |
| 646 Scope* sibling = parent->inner_scope(); | |
| 647 for (; sibling != nullptr; sibling = sibling->sibling()) { | |
| 648 if (sibling == this) return false; | |
| 649 } | |
|
Dan Ehrenberg
2016/11/22 16:07:00
This is asymptotically a bit unfortunate. Is there
Toon Verwaest
2016/11/22 16:19:47
Yeah that's a good suggestion though. We can just
| |
| 650 | |
| 651 DCHECK_NULL(inner_scope_); | |
| 652 return true; | |
| 653 } | |
| 654 | |
| 639 Scope* Scope::FinalizeBlockScope() { | 655 Scope* Scope::FinalizeBlockScope() { |
| 640 DCHECK(is_block_scope()); | 656 DCHECK(is_block_scope()); |
| 641 | 657 |
| 642 if (variables_.occupancy() > 0 || | 658 if (variables_.occupancy() > 0 || |
| 643 (is_declaration_scope() && calls_sloppy_eval())) { | 659 (is_declaration_scope() && calls_sloppy_eval())) { |
| 644 return this; | 660 return this; |
| 645 } | 661 } |
| 646 | 662 |
| 647 // Remove this scope from outer scope. | 663 // Remove this scope from outer scope. |
| 648 outer_scope()->RemoveInnerScope(this); | 664 outer_scope()->RemoveInnerScope(this); |
| (...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2027 Variable* function = | 2043 Variable* function = |
| 2028 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 2044 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
| 2029 bool is_function_var_in_context = | 2045 bool is_function_var_in_context = |
| 2030 function != nullptr && function->IsContextSlot(); | 2046 function != nullptr && function->IsContextSlot(); |
| 2031 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 2047 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
| 2032 (is_function_var_in_context ? 1 : 0); | 2048 (is_function_var_in_context ? 1 : 0); |
| 2033 } | 2049 } |
| 2034 | 2050 |
| 2035 } // namespace internal | 2051 } // namespace internal |
| 2036 } // namespace v8 | 2052 } // namespace v8 |
| OLD | NEW |