EncodedTiValue operationGetByVal(TiExcState* exec, EncodedTiValue encodedBase, EncodedTiValue encodedProperty) { TiValue baseValue = TiValue::decode(encodedBase); TiValue property = TiValue::decode(encodedProperty); if (LIKELY(baseValue.isCell())) { TiCell* base = baseValue.asCell(); if (property.isUInt32()) { TiGlobalData* globalData = &exec->globalData(); uint32_t i = property.asUInt32(); // FIXME: the JIT used to handle these in compiled code! if (isTiArray(globalData, base) && asArray(base)->canGetIndex(i)) return TiValue::encode(asArray(base)->getIndex(i)); // FIXME: the JITstub used to relink this to an optimized form! if (isTiString(globalData, base) && asString(base)->canGetIndex(i)) return TiValue::encode(asString(base)->getIndex(exec, i)); // FIXME: the JITstub used to relink this to an optimized form! if (isTiArrayArray(globalData, base) && asByteArray(base)->canAccessIndex(i)) return TiValue::encode(asByteArray(base)->getIndex(exec, i)); return TiValue::encode(baseValue.get(exec, i)); } if (property.isString()) { Identifier propertyName(exec, asString(property)->value(exec)); PropertySlot slot(base); if (base->fastGetOwnPropertySlot(exec, propertyName, slot)) return TiValue::encode(slot.getValue(exec, propertyName)); } } Identifier ident(exec, property.toString(exec)); return TiValue::encode(baseValue.get(exec, ident)); }
EncodedTiValue operationGetById(TiExcState* exec, EncodedTiValue encodedBase, Identifier* identifier) { TiValue baseValue = TiValue::decode(encodedBase); PropertySlot slot(baseValue); return TiValue::encode(baseValue.get(exec, *identifier, slot)); }