summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-01-07 16:47:44 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-20 21:13:39 +0100
commitf5cde6dbd8ecea7c8c4b9e48f0e7d217fb24149b (patch)
treec8157ec97e2b914eae4e236b83b58b262136b500 /src
parent091d8259e0fd820801ee2ffaf87d4f42cdc52c20 (diff)
Lookup::lookup should not return a Property pointer
Change-Id: I5c9858f636c199b9cbe7cb2bffa03db14b6e1ae4 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/jsruntime/qv4lookup.cpp55
-rw-r--r--src/qml/jsruntime/qv4lookup_p.h3
-rw-r--r--src/qml/jsruntime/qv4object.cpp8
3 files changed, 49 insertions, 17 deletions
diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp
index 66dc7b7e4a..80b8b08a1a 100644
--- a/src/qml/jsruntime/qv4lookup.cpp
+++ b/src/qml/jsruntime/qv4lookup.cpp
@@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE
using namespace QV4;
-Property *Lookup::lookup(Object *obj, PropertyAttributes *attrs)
+ReturnedValue Lookup::lookup(ValueRef thisObject, Object *obj, PropertyAttributes *attrs)
{
int i = 0;
while (i < Size && obj) {
@@ -56,7 +56,7 @@ Property *Lookup::lookup(Object *obj, PropertyAttributes *attrs)
if (index != UINT_MAX) {
level = i;
*attrs = obj->internalClass->propertyData.at(index);
- return obj->memberData + index;
+ return !attrs->isAccessor() ? obj->memberData[index].value.asReturnedValue() : obj->getValue(thisObject, obj->memberData + index, *attrs);
}
obj = obj->prototype();
@@ -68,12 +68,43 @@ Property *Lookup::lookup(Object *obj, PropertyAttributes *attrs)
index = obj->internalClass->find(name);
if (index != UINT_MAX) {
*attrs = obj->internalClass->propertyData.at(index);
- return obj->memberData + index;
+ return !attrs->isAccessor() ? obj->memberData[index].value.asReturnedValue() : obj->getValue(thisObject, obj->memberData + index, *attrs);
}
obj = obj->prototype();
}
- return 0;
+ return Primitive::emptyValue().asReturnedValue();
+}
+
+ReturnedValue Lookup::lookup(Object *obj, PropertyAttributes *attrs)
+{
+ Object *thisObject = obj;
+ int i = 0;
+ while (i < Size && obj) {
+ classList[i] = obj->internalClass;
+
+ index = obj->internalClass->find(name);
+ if (index != UINT_MAX) {
+ level = i;
+ *attrs = obj->internalClass->propertyData.at(index);
+ return !attrs->isAccessor() ? obj->memberData[index].value.asReturnedValue() : thisObject->getValue(obj->memberData + index, *attrs);
+ }
+
+ obj = obj->prototype();
+ ++i;
+ }
+ level = Size;
+
+ while (obj) {
+ index = obj->internalClass->find(name);
+ if (index != UINT_MAX) {
+ *attrs = obj->internalClass->propertyData.at(index);
+ return !attrs->isAccessor() ? obj->memberData[index].value.asReturnedValue() : thisObject->getValue(obj->memberData + index, *attrs);
+ }
+
+ obj = obj->prototype();
+ }
+ return Primitive::emptyValue().asReturnedValue();
}
@@ -106,8 +137,8 @@ ReturnedValue Lookup::getterGeneric(QV4::Lookup *l, const ValueRef object)
}
PropertyAttributes attrs;
- Property *p = l->lookup(proto, &attrs);
- if (p) {
+ ReturnedValue v = l->lookup(object, proto, &attrs);
+ if (v != Primitive::emptyValue().asReturnedValue()) {
l->type = object->type();
l->proto = proto;
if (attrs.isData()) {
@@ -115,13 +146,13 @@ ReturnedValue Lookup::getterGeneric(QV4::Lookup *l, const ValueRef object)
l->getter = Lookup::primitiveGetter0;
else if (l->level == 1)
l->getter = Lookup::primitiveGetter1;
- return p->value.asReturnedValue();
+ return v;
} else {
if (l->level == 0)
l->getter = Lookup::primitiveGetterAccessor0;
else if (l->level == 1)
l->getter = Lookup::primitiveGetterAccessor1;
- return proto->getValue(object, p, attrs);
+ return v;
}
}
@@ -330,8 +361,8 @@ ReturnedValue Lookup::globalGetterGeneric(Lookup *l, ExecutionContext *ctx)
{
Object *o = ctx->engine->globalObject;
PropertyAttributes attrs;
- Property *p = l->lookup(o, &attrs);
- if (p) {
+ ReturnedValue v = l->lookup(o, &attrs);
+ if (v != Primitive::emptyValue().asReturnedValue()) {
if (attrs.isData()) {
if (l->level == 0)
l->globalGetter = globalGetter0;
@@ -339,7 +370,7 @@ ReturnedValue Lookup::globalGetterGeneric(Lookup *l, ExecutionContext *ctx)
l->globalGetter = globalGetter1;
else if (l->level == 2)
l->globalGetter = globalGetter2;
- return p->value.asReturnedValue();
+ return v;
} else {
if (l->level == 0)
l->globalGetter = globalGetterAccessor0;
@@ -347,7 +378,7 @@ ReturnedValue Lookup::globalGetterGeneric(Lookup *l, ExecutionContext *ctx)
l->globalGetter = globalGetterAccessor1;
else if (l->level == 2)
l->globalGetter = globalGetterAccessor2;
- return o->getValue(p, attrs);
+ return v;
}
}
Scope scope(ctx);
diff --git a/src/qml/jsruntime/qv4lookup_p.h b/src/qml/jsruntime/qv4lookup_p.h
index 93c2e2156e..f47b603c15 100644
--- a/src/qml/jsruntime/qv4lookup_p.h
+++ b/src/qml/jsruntime/qv4lookup_p.h
@@ -101,7 +101,8 @@ struct Lookup {
static void setterInsert1(Lookup *l, const ValueRef object, const ValueRef value);
static void setterInsert2(Lookup *l, const ValueRef object, const ValueRef value);
- Property *lookup(Object *obj, PropertyAttributes *attrs);
+ ReturnedValue lookup(ValueRef thisObject, Object *obj, PropertyAttributes *attrs);
+ ReturnedValue lookup(Object *obj, PropertyAttributes *attrs);
};
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 00d11b4cd6..819a2f6f0b 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -458,8 +458,8 @@ ReturnedValue Object::getLookup(Managed *m, Lookup *l)
{
Object *o = static_cast<Object *>(m);
PropertyAttributes attrs;
- Property *p = l->lookup(o, &attrs);
- if (p) {
+ ReturnedValue v = l->lookup(o, &attrs);
+ if (v != Primitive::emptyValue().asReturnedValue()) {
if (attrs.isData()) {
if (l->level == 0)
l->getter = Lookup::getter0;
@@ -467,7 +467,7 @@ ReturnedValue Object::getLookup(Managed *m, Lookup *l)
l->getter = Lookup::getter1;
else if (l->level == 2)
l->getter = Lookup::getter2;
- return p->value.asReturnedValue();
+ return v;
} else {
if (l->level == 0)
l->getter = Lookup::getterAccessor0;
@@ -475,7 +475,7 @@ ReturnedValue Object::getLookup(Managed *m, Lookup *l)
l->getter = Lookup::getterAccessor1;
else if (l->level == 2)
l->getter = Lookup::getterAccessor2;
- return o->getValue(p, attrs);
+ return v;
}
}
return Encode::undefined();