| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 | 187 |
| 188 int ScopeInfo::ContextLength() { | 188 int ScopeInfo::ContextLength() { |
| 189 if (length() > 0) { | 189 if (length() > 0) { |
| 190 int context_locals = ContextLocalCount(); | 190 int context_locals = ContextLocalCount(); |
| 191 bool function_name_context_slot = | 191 bool function_name_context_slot = |
| 192 FunctionVariableField::decode(Flags()) == CONTEXT; | 192 FunctionVariableField::decode(Flags()) == CONTEXT; |
| 193 bool has_context = context_locals > 0 || | 193 bool has_context = context_locals > 0 || |
| 194 function_name_context_slot || | 194 function_name_context_slot || |
| 195 Type() == WITH_SCOPE || | 195 Type() == WITH_SCOPE || |
| 196 (Type() == FUNCTION_SCOPE && CallsEval()); | 196 (Type() == FUNCTION_SCOPE && CallsEval()) || |
| 197 Type() == MODULE_SCOPE; |
| 197 if (has_context) { | 198 if (has_context) { |
| 198 return Context::MIN_CONTEXT_SLOTS + context_locals + | 199 return Context::MIN_CONTEXT_SLOTS + context_locals + |
| 199 (function_name_context_slot ? 1 : 0); | 200 (function_name_context_slot ? 1 : 0); |
| 200 } | 201 } |
| 201 } | 202 } |
| 202 return 0; | 203 return 0; |
| 203 } | 204 } |
| 204 | 205 |
| 205 | 206 |
| 206 bool ScopeInfo::HasFunctionName() { | 207 bool ScopeInfo::HasFunctionName() { |
| 207 if (length() > 0) { | 208 if (length() > 0) { |
| 208 return NONE != FunctionVariableField::decode(Flags()); | 209 return NONE != FunctionVariableField::decode(Flags()); |
| 209 } else { | 210 } else { |
| 210 return false; | 211 return false; |
| 211 } | 212 } |
| 212 } | 213 } |
| 213 | 214 |
| 214 | 215 |
| 215 bool ScopeInfo::HasHeapAllocatedLocals() { | 216 bool ScopeInfo::HasHeapAllocatedLocals() { |
| 216 if (length() > 0) { | 217 if (length() > 0) { |
| 217 return ContextLocalCount() > 0; | 218 return ContextLocalCount() > 0; |
| 218 } else { | 219 } else { |
| 219 return false; | 220 return false; |
| 220 } | 221 } |
| 221 } | 222 } |
| 222 | 223 |
| 223 | 224 |
| 224 bool ScopeInfo::HasContext() { | 225 bool ScopeInfo::HasContext() { |
| 225 if (length() > 0) { | 226 return ContextLength() > 0; |
| 226 return ContextLength() > 0; | |
| 227 } else { | |
| 228 return false; | |
| 229 } | |
| 230 } | 227 } |
| 231 | 228 |
| 232 | 229 |
| 233 String* ScopeInfo::FunctionName() { | 230 String* ScopeInfo::FunctionName() { |
| 234 ASSERT(HasFunctionName()); | 231 ASSERT(HasFunctionName()); |
| 235 return String::cast(get(FunctionNameEntryIndex())); | 232 return String::cast(get(FunctionNameEntryIndex())); |
| 236 } | 233 } |
| 237 | 234 |
| 238 | 235 |
| 239 String* ScopeInfo::ParameterName(int var) { | 236 String* ScopeInfo::ParameterName(int var) { |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 Context::MIN_CONTEXT_SLOTS, | 498 Context::MIN_CONTEXT_SLOTS, |
| 502 ContextLocalNameEntriesIndex(), | 499 ContextLocalNameEntriesIndex(), |
| 503 ContextLocalNameEntriesIndex() + ContextLocalCount(), | 500 ContextLocalNameEntriesIndex() + ContextLocalCount(), |
| 504 this); | 501 this); |
| 505 | 502 |
| 506 PrintF("}\n"); | 503 PrintF("}\n"); |
| 507 } | 504 } |
| 508 #endif // DEBUG | 505 #endif // DEBUG |
| 509 | 506 |
| 510 } } // namespace v8::internal | 507 } } // namespace v8::internal |
| OLD | NEW |