Changeset 10076 in webkit for trunk/JavaScriptCore/bindings/runtime_array.cpp
- Timestamp:
- Aug 6, 2005, 11:17:49 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/bindings/runtime_array.cpp
r9889 r10076 44 44 } 45 45 46 bool RuntimeArrayImp::getOwnProperty(ExecState *exec, const Identifier &propertyName, Value& result) const 46 Value RuntimeArrayImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot) 47 { 48 RuntimeArrayImp *thisObj = static_cast<RuntimeArrayImp *>(slot.slotBase()); 49 return Number(thisObj->getLength()); 50 } 51 52 Value RuntimeArrayImp::indexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot) 53 { 54 RuntimeArrayImp *thisObj = static_cast<RuntimeArrayImp *>(slot.slotBase()); 55 return thisObj->getConcreteArray()->valueAt(exec, slot.index()); 56 } 57 58 bool RuntimeArrayImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) 47 59 { 48 60 if (propertyName == lengthPropertyName) { 49 result = Number(getLength());61 slot.setCustom(this, lengthGetter); 50 62 return true; 51 63 } … … 54 66 unsigned index = propertyName.toArrayIndex(&ok); 55 67 if (ok) { 56 if (index >= getLength()) 57 result = Undefined(); 58 else 59 result = getConcreteArray()->valueAt(exec, index); 68 if (index < getLength()) { 69 slot.setCustomIndex(this, index, indexGetter); 70 return true; 71 } 72 } 73 74 return ArrayInstanceImp::getOwnPropertySlot(exec, propertyName, slot); 75 } 76 77 bool RuntimeArrayImp::getOwnPropertySlot(ExecState *exec, unsigned index, PropertySlot& slot) 78 { 79 if (index < getLength()) { 80 slot.setCustomIndex(this, index, indexGetter); 60 81 return true; 61 82 } 62 83 63 return ArrayInstanceImp::getOwnProperty(exec, propertyName, result); 64 } 65 66 bool RuntimeArrayImp::getOwnProperty(ExecState *exec, unsigned index, Value& result) const 67 { 68 if (index >= getLength()) 69 result = Undefined(); 70 else 71 result = getConcreteArray()->valueAt(exec, index); 72 73 return true; 84 return ArrayInstanceImp::getOwnPropertySlot(exec, index, slot); 74 85 } 75 86 … … 103 114 } 104 115 105 106 bool RuntimeArrayImp::hasOwnProperty(ExecState *exec, const Identifier &propertyName) const107 {108 if (propertyName == lengthPropertyName)109 return true;110 111 bool ok;112 unsigned index = propertyName.toArrayIndex(&ok);113 if (ok) {114 if (index >= getLength())115 return false;116 return true;117 }118 119 return ObjectImp::hasOwnProperty(exec, propertyName);120 }121 122 bool RuntimeArrayImp::hasOwnProperty(ExecState *exec, unsigned index) const123 {124 if (index >= getLength())125 return false;126 return true;127 }128 129 116 bool RuntimeArrayImp::deleteProperty(ExecState *exec, const Identifier &propertyName) 130 117 {
Note:
See TracChangeset
for help on using the changeset viewer.