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 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 current->set_next_unresolved(next->next_unresolved()); | 1011 current->set_next_unresolved(next->next_unresolved()); |
1012 var->set_next_unresolved(nullptr); | 1012 var->set_next_unresolved(nullptr); |
1013 return true; | 1013 return true; |
1014 } | 1014 } |
1015 current = next; | 1015 current = next; |
1016 } | 1016 } |
1017 return false; | 1017 return false; |
1018 } | 1018 } |
1019 | 1019 |
1020 bool Scope::RemoveUnresolved(const AstRawString* name) { | 1020 bool Scope::RemoveUnresolved(const AstRawString* name) { |
1021 if (unresolved_->raw_name() == name) { | 1021 if (unresolved_ != nullptr && unresolved_->raw_name() == name) { |
1022 VariableProxy* removed = unresolved_; | 1022 VariableProxy* removed = unresolved_; |
1023 unresolved_ = unresolved_->next_unresolved(); | 1023 unresolved_ = unresolved_->next_unresolved(); |
1024 removed->set_next_unresolved(nullptr); | 1024 removed->set_next_unresolved(nullptr); |
1025 return true; | 1025 return true; |
1026 } | 1026 } |
1027 VariableProxy* current = unresolved_; | 1027 VariableProxy* current = unresolved_; |
1028 while (current != nullptr) { | 1028 while (current != nullptr) { |
1029 VariableProxy* next = current->next_unresolved(); | 1029 VariableProxy* next = current->next_unresolved(); |
1030 if (next->raw_name() == name) { | 1030 if (next != nullptr && next->raw_name() == name) { |
1031 current->set_next_unresolved(next->next_unresolved()); | 1031 current->set_next_unresolved(next->next_unresolved()); |
1032 next->set_next_unresolved(nullptr); | 1032 next->set_next_unresolved(nullptr); |
1033 return true; | 1033 return true; |
1034 } | 1034 } |
1035 current = next; | 1035 current = next; |
1036 } | 1036 } |
1037 return false; | 1037 return false; |
1038 } | 1038 } |
1039 | 1039 |
1040 Variable* Scope::NewTemporary(const AstRawString* name) { | 1040 Variable* Scope::NewTemporary(const AstRawString* name) { |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1946 Variable* function = | 1946 Variable* function = |
1947 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 1947 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
1948 bool is_function_var_in_context = | 1948 bool is_function_var_in_context = |
1949 function != nullptr && function->IsContextSlot(); | 1949 function != nullptr && function->IsContextSlot(); |
1950 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1950 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1951 (is_function_var_in_context ? 1 : 0); | 1951 (is_function_var_in_context ? 1 : 0); |
1952 } | 1952 } |
1953 | 1953 |
1954 } // namespace internal | 1954 } // namespace internal |
1955 } // namespace v8 | 1955 } // namespace v8 |
OLD | NEW |