diff options
-rw-r--r-- | src/qml/jsruntime/qv4arrayobject.cpp | 5 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 43 | ||||
-rw-r--r-- | tests/manual/v4/TestExpectations | 6 |
3 files changed, 43 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index b1f25177dd..214ec9381c 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -147,9 +147,12 @@ Value ArrayPrototype::method_concat(SimpleCallContext *ctx) if (ArrayObject *instance = ctx->thisObject.asArrayObject()) { result->copyArrayData(instance); - } else { + } else if (ctx->thisObject.asStringObject()) { QString v = ctx->thisObject.toString(ctx)->toQString(); result->arraySet(0, Value::fromString(ctx, v)); + } else { + Object *instance = ctx->thisObject.asObject(); + result->arraySet(0, ctx->thisObject); } for (uint i = 0; i < ctx->argumentCount; ++i) { diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index ad18edd857..6d4b6016b8 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -1065,16 +1065,49 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, const QString &name, c void Object::copyArrayData(Object *other) { - arrayReserve(other->arrayDataLen); - arrayDataLen = other->arrayDataLen; - memcpy(arrayData, other->arrayData, arrayDataLen*sizeof(Property)); + Q_ASSERT(isArrayObject()); + + bool protoHasArray = false; + Object *p = other; + while ((p = p->prototype)) + if (p->arrayDataLen) + protoHasArray = true; + + bool arrayHasGetter = false; + if (!protoHasArray && other->arrayAttributes) { + for (uint i = 0; i < other->arrayDataLen; ++i) { + if (other->arrayAttributes[i].isAccessor()) { + const Property &pd = other->arrayData[i]; + FunctionObject *getter = pd.getter(); + if (getter) { + arrayHasGetter = true; + break; + } + } + } + } + + if (protoHasArray || arrayHasGetter) { + uint len = other->arrayLength(); + Q_ASSERT(len); + + for (uint i = 0; i < len; ++i) { + arraySet(i, other->getIndexed(i)); + } + } else { + arrayReserve(other->arrayDataLen); + arrayDataLen = other->arrayDataLen; + memcpy(arrayData, other->arrayData, arrayDataLen*sizeof(Property)); + } + arrayOffset = 0; + if (other->sparseArray) { sparseArray = new SparseArray(*other->sparseArray); arrayFreeList = other->arrayFreeList; } - if (isArrayObject()) - setArrayLengthUnchecked(other->arrayLength()); + + setArrayLengthUnchecked(other->arrayLength()); } diff --git a/tests/manual/v4/TestExpectations b/tests/manual/v4/TestExpectations index 17cdc3b3c3..8af484277f 100644 --- a/tests/manual/v4/TestExpectations +++ b/tests/manual/v4/TestExpectations @@ -11,9 +11,5 @@ S13_A15_T4 failing S13.2.3_A1 failing S15.4.4.3_A1_T1 failing S15.4.4.3_A3_T1 failing -15.4.4.4-5-c-i-1 failing -S15.4.4.4_A2_T1 failing -S15.4.4.4_A2_T2 failing -S15.4.4.4_A3_T1 failing S15.5.4.11_A5_T1 failing -S15.2.4.4_A14 failing
\ No newline at end of file +S15.2.4.4_A14 failing |