diff options
Diffstat (limited to 'src/qml/jsruntime/qv4object.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 1cb544d205..2cdc8bd1ee 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -52,16 +52,21 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(Object); Heap::Object::Object(InternalClass *internalClass, QV4::Object *prototype) - : internalClass(internalClass), - prototype(prototype ? prototype->d() : 0) + : prototype(prototype ? prototype->d() : 0) { - if (internalClass->size) { + if (internalClass) { Scope scope(internalClass->engine); ScopedObject o(scope, this); - o->ensureMemberIndex(internalClass->engine, internalClass->size); + o->setInternalClass(internalClass); } } +void Object::setInternalClass(InternalClass *ic) +{ + d()->internalClass = ic; + ensureMemberData(); +} + bool Object::setPrototype(Object *proto) { Heap::Object *pp = proto ? proto->d() : 0; @@ -197,9 +202,10 @@ void Object::markObjects(Heap::Base *that, ExecutionEngine *e) o->prototype->mark(e); } -void Object::ensureMemberIndex(uint idx) +void Object::ensureMemberData() { - d()->memberData = MemberData::reallocate(engine(), d()->memberData, idx); + QV4::InternalClass *ic = internalClass(); + d()->memberData = MemberData::reallocate(ic->engine, d()->memberData, ic->size); } void Object::insertMember(String *s, const Property *p, PropertyAttributes attributes) @@ -207,9 +213,6 @@ void Object::insertMember(String *s, const Property *p, PropertyAttributes attri uint idx; InternalClass::addMember(this, s, attributes, &idx); - - ensureMemberIndex(internalClass()->size); - if (attributes.isAccessor()) { Property *pp = propertyAt(idx); pp->value = p->value; @@ -475,7 +478,7 @@ void Object::setLookup(Managed *m, Lookup *l, const Value &value) l->classList[0] = o->internalClass(); l->index = idx; l->setter = Lookup::setter0; - o->memberData()->data[idx] = value; + *o->propertyData(idx) = value; return; } @@ -1162,7 +1165,7 @@ ReturnedValue ArrayObject::getLookup(const Managed *m, Lookup *l) // special case, as the property is on the object itself l->getter = Lookup::arrayLengthGetter; const ArrayObject *a = static_cast<const ArrayObject *>(m); - return a->memberData()->data[Heap::ArrayObject::LengthPropertyIndex].asReturnedValue(); + return a->propertyData(Heap::ArrayObject::LengthPropertyIndex)->asReturnedValue(); } return Object::getLookup(m, l); } @@ -1170,9 +1173,9 @@ ReturnedValue ArrayObject::getLookup(const Managed *m, Lookup *l) uint ArrayObject::getLength(const Managed *m) { const ArrayObject *a = static_cast<const ArrayObject *>(m); - if (a->memberData()->data[Heap::ArrayObject::LengthPropertyIndex].isInteger()) - return a->memberData()->data[Heap::ArrayObject::LengthPropertyIndex].integerValue(); - return Primitive::toUInt32(a->memberData()->data[Heap::ArrayObject::LengthPropertyIndex].doubleValue()); + if (a->propertyData(Heap::ArrayObject::LengthPropertyIndex)->isInteger()) + return a->propertyData(Heap::ArrayObject::LengthPropertyIndex)->integerValue(); + return Primitive::toUInt32(a->propertyData(Heap::ArrayObject::LengthPropertyIndex)->doubleValue()); } QStringList ArrayObject::toQStringList() const |