aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4lookup.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-05-14 10:22:02 +0200
committerLars Knoll <lars.knoll@qt.io>2018-05-14 19:32:24 +0000
commitb9311cc01da09f7f736850f500113f3e576c21a9 (patch)
tree55f203c12d4f928f6bf731a2c63a9e7d667083f9 /src/qml/jsruntime/qv4lookup.cpp
parent1b46ba1e35af5e5d71f71d671906cefcb3b48a19 (diff)
Fix lookups of indexed properties
These can now happen through destructuring expressions, so add proper support for those. Change-Id: I3fdd4e9903ab851a5c4f5c1b64ab4e991ba7d8c1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4lookup.cpp')
-rw-r--r--src/qml/jsruntime/qv4lookup.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp
index e4a7c703fc..67b4b9dc38 100644
--- a/src/qml/jsruntime/qv4lookup.cpp
+++ b/src/qml/jsruntime/qv4lookup.cpp
@@ -71,6 +71,11 @@ ReturnedValue Lookup::resolveGetter(ExecutionEngine *engine, const Object *objec
{
Heap::Object *obj = object->d();
Identifier name = engine->identifierTable->identifier(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
+ if (name.isArrayIndex()) {
+ indexedLookup.index = name.asArrayIndex();
+ getter = getterIndexed;
+ return getter(this, engine, *object);
+ }
uint index = obj->internalClass->find(name);
if (index != UINT_MAX) {
@@ -373,6 +378,24 @@ ReturnedValue Lookup::getterProtoAccessorTwoClasses(Lookup *l, ExecutionEngine *
return getterFallback(l, engine, object);
}
+ReturnedValue Lookup::getterIndexed(Lookup *l, ExecutionEngine *engine, const Value &object)
+{
+ Object *o = object.objectValue();
+ if (o) {
+ Heap::Object *ho = o->d();
+ if (ho->arrayData && ho->arrayData->type == Heap::ArrayData::Simple) {
+ Heap::SimpleArrayData *s = ho->arrayData.cast<Heap::SimpleArrayData>();
+ if (l->indexedLookup.index < s->values.size)
+ if (!s->data(l->indexedLookup.index).isEmpty())
+ return s->data(l->indexedLookup.index).asReturnedValue();
+ }
+ return o->getIndexed(l->indexedLookup.index);
+ }
+ l->getter = getterFallback;
+ return getterFallback(l, engine, object);
+
+}
+
ReturnedValue Lookup::primitiveGetterProto(Lookup *l, ExecutionEngine *engine, const Value &object)
{
if (object.type() == l->primitiveLookup.type) {