Changeset 4630 in webkit for trunk/JavaScriptCore/kjs/array_object.cpp
- Timestamp:
- Jul 12, 2003, 9:01:36 AM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/array_object.cpp
r3478 r4630 71 71 } 72 72 73 // Rule from ECMA 15.2 about what an array index is. 74 // Must exactly match string form of an unsigned integer, and be less than 2^32 - 1. 75 76 const unsigned maxUInt32 = 0xFFFFFFFFU; 77 const unsigned notArrayIndex = maxUInt32; 78 79 unsigned getArrayIndex(const Identifier &propertyName) 80 { 81 bool ok; 82 unsigned index = propertyName.toStrictUInt32(&ok); 83 if (!ok || index >= maxUInt32) 84 return notArrayIndex; 85 return index; 86 } 87 73 88 Value ArrayInstanceImp::get(ExecState *exec, const Identifier &propertyName) const 74 89 { … … 76 91 return Number(length); 77 92 78 bool ok; 79 unsigned index = propertyName.toULong(&ok); 80 if (ok) { 93 unsigned index = getArrayIndex(propertyName); 94 if (index != notArrayIndex) { 81 95 if (index >= length) 82 96 return Undefined(); … … 110 124 } 111 125 112 bool ok; 113 unsigned index = propertyName.toULong(&ok); 114 if (ok) { 126 unsigned index = getArrayIndex(propertyName); 127 if (index != notArrayIndex) { 115 128 put(exec, index, value, attr); 116 129 return; … … 144 157 return true; 145 158 146 bool ok; 147 unsigned index = propertyName.toULong(&ok); 148 if (ok) { 159 unsigned index = getArrayIndex(propertyName); 160 if (index != notArrayIndex) { 149 161 if (index >= length) 150 162 return false; … … 253 265 while (it != sparseProperties.end()) { 254 266 Reference ref = it++; 255 bool ok;256 if ( ref.getPropertyName(exec).toULong(&ok)> newLength) {267 unsigned index = getArrayIndex(ref.getPropertyName(exec)); 268 if (index != notArrayIndex && index > newLength) { 257 269 ref.deleteValue(exec); 258 270 }
Note:
See TracChangeset
for help on using the changeset viewer.