aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4object.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-09-23 12:10:12 +0200
committerLars Knoll <lars.knoll@qt.io>2018-09-27 08:33:55 +0000
commitf63d48d474db7e9eff7583f1b8478228b13d3c82 (patch)
tree4bc1dd1f4f7b2f9a5df5b40247e1a8245169b903 /src/qml/jsruntime/qv4object.cpp
parent1804fea8893c355dbd585e373cb9644387410a92 (diff)
Differentiate between finding for get and set in InternalClass
This is required, so we can get rid of the requirement that getter and setter live next to each other in the member data. Change-Id: I2ed57a171628af4dfecd1836d00e958c6bed9d4f Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4object.cpp')
-rw-r--r--src/qml/jsruntime/qv4object.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 476ecf7f2a..855bebff88 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -108,16 +108,14 @@ ReturnedValue Object::getValueAccessor(const Value &thisObject, const Value &v,
return f->call(jsCallData);
}
-bool Object::putValue(uint memberIndex, const Value &value)
+bool Object::putValue(uint memberIndex, PropertyAttributes attrs, const Value &value)
{
Heap::InternalClass *ic = internalClass();
if (ic->engine->hasException)
return false;
- PropertyAttributes attrs = ic->propertyData[memberIndex];
-
if (attrs.isAccessor()) {
- const FunctionObject *set = propertyData(memberIndex + SetterOffset)->as<FunctionObject>();
+ const FunctionObject *set = propertyData(memberIndex)->as<FunctionObject>();
if (set) {
Scope scope(ic->engine);
ScopedFunctionObject setter(scope, set);
@@ -256,7 +254,7 @@ void Object::insertMember(StringOrSymbol *s, const Property *p, PropertyAttribut
Heap::InternalClass::addMember(this, key, attributes, &idx);
if (attributes.isAccessor()) {
- setProperty(idx + GetterOffset, p->value);
+ setProperty(idx, p->value);
setProperty(idx + SetterOffset, p->set);
} else {
setProperty(idx, p->value);
@@ -295,10 +293,10 @@ PropertyIndex Object::getValueOrSetter(PropertyKey id, PropertyAttributes *attrs
} else {
Heap::Object *o = d();
while (o) {
- auto idx = o->internalClass->find(id);
+ auto idx = o->internalClass->findValueOrSetter(id);
if (idx.isValid()) {
*attrs = idx.attrs;
- return o->writablePropertyData(attrs->isAccessor() ? idx.index + SetterOffset : idx.index );
+ return o->writablePropertyData(idx.index);
}
o = o->prototype();
@@ -443,7 +441,7 @@ ReturnedValue Object::internalGet(PropertyKey id, const Value *receiver, bool *h
Q_ASSERT(!id.isArrayIndex());
while (1) {
- auto idx = o->internalClass->find(id);
+ auto idx = o->internalClass->findValueOrGetter(id);
if (idx.isValid()) {
if (hasProperty)
*hasProperty = true;
@@ -488,10 +486,10 @@ bool Object::internalPut(PropertyKey id, const Value &value, Value *receiver)
if (arrayData())
propertyIndex = arrayData()->getValueOrSetter(index, &attrs);
} else {
- auto member = internalClass()->find(id);
+ auto member = internalClass()->findValueOrSetter(id);
if (member.isValid()) {
attrs = member.attrs;
- propertyIndex = d()->writablePropertyData(member.attrs.isAccessor() ? member.index + SetterOffset : member.index);
+ propertyIndex = d()->writablePropertyData(member.index);
}
}
@@ -588,7 +586,7 @@ bool Object::internalDeleteProperty(PropertyKey id)
return false;
}
- auto memberIdx = internalClass()->find(id);
+ auto memberIdx = internalClass()->findValueOrGetter(id);
if (memberIdx.isValid()) {
if (memberIdx.attrs.isConfigurable()) {
Heap::InternalClass::removeMember(this, id);
@@ -804,7 +802,7 @@ PropertyAttributes Object::virtualGetOwnProperty(const Managed *m, PropertyKey i
} else {
Q_ASSERT(id.asStringOrSymbol());
- auto member = o->internalClass()->find(id);
+ auto member = o->internalClass()->findValueOrGetter(id);
if (member.isValid()) {
attrs = member.attrs;
if (p) {
@@ -854,7 +852,7 @@ bool Object::virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property
return o->internalDefineOwnProperty(scope.engine, index, nullptr, p, attrs);
}
- auto memberIndex = o->internalClass()->find(id);
+ auto memberIndex = o->internalClass()->findValueOrGetter(id);
Scoped<StringOrSymbol> name(scope, id.asStringOrSymbol());
if (!memberIndex.isValid()) {