Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 9e16bc435d2b665f06f036291b736649669c4b4d..ba10c39c488be2b550ca25e639100ed98067fdc4 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -644,45 +644,53 @@ static Object* Runtime_GetOwnProperty(Arguments args) { |
// This could be an element. |
uint32_t index; |
if (name->AsArrayIndex(&index)) { |
- if (!obj->HasLocalElement(index)) { |
- return Heap::undefined_value(); |
- } |
+ switch (obj->HasLocalElement(index)) { |
+ case JSObject::UNDEFINED_ELEMENT: |
+ return Heap::undefined_value(); |
- // Special handling of string objects according to ECMAScript 5 15.5.5.2. |
- // Note that this might be a string object with elements other than the |
- // actual string value. This is covered by the subsequent cases. |
- if (obj->IsStringObjectWithCharacterAt(index)) { |
- JSValue* js_value = JSValue::cast(obj); |
- String* str = String::cast(js_value->value()); |
- elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); |
- elms->set(VALUE_INDEX, str->SubString(index, index+1)); |
- elms->set(WRITABLE_INDEX, Heap::false_value()); |
- elms->set(ENUMERABLE_INDEX, Heap::false_value()); |
- elms->set(CONFIGURABLE_INDEX, Heap::false_value()); |
- return *desc; |
- } |
- |
- // This can potentially be an element in the elements dictionary or |
- // a fast element. |
- if (obj->HasDictionaryElements()) { |
- NumberDictionary* dictionary = obj->element_dictionary(); |
- int entry = dictionary->FindEntry(index); |
- PropertyDetails details = dictionary->DetailsAt(entry); |
- elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); |
- elms->set(VALUE_INDEX, dictionary->ValueAt(entry)); |
- elms->set(WRITABLE_INDEX, Heap::ToBoolean(!details.IsReadOnly())); |
- elms->set(ENUMERABLE_INDEX, Heap::ToBoolean(!details.IsDontEnum())); |
- elms->set(CONFIGURABLE_INDEX, Heap::ToBoolean(!details.IsDontDelete())); |
- return *desc; |
- } else { |
- // Elements that are stored as array elements always has: |
- // writable: true, configurable: true, enumerable: true. |
- elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); |
- elms->set(VALUE_INDEX, obj->GetElement(index)); |
- elms->set(WRITABLE_INDEX, Heap::true_value()); |
- elms->set(ENUMERABLE_INDEX, Heap::true_value()); |
- elms->set(CONFIGURABLE_INDEX, Heap::true_value()); |
- return *desc; |
+ case JSObject::STRING_CHARACTER_ELEMENT: { |
+ // Special handling of string objects according to ECMAScript 5 |
+ // 15.5.5.2. Note that this might be a string object with elements |
+ // other than the actual string value. This is covered by the |
+ // subsequent cases. |
+ JSValue* js_value = JSValue::cast(obj); |
+ String* str = String::cast(js_value->value()); |
+ elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); |
+ elms->set(VALUE_INDEX, str->SubString(index, index+1)); |
+ elms->set(WRITABLE_INDEX, Heap::false_value()); |
+ elms->set(ENUMERABLE_INDEX, Heap::false_value()); |
+ elms->set(CONFIGURABLE_INDEX, Heap::false_value()); |
+ return *desc; |
+ } |
+ |
+ case JSObject::INTERCEPTED_ELEMENT: |
+ case JSObject::FAST_ELEMENT: |
+ elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); |
+ elms->set(VALUE_INDEX, obj->GetElement(index)); |
+ elms->set(WRITABLE_INDEX, Heap::true_value()); |
+ elms->set(ENUMERABLE_INDEX, Heap::true_value()); |
antonm
2010/09/22 13:26:38
I am not sure all intercepted elements are enumera
|
+ elms->set(CONFIGURABLE_INDEX, Heap::true_value()); |
+ return *desc; |
+ |
+ case JSObject::DICTIONARY_ELEMENT: { |
+ NumberDictionary* dictionary = obj->element_dictionary(); |
+ int entry = dictionary->FindEntry(index); |
+ ASSERT(entry != NumberDictionary::kNotFound); |
+ PropertyDetails details = dictionary->DetailsAt(entry); |
+ if (details.type() == CALLBACKS) { |
+ FixedArray* callbacks = FixedArray::cast(dictionary->ValueAt(entry)); |
+ elms->set(IS_ACCESSOR_INDEX, Heap::true_value()); |
+ elms->set(GETTER_INDEX, callbacks->get(0)); |
+ elms->set(SETTER_INDEX, callbacks->get(1)); |
+ } else { |
Rico
2010/09/22 15:23:56
Add comment on why we would go in here
|
+ elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); |
+ elms->set(VALUE_INDEX, dictionary->ValueAt(entry)); |
+ elms->set(WRITABLE_INDEX, Heap::ToBoolean(!details.IsReadOnly())); |
+ } |
+ elms->set(ENUMERABLE_INDEX, Heap::ToBoolean(!details.IsDontEnum())); |
+ elms->set(CONFIGURABLE_INDEX, Heap::ToBoolean(!details.IsDontDelete())); |
+ return *desc; |
+ } |
} |
} |