fullyCreate();
Scope scope(ctx);
- Property *pd = arrayData()->getProperty(index);
+ Property *pd = arrayData() ? arrayData()->getProperty(index) : 0;
Property map;
PropertyAttributes mapAttrs;
bool isMapped = false;
isMapped = arrayData()->attributes(index).isAccessor() && pd->getter() == context()->d()->engine->argumentsAccessors[index].getter();
if (isMapped) {
+ Q_ASSERT(arrayData());
mapAttrs = arrayData()->attributes(index);
map.copy(*pd, mapAttrs);
setArrayAttributes(index, Attr_Data);
ctx->d()->strictMode = strict;
if (isMapped && attrs.isData()) {
+ Q_ASSERT(arrayData());
ScopedCallData callData(scope, 1);
callData->thisObject = this->asReturnedValue();
callData->args[0] = desc.value;
if (!len)
return;
- if (!thisObject->arrayData()->length())
+ if (!thisObject->arrayData() || !thisObject->arrayData()->length())
return;
if (!(comparefn->isUndefined() || comparefn->asObject())) {
bool isSparse() const { return this && type() == Sparse; }
uint length() const {
- if (!this)
- return 0;
return vtable()->length(this);
}
}
bool isEmpty(uint i) const {
- if (!this)
- return true;
return (vtable()->get(this, i) == Primitive::emptyValue().asReturnedValue());
}
ReturnedValue get(uint i) const {
- if (!this)
- return Primitive::emptyValue().asReturnedValue();
return vtable()->get(this, i);
}
inline Property *getProperty(uint index);
inline Property *ArrayData::getProperty(uint index)
{
- if (!this)
- return 0;
if (type() != Sparse) {
SimpleArrayData *that = static_cast<SimpleArrayData *>(this);
return that->getProperty(index);
return Encode::undefined();
instance->arrayCreate();
+ Q_ASSERT(instance->arrayData());
uint len = instance->getLength();
return Encode::undefined();
instance->arrayCreate();
+ Q_ASSERT(instance->arrayData());
uint len = instance->getLength();
return Encode::undefined();
instance->arrayCreate();
+ Q_ASSERT(instance->arrayData());
uint len = instance->getLength();
for (quint32 i = 0; i < len; ++i)
callData->args[i] = arr->getIndexed(i);
} else {
- uint alen = qMin(len, arr->arrayData()->length());
+ uint alen = arr->arrayData() ? arr->arrayData()->length() : 0;
+ if (alen > len)
+ alen = len;
for (uint i = 0; i < alen; ++i)
callData->args[i] = static_cast<SimpleArrayData *>(arr->arrayData())->data(i);
for (quint32 i = alen; i < len; ++i)
}
if (idx < UINT_MAX) {
- if (!o->arrayData()->hasAttributes()) {
+ if (o->arrayData() && !o->arrayData()->hasAttributes()) {
ScopedValue v(scope, o->arrayData()->get(idx));
if (!v->isEmpty())
return v->asReturnedValue();
Property *Object::__getOwnProperty__(uint index, PropertyAttributes *attrs)
{
- Property *p = arrayData()->getProperty(index);
+ Property *p = arrayData() ? arrayData()->getProperty(index) : 0;
if (p) {
if (attrs)
*attrs = arrayData()->attributes(index);
{
const Object *o = this;
while (o) {
- Property *p = o->arrayData()->getProperty(index);
+ Property *p = o->arrayData() ? o->arrayData()->getProperty(index) : 0;
if (p) {
if (attrs)
*attrs = o->arrayData()->attributes(index);
bool Object::hasOwnProperty(uint index) const
{
- if (!arrayData()->isEmpty(index))
+ if (arrayData() && !arrayData()->isEmpty(index))
return true;
if (isStringObject()) {
String *s = static_cast<const StringObject *>(this)->d()->value.asString();
PropertyAttributes Object::queryIndexed(const Managed *m, uint index)
{
const Object *o = static_cast<const Object *>(m);
- if (o->arrayData()->get(index) != Primitive::emptyValue().asReturnedValue())
+ if (o->arrayData() && o->arrayData()->get(index) != Primitive::emptyValue().asReturnedValue())
return o->arrayData()->attributes(index);
if (o->isStringObject()) {
PropertyAttributes attrs;
Object *o = this;
while (o) {
- Property *p = o->arrayData()->getProperty(index);
+ Property *p = o->arrayData() ? o->arrayData()->getProperty(index) : 0;
if (p) {
pd = p;
attrs = o->arrayData()->attributes(index);
PropertyAttributes attrs;
- Property *pd = arrayData()->getProperty(index);
+ Property *pd = arrayData() ? arrayData()->getProperty(index) : 0;
if (pd)
attrs = arrayData()->attributes(index);
Property *current = 0;
// Clause 1
- {
+ if (arrayData()) {
current = arrayData()->getProperty(index);
if (!current && isStringObject())
current = static_cast<StringObject *>(this)->getIndex(index);
if (attrs.isEmpty())
return true;
- Property *current;
+ Property *current = 0;
PropertyAttributes cattrs;
if (member) {
current = propertyAt(index);
cattrs = internalClass()->propertyData[index];
- } else {
+ } else if (arrayData()) {
current = arrayData()->getProperty(index);
cattrs = arrayData()->attributes(index);
}
if (!member) {
// need to convert the array and the slot
initSparseArray();
+ Q_ASSERT(arrayData());
setArrayAttributes(index, cattrs);
current = arrayData()->getProperty(index);
}
if (!o->arrayData() || !o->arrayData()->length())
return Encode(true);
- if (o->arrayData()->length() && !o->arrayData()->attrs())
+ Q_ASSERT(o->arrayData() && o->arrayData()->length());
+ if (!o->arrayData()->attrs())
return Encode(false);
for (uint i = 0; i < o->arrayData()->alloc(); ++i) {
- // ### Fix for sparse arrays
if (!o->arrayData()->isEmpty(i))
if (o->arrayData()->attributes(i).isConfigurable())
return Encode(false);
if (o->internalClass() != o->internalClass()->frozen())
return Encode(false);
- if (!o->arrayData()->length())
+ if (!o->arrayData() || !o->arrayData()->length())
return Encode(true);
- if (o->arrayData()->length() && !o->arrayData()->attrs())
+ Q_ASSERT(o->arrayData() && o->arrayData()->length());
+ if (!o->arrayData()->attrs())
return Encode(false);
for (uint i = 0; i < o->arrayData()->alloc(); ++i) {
- // ### Fix for sparse arrays
if (!o->arrayData()->isEmpty(i))
if (o->arrayData()->attributes(i).isConfigurable() || o->arrayData()->attributes(i).isWritable())
return Encode(false);
}
if (idx < UINT_MAX) {
- if (!o->arrayData()->hasAttributes()) {
+ if (o->arrayData() && !o->arrayData()->hasAttributes()) {
ScopedValue v(scope, o->arrayData()->get(idx));
if (!v->isEmpty())
return v->asReturnedValue();