static inline void putByVal(ExecState* exec, JSValue baseValue, uint32_t index, JSValue value) { JSGlobalData* globalData = &exec->globalData(); if (isJSArray(baseValue)) { JSArray* array = asArray(baseValue); if (array->canSetIndex(index)) { array->setIndex(*globalData, index, value); return; } JSArray::putByIndex(array, exec, index, value, strict); return; } if (isJSByteArray(baseValue) && asByteArray(baseValue)->canAccessIndex(index)) { JSByteArray* byteArray = asByteArray(baseValue); // FIXME: the JITstub used to relink this to an optimized form! if (value.isInt32()) { byteArray->setIndex(index, value.asInt32()); return; } if (value.isNumber()) { byteArray->setIndex(index, value.asNumber()); return; } } baseValue.putByIndex(exec, index, value, strict); }
bool JSByteArray::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot) { JSByteArray* thisObject = jsCast<JSByteArray*>(cell); if (thisObject->canAccessIndex(propertyName)) { slot.setValue(thisObject->getIndex(exec, propertyName)); return true; } return JSObject::getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot); }
void JSByteArray::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) { JSByteArray* thisObject = jsCast<JSByteArray*>(cell); bool ok; unsigned index = propertyName.toUInt32(ok); if (ok) { thisObject->setIndex(exec, index, value); return; } JSObject::put(thisObject, exec, propertyName, value, slot); }
bool JSByteArray::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { JSByteArray* thisObject = jsCast<JSByteArray*>(object); bool ok; unsigned index = propertyName.toUInt32(ok); if (ok && thisObject->canAccessIndex(index)) { descriptor.setDescriptor(thisObject->getIndex(exec, index), DontDelete); return true; } return JSObject::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); }
bool JSByteArray::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { JSByteArray* thisObject = jsCast<JSByteArray*>(cell); bool ok; unsigned index = propertyName.toUInt32(ok); if (ok && thisObject->canAccessIndex(index)) { slot.setValue(thisObject->getIndex(exec, index)); return true; } return JSObject::getOwnPropertySlot(thisObject, exec, propertyName, slot); }
ALWAYS_INLINE static void operationPutByValInternal(ExecState* exec, EncodedJSValue encodedBase, EncodedJSValue encodedProperty, EncodedJSValue encodedValue) { JSGlobalData* globalData = &exec->globalData(); JSValue baseValue = JSValue::decode(encodedBase); JSValue property = JSValue::decode(encodedProperty); JSValue value = JSValue::decode(encodedValue); if (LIKELY(property.isUInt32())) { uint32_t i = property.asUInt32(); if (isJSArray(globalData, baseValue)) { JSArray* jsArray = asArray(baseValue); if (jsArray->canSetIndex(i)) { jsArray->setIndex(*globalData, i, value); return; } jsArray->JSArray::put(exec, i, value); return; } if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) { JSByteArray* jsByteArray = asByteArray(baseValue); // FIXME: the JITstub used to relink this to an optimized form! if (value.isInt32()) { jsByteArray->setIndex(i, value.asInt32()); return; } double dValue = 0; if (value.getNumber(dValue)) { jsByteArray->setIndex(i, dValue); return; } } baseValue.put(exec, i, value); return; } // Don't put to an object if toString throws an exception. Identifier ident(exec, property.toString(exec)); if (!globalData->exception) { PutPropertySlot slot(strict); baseValue.put(exec, ident, value, slot); } }