OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/scopeinfo.h" | 9 #include "src/scopeinfo.h" |
10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 163 } |
164 return 0; | 164 return 0; |
165 } | 165 } |
166 | 166 |
167 | 167 |
168 int ScopeInfo::ContextLength() { | 168 int ScopeInfo::ContextLength() { |
169 if (length() > 0) { | 169 if (length() > 0) { |
170 int context_locals = ContextLocalCount(); | 170 int context_locals = ContextLocalCount(); |
171 bool function_name_context_slot = | 171 bool function_name_context_slot = |
172 FunctionVariableField::decode(Flags()) == CONTEXT; | 172 FunctionVariableField::decode(Flags()) == CONTEXT; |
173 bool has_context = context_locals > 0 || | 173 bool has_context = context_locals > 0 || function_name_context_slot || |
174 function_name_context_slot || | 174 scope_type() == WITH_SCOPE || |
175 scope_type() == WITH_SCOPE || | 175 (scope_type() == ARROW_SCOPE && CallsEval()) || |
176 (scope_type() == FUNCTION_SCOPE && CallsEval()) || | 176 (scope_type() == FUNCTION_SCOPE && CallsEval()) || |
177 scope_type() == MODULE_SCOPE; | 177 scope_type() == MODULE_SCOPE; |
178 if (has_context) { | 178 if (has_context) { |
179 return Context::MIN_CONTEXT_SLOTS + context_locals + | 179 return Context::MIN_CONTEXT_SLOTS + context_locals + |
180 (function_name_context_slot ? 1 : 0); | 180 (function_name_context_slot ? 1 : 0); |
181 } | 181 } |
182 } | 182 } |
183 return 0; | 183 return 0; |
184 } | 184 } |
185 | 185 |
186 | 186 |
187 bool ScopeInfo::HasFunctionName() { | 187 bool ScopeInfo::HasFunctionName() { |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 } else { | 564 } else { |
565 DCHECK(var->index() >= 0); | 565 DCHECK(var->index() >= 0); |
566 info->set_index(i, var->index()); | 566 info->set_index(i, var->index()); |
567 } | 567 } |
568 } | 568 } |
569 DCHECK(i == info->length()); | 569 DCHECK(i == info->length()); |
570 return info; | 570 return info; |
571 } | 571 } |
572 | 572 |
573 } } // namespace v8::internal | 573 } } // namespace v8::internal |
OLD | NEW |