| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 return details_.attributes(); | 223 return details_.attributes(); |
| 224 } | 224 } |
| 225 | 225 |
| 226 PropertyDetails GetPropertyDetails() { | 226 PropertyDetails GetPropertyDetails() { |
| 227 return details_; | 227 return details_; |
| 228 } | 228 } |
| 229 | 229 |
| 230 bool IsReadOnly() { return details_.IsReadOnly(); } | 230 bool IsReadOnly() { return details_.IsReadOnly(); } |
| 231 bool IsDontDelete() { return details_.IsDontDelete(); } | 231 bool IsDontDelete() { return details_.IsDontDelete(); } |
| 232 bool IsDontEnum() { return details_.IsDontEnum(); } | 232 bool IsDontEnum() { return details_.IsDontEnum(); } |
| 233 bool IsDeleted() { return details_.IsDeleted(); } |
| 233 | 234 |
| 234 bool IsValid() { return lookup_type_ != NOT_FOUND; } | 235 bool IsValid() { return lookup_type_ != NOT_FOUND; } |
| 235 bool IsNotFound() { return lookup_type_ == NOT_FOUND; } | 236 bool IsNotFound() { return lookup_type_ == NOT_FOUND; } |
| 236 | 237 |
| 237 // Tells whether the result is a property. | 238 // Tells whether the result is a property. |
| 238 // Excluding transitions and the null descriptor. | 239 // Excluding transitions and the null descriptor. |
| 239 bool IsProperty() { | 240 bool IsProperty() { |
| 240 return IsValid() && type() < FIRST_PHANTOM_PROPERTY_TYPE; | 241 return IsValid() && type() < FIRST_PHANTOM_PROPERTY_TYPE; |
| 241 } | 242 } |
| 242 | 243 |
| 243 bool IsCacheable() { return cacheable_; } | 244 bool IsCacheable() { return cacheable_; } |
| 244 void DisallowCaching() { cacheable_ = false; } | 245 void DisallowCaching() { cacheable_ = false; } |
| 245 | 246 |
| 246 // Tells whether the value needs to be loaded. | 247 // Tells whether the value needs to be loaded. |
| 247 bool IsLoaded() { | 248 bool IsLoaded() { |
| 248 if (lookup_type_ == DESCRIPTOR_TYPE || lookup_type_ == DICTIONARY_TYPE) { | 249 if (lookup_type_ == DESCRIPTOR_TYPE || lookup_type_ == DICTIONARY_TYPE) { |
| 249 Object* target = GetLazyValue(); | 250 Object* target = GetLazyValue(); |
| 250 return !target->IsJSObject() || JSObject::cast(target)->IsLoaded(); | 251 return !target->IsJSObject() || JSObject::cast(target)->IsLoaded(); |
| 251 } | 252 } |
| 252 return true; | 253 return true; |
| 253 } | 254 } |
| 254 | 255 |
| 255 Object* GetLazyValue() { | 256 Object* GetLazyValue() { |
| 256 switch (type()) { | 257 switch (type()) { |
| 257 case FIELD: | 258 case FIELD: |
| 258 return holder()->FastPropertyAt(GetFieldIndex()); | 259 return holder()->FastPropertyAt(GetFieldIndex()); |
| 259 case NORMAL: | 260 case NORMAL: { |
| 260 return holder()->property_dictionary()->ValueAt(GetDictionaryEntry()); | 261 Object* value; |
| 262 value = holder()->property_dictionary()->ValueAt(GetDictionaryEntry()); |
| 263 if (holder()->IsJSGlobalObject()) { |
| 264 value = JSGlobalPropertyCell::cast(value)->value(); |
| 265 } |
| 266 return value; |
| 267 } |
| 261 case CONSTANT_FUNCTION: | 268 case CONSTANT_FUNCTION: |
| 262 return GetConstantFunction(); | 269 return GetConstantFunction(); |
| 263 default: | 270 default: |
| 264 return Smi::FromInt(0); | 271 return Smi::FromInt(0); |
| 265 } | 272 } |
| 266 } | 273 } |
| 267 | 274 |
| 268 Map* GetTransitionMap() { | 275 Map* GetTransitionMap() { |
| 269 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | 276 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); |
| 270 ASSERT(type() == MAP_TRANSITION); | 277 ASSERT(type() == MAP_TRANSITION); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 299 void Print(); | 306 void Print(); |
| 300 #endif | 307 #endif |
| 301 | 308 |
| 302 Object* GetValue() { | 309 Object* GetValue() { |
| 303 if (lookup_type_ == DESCRIPTOR_TYPE) { | 310 if (lookup_type_ == DESCRIPTOR_TYPE) { |
| 304 DescriptorArray* descriptors = holder()->map()->instance_descriptors(); | 311 DescriptorArray* descriptors = holder()->map()->instance_descriptors(); |
| 305 return descriptors->GetValue(number_); | 312 return descriptors->GetValue(number_); |
| 306 } | 313 } |
| 307 // In the dictionary case, the data is held in the value field. | 314 // In the dictionary case, the data is held in the value field. |
| 308 ASSERT(lookup_type_ == DICTIONARY_TYPE); | 315 ASSERT(lookup_type_ == DICTIONARY_TYPE); |
| 309 return holder()->property_dictionary()->ValueAt(GetDictionaryEntry()); | 316 return holder()->GetNormalizedProperty(this); |
| 310 } | 317 } |
| 311 | 318 |
| 312 private: | 319 private: |
| 313 JSObject* holder_; | 320 JSObject* holder_; |
| 314 int number_; | 321 int number_; |
| 315 bool cacheable_; | 322 bool cacheable_; |
| 316 PropertyDetails details_; | 323 PropertyDetails details_; |
| 317 }; | 324 }; |
| 318 | 325 |
| 319 | 326 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 406 |
| 400 // Append a descriptor to this stream. | 407 // Append a descriptor to this stream. |
| 401 void Write(Descriptor* desc); | 408 void Write(Descriptor* desc); |
| 402 // Read a descriptor from the reader and append it to this stream. | 409 // Read a descriptor from the reader and append it to this stream. |
| 403 void WriteFrom(DescriptorReader* reader); | 410 void WriteFrom(DescriptorReader* reader); |
| 404 }; | 411 }; |
| 405 | 412 |
| 406 } } // namespace v8::internal | 413 } } // namespace v8::internal |
| 407 | 414 |
| 408 #endif // V8_PROPERTY_H_ | 415 #endif // V8_PROPERTY_H_ |
| OLD | NEW |