diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-01-15 11:36:57 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@digia.com> | 2015-01-23 08:07:32 +0100 |
commit | 002a5d4303b3b182ae4abc4a752c49787c1c2821 (patch) | |
tree | 69c7666ed1061c7acacee1d76597c06405459c80 /src/qml/jsruntime | |
parent | fddc75e862032163af36d2282051758647b62d15 (diff) |
Get rid of most uses of ValueRef
Instead pass a const Value & into the functions
With our new inheritance structure, we can get rid of ValueRef
and instead simply pass a pointer to a Value again. Pointers to
Values are safe to use again now, as they are now guaranteed to
be in a place where the GC knows about them.
Change-Id: I44c606fde764db3993b8128fd6fb781d3a298e53
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
46 files changed, 880 insertions, 884 deletions
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index 5e002446ed..f48ab9e39d 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -160,7 +160,7 @@ ReturnedValue ArgumentsObject::getIndexed(Managed *m, uint index, bool *hasPrope return Encode::undefined(); } -void ArgumentsObject::putIndexed(Managed *m, uint index, const ValueRef value) +void ArgumentsObject::putIndexed(Managed *m, uint index, const Value &value) { ArgumentsObject *args = static_cast<ArgumentsObject *>(m); if (!args->fullyCreated() && index >= static_cast<uint>(args->context()->callData->argc)) diff --git a/src/qml/jsruntime/qv4argumentsobject_p.h b/src/qml/jsruntime/qv4argumentsobject_p.h index ca7fdffa6c..970fa03d2a 100644 --- a/src/qml/jsruntime/qv4argumentsobject_p.h +++ b/src/qml/jsruntime/qv4argumentsobject_p.h @@ -112,7 +112,7 @@ struct ArgumentsObject: Object { bool defineOwnProperty(ExecutionEngine *engine, uint index, const Property *desc, PropertyAttributes attrs); static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); - static void putIndexed(Managed *m, uint index, const ValueRef value); + static void putIndexed(Managed *m, uint index, const Value &value); static bool deleteIndexedProperty(Managed *m, uint index); static PropertyAttributes queryIndexed(const Managed *m, uint index); static void markObjects(Heap::Base *that, ExecutionEngine *e); diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index 8f1fe1bbe6..3157a41d21 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -229,7 +229,7 @@ ReturnedValue SimpleArrayData::get(const Heap::ArrayData *d, uint index) return dd->data(index).asReturnedValue(); } -bool SimpleArrayData::put(Object *o, uint index, ValueRef value) +bool SimpleArrayData::put(Object *o, uint index, const Value &value) { Heap::SimpleArrayData *dd = static_cast<Heap::SimpleArrayData *>(o->d()->arrayData); Q_ASSERT(index >= dd->len || !dd->attrs || !dd->attrs[index].isAccessor()); @@ -317,7 +317,7 @@ uint SimpleArrayData::length(const Heap::ArrayData *d) return d->len; } -bool SimpleArrayData::putArray(Object *o, uint index, Value *values, uint n) +bool SimpleArrayData::putArray(Object *o, uint index, const Value *values, uint n) { Heap::SimpleArrayData *dd = static_cast<Heap::SimpleArrayData *>(o->d()->arrayData); if (index + n > dd->alloc) { @@ -414,9 +414,9 @@ ReturnedValue SparseArrayData::get(const Heap::ArrayData *d, uint index) return s->arrayData[index].asReturnedValue(); } -bool SparseArrayData::put(Object *o, uint index, ValueRef value) +bool SparseArrayData::put(Object *o, uint index, const Value &value) { - if (value->isEmpty()) + if (value.isEmpty()) return true; Heap::SparseArrayData *s = static_cast<Heap::SparseArrayData *>(o->d()->arrayData); @@ -546,7 +546,7 @@ uint SparseArrayData::length(const Heap::ArrayData *d) return n ? n->key() + 1 : 0; } -bool SparseArrayData::putArray(Object *o, uint index, Value *values, uint n) +bool SparseArrayData::putArray(Object *o, uint index, const Value *values, uint n) { for (uint i = 0; i < n; ++i) put(o, index + i, values[i]); @@ -636,7 +636,7 @@ Property *ArrayData::insert(Object *o, uint index, bool isAccessor) class ArrayElementLessThan { public: - inline ArrayElementLessThan(ExecutionEngine *engine, Object *thisObject, const ValueRef comparefn) + inline ArrayElementLessThan(ExecutionEngine *engine, Object *thisObject, const Value &comparefn) : m_engine(engine), thisObject(thisObject), m_comparefn(comparefn) {} bool operator()(Value v1, Value v2) const; @@ -644,7 +644,7 @@ public: private: ExecutionEngine *m_engine; Object *thisObject; - const ValueRef m_comparefn; + const Value &m_comparefn; }; @@ -727,7 +727,7 @@ top: } -void ArrayData::sort(ExecutionEngine *engine, Object *thisObject, const ValueRef comparefn, uint len) +void ArrayData::sort(ExecutionEngine *engine, Object *thisObject, const Value &comparefn, uint len) { if (!len) return; @@ -738,7 +738,7 @@ void ArrayData::sort(ExecutionEngine *engine, Object *thisObject, const ValueRef if (!arrayData || !arrayData->length()) return; - if (!(comparefn->isUndefined() || comparefn->asObject())) { + if (!(comparefn.isUndefined() || comparefn.asObject())) { engine->throwTypeError(); return; } diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h index 76451480c3..5ae3883647 100644 --- a/src/qml/jsruntime/qv4arraydata_p.h +++ b/src/qml/jsruntime/qv4arraydata_p.h @@ -61,8 +61,8 @@ struct ArrayVTable uint type; Heap::ArrayData *(*reallocate)(Object *o, uint n, bool enforceAttributes); ReturnedValue (*get)(const Heap::ArrayData *d, uint index); - bool (*put)(Object *o, uint index, ValueRef value); - bool (*putArray)(Object *o, uint index, Value *values, uint n); + bool (*put)(Object *o, uint index, const Value &value); + bool (*putArray)(Object *o, uint index, const Value *values, uint n); bool (*del)(Object *o, uint index); void (*setAttribute)(Object *o, uint index, PropertyAttributes attrs); void (*push_front)(Object *o, Value *values, uint n); @@ -203,7 +203,7 @@ struct Q_QML_EXPORT ArrayData : public Managed static void ensureAttributes(Object *o); static void realloc(Object *o, Type newType, uint alloc, bool enforceAttributes); - static void sort(ExecutionEngine *engine, Object *thisObject, const ValueRef comparefn, uint dataLen); + static void sort(ExecutionEngine *engine, Object *thisObject, const Value &comparefn, uint dataLen); static uint append(Object *obj, ArrayObject *otherObj, uint n); static Property *insert(Object *o, uint index, bool isAccessor = false); }; @@ -224,8 +224,8 @@ struct Q_QML_EXPORT SimpleArrayData : public ArrayData static void markObjects(Heap::Base *d, ExecutionEngine *e); static ReturnedValue get(const Heap::ArrayData *d, uint index); - static bool put(Object *o, uint index, ValueRef value); - static bool putArray(Object *o, uint index, Value *values, uint n); + static bool put(Object *o, uint index, const Value &value); + static bool putArray(Object *o, uint index, const Value *values, uint n); static bool del(Object *o, uint index); static void setAttribute(Object *o, uint index, PropertyAttributes attrs); static void push_front(Object *o, Value *values, uint n); @@ -253,8 +253,8 @@ struct Q_QML_EXPORT SparseArrayData : public ArrayData static Heap::ArrayData *reallocate(Object *o, uint n, bool enforceAttributes); static ReturnedValue get(const Heap::ArrayData *d, uint index); - static bool put(Object *o, uint index, ValueRef value); - static bool putArray(Object *o, uint index, Value *values, uint n); + static bool put(Object *o, uint index, const Value &value); + static bool putArray(Object *o, uint index, const Value *values, uint n); static bool del(Object *o, uint index); static void setAttribute(Object *o, uint index, PropertyAttributes attrs); static void push_front(Object *o, Value *values, uint n); diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 6c677e856f..d3c16bc2c0 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -143,9 +143,8 @@ ReturnedValue ArrayPrototype::method_concat(CallContext *ctx) ScopedObject thisObject(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); if (!thisObject) return Encode::undefined(); - ScopedArrayObject instance(scope, thisObject); - if (instance) { - result->copyArrayData(instance); + if (thisObject->isArrayObject()) { + result->copyArrayData(thisObject); } else { result->arraySet(0, thisObject); } diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 29f4278879..3db957c9bb 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -87,7 +87,7 @@ Heap::WithContext *ExecutionContext::newWithContext(Object *with) return d()->engine->memoryManager->alloc<WithContext>(d()->engine, with); } -Heap::CatchContext *ExecutionContext::newCatchContext(String *exceptionVarName, const ValueRef exceptionValue) +Heap::CatchContext *ExecutionContext::newCatchContext(String *exceptionVarName, const Value &exceptionValue) { return d()->engine->memoryManager->alloc<CatchContext>(d()->engine, exceptionVarName, exceptionValue); } @@ -146,7 +146,7 @@ Heap::WithContext::WithContext(ExecutionEngine *engine, QV4::Object *with) withObject = with ? with->d() : 0; } -Heap::CatchContext::CatchContext(ExecutionEngine *engine, QV4::String *exceptionVarName, const ValueRef exceptionValue) +Heap::CatchContext::CatchContext(ExecutionEngine *engine, QV4::String *exceptionVarName, const Value &exceptionValue) : Heap::ExecutionContext(engine, Heap::ExecutionContext::Type_CatchContext) { strictMode = parent->strictMode; @@ -282,7 +282,7 @@ void ExecutionContext::markObjects(Heap::Base *m, ExecutionEngine *engine) } } -void ExecutionContext::setProperty(String *name, const ValueRef value) +void ExecutionContext::setProperty(String *name, const Value &value) { Scope scope(this); ScopedContext ctx(scope, this); @@ -294,7 +294,7 @@ void ExecutionContext::setProperty(String *name, const ValueRef value) return; } } else if (ctx->d()->type == Heap::ExecutionContext::Type_CatchContext && static_cast<Heap::CatchContext *>(ctx->d())->exceptionVarName->isEqualTo(name)) { - static_cast<Heap::CatchContext *>(ctx->d())->exceptionValue = *value; + static_cast<Heap::CatchContext *>(ctx->d())->exceptionValue = value; return; } else { ScopedObject activation(scope, (Object *)0); @@ -304,10 +304,10 @@ void ExecutionContext::setProperty(String *name, const ValueRef value) uint index = c->function->function->internalClass->find(name); if (index < UINT_MAX) { if (index < c->function->formalParameterCount()) { - c->callData->args[c->function->formalParameterCount() - index - 1] = *value; + c->callData->args[c->function->formalParameterCount() - index - 1] = value; } else { index -= c->function->formalParameterCount(); - c->locals[index] = *value; + c->locals[index] = value; } return; } diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 0b70677cb3..4d27b0456c 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -118,7 +118,7 @@ struct GlobalContext : ExecutionContext { }; struct CatchContext : ExecutionContext { - CatchContext(ExecutionEngine *engine, QV4::String *exceptionVarName, const ValueRef exceptionValue); + CatchContext(ExecutionEngine *engine, QV4::String *exceptionVarName, const Value &exceptionValue); StringValue exceptionVarName; Value exceptionValue; }; @@ -144,12 +144,12 @@ struct Q_QML_EXPORT ExecutionContext : public Managed Heap::CallContext *newCallContext(FunctionObject *f, CallData *callData); Heap::WithContext *newWithContext(Object *with); - Heap::CatchContext *newCatchContext(String *exceptionVarName, const ValueRef exceptionValue); + Heap::CatchContext *newCatchContext(String *exceptionVarName, const Value &exceptionValue); Heap::CallContext *newQmlContext(FunctionObject *f, Object *qml); void createMutableBinding(String *name, bool deletable); - void setProperty(String *name, const ValueRef value); + void setProperty(String *name, const Value &value); ReturnedValue getProperty(String *name); ReturnedValue getPropertyAndBase(String *name, Heap::Object **base); bool deleteProperty(String *name); diff --git a/src/qml/jsruntime/qv4dateobject_p.h b/src/qml/jsruntime/qv4dateobject_p.h index 9b0eb91109..4bb911d44e 100644 --- a/src/qml/jsruntime/qv4dateobject_p.h +++ b/src/qml/jsruntime/qv4dateobject_p.h @@ -52,7 +52,7 @@ struct DateObject : Object { value = Encode(qSNaN()); } - DateObject(QV4::ExecutionEngine *engine, const ValueRef date) + DateObject(QV4::ExecutionEngine *engine, const Value &date) : Object(engine->emptyClass, engine->datePrototype.asObject()) { value = date; @@ -74,7 +74,7 @@ struct DateObject: Object { Value date() const { return d()->value; } Value &date() { return d()->value; } - void setDate(const ValueRef date) { d()->value = date; } + void setDate(const Value &date) { d()->value = date; } QDateTime toQDateTime() const; }; diff --git a/src/qml/jsruntime/qv4debugging.cpp b/src/qml/jsruntime/qv4debugging.cpp index 01ee9585c3..46eac6eb2b 100644 --- a/src/qml/jsruntime/qv4debugging.cpp +++ b/src/qml/jsruntime/qv4debugging.cpp @@ -484,7 +484,7 @@ void Debugger::collectReturnedValue(Collector *collector) const return; Scope scope(m_engine); - ScopedObject o(scope, m_returnedValue); + ScopedObject o(scope, m_returnedValue.valueRef()); collector->collect(o); } diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 366e5c7603..9dba5c2275 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -533,21 +533,21 @@ Heap::String *ExecutionEngine::newIdentifier(const QString &text) return identifierTable->insertString(text); } -Heap::Object *ExecutionEngine::newStringObject(const ValueRef value) +Heap::Object *ExecutionEngine::newStringObject(const Value &value) { Scope scope(this); Scoped<StringObject> object(scope, memoryManager->alloc<StringObject>(this, value)); return object->d(); } -Heap::Object *ExecutionEngine::newNumberObject(const ValueRef value) +Heap::Object *ExecutionEngine::newNumberObject(const Value &value) { Scope scope(this); Scoped<NumberObject> object(scope, memoryManager->alloc<NumberObject>(this, value)); return object->d(); } -Heap::Object *ExecutionEngine::newBooleanObject(const ValueRef value) +Heap::Object *ExecutionEngine::newBooleanObject(const Value &value) { Scope scope(this); ScopedObject object(scope, memoryManager->alloc<BooleanObject>(this, value)); @@ -582,7 +582,7 @@ Heap::ArrayObject *ExecutionEngine::newArrayObject(InternalClass *ic, Object *pr } -Heap::DateObject *ExecutionEngine::newDateObject(const ValueRef value) +Heap::DateObject *ExecutionEngine::newDateObject(const Value &value) { Scope scope(this); Scoped<DateObject> object(scope, memoryManager->alloc<DateObject>(this, value)); @@ -625,7 +625,7 @@ Heap::RegExpObject *ExecutionEngine::newRegExpObject(const QRegExp &re) return object->d(); } -Heap::Object *ExecutionEngine::newErrorObject(const ValueRef value) +Heap::Object *ExecutionEngine::newErrorObject(const Value &value) { Scope scope(this); ScopedObject object(scope, memoryManager->alloc<ErrorObject>(emptyClass, errorPrototype.asObject(), value)); @@ -677,7 +677,7 @@ Heap::Object *ExecutionEngine::newRangeErrorObject(const QString &message) return o->d(); } -Heap::Object *ExecutionEngine::newURIErrorObject(const ValueRef message) +Heap::Object *ExecutionEngine::newURIErrorObject(const Value &message) { Scope scope(this); ScopedObject o(scope, memoryManager->alloc<URIErrorObject>(this, message)); @@ -985,7 +985,7 @@ QmlExtensions *ExecutionEngine::qmlExtensions() return m_qmlExtensions; } -ReturnedValue ExecutionEngine::throwError(const ValueRef value) +ReturnedValue ExecutionEngine::throwError(const Value &value) { // we can get in here with an exception already set, as the runtime // doesn't check after every operation that can throw. @@ -1058,10 +1058,10 @@ ReturnedValue ExecutionEngine::throwTypeError(const QString &message) return throwError(error); } -ReturnedValue ExecutionEngine::throwReferenceError(const ValueRef value) +ReturnedValue ExecutionEngine::throwReferenceError(const Value &value) { Scope scope(this); - ScopedString s(scope, value->toString(this)); + ScopedString s(scope, value.toString(this)); QString msg = s->toQString() + QStringLiteral(" is not defined"); ScopedObject error(scope, newReferenceErrorObject(msg)); return throwError(error); @@ -1082,16 +1082,16 @@ ReturnedValue ExecutionEngine::throwRangeError(const QString &message) return throwError(error); } -ReturnedValue ExecutionEngine::throwRangeError(const ValueRef value) +ReturnedValue ExecutionEngine::throwRangeError(const Value &value) { Scope scope(this); - ScopedString s(scope, value->toString(this)); + ScopedString s(scope, value.toString(this)); QString msg = s->toQString() + QStringLiteral(" out of range"); ScopedObject error(scope, newRangeErrorObject(msg)); return throwError(error); } -ReturnedValue ExecutionEngine::throwURIError(const ValueRef msg) +ReturnedValue ExecutionEngine::throwURIError(const Value &msg) { Scope scope(this); ScopedObject error(scope, newURIErrorObject(msg)); @@ -1148,10 +1148,10 @@ bool ExecutionEngine::recheckCStackLimits() // Variant conversion code typedef QSet<QV4::Heap::Object *> V4ObjectSet; -static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::ValueRef value, int typeHint, bool createJSValueForObjects, V4ObjectSet *visitedObjects); -static QObject *qtObjectFromJS(QV4::ExecutionEngine *engine, const QV4::ValueRef value); +static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int typeHint, bool createJSValueForObjects, V4ObjectSet *visitedObjects); +static QObject *qtObjectFromJS(QV4::ExecutionEngine *engine, const QV4::Value &value); static QVariant objectToVariant(QV4::ExecutionEngine *e, QV4::Object *o, V4ObjectSet *visitedObjects = 0); -static bool convertToNativeQObject(QV4::ExecutionEngine *e, const QV4::ValueRef value, +static bool convertToNativeQObject(QV4::ExecutionEngine *e, const QV4::Value &value, const QByteArray &targetType, void **result); static QV4::ReturnedValue variantListToJS(QV4::ExecutionEngine *v4, const QVariantList &lst); @@ -1162,22 +1162,22 @@ static QV4::ReturnedValue variantToJS(QV4::ExecutionEngine *v4, const QVariant & } -QVariant ExecutionEngine::toVariant(const ValueRef value, int typeHint, bool createJSValueForObjects) +QVariant ExecutionEngine::toVariant(const Value &value, int typeHint, bool createJSValueForObjects) { return ::toVariant(this, value, typeHint, createJSValueForObjects, 0); } -static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::ValueRef value, int typeHint, bool createJSValueForObjects, V4ObjectSet *visitedObjects) +static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int typeHint, bool createJSValueForObjects, V4ObjectSet *visitedObjects) { - Q_ASSERT (!value->isEmpty()); + Q_ASSERT (!value.isEmpty()); QV4::Scope scope(e); - if (QV4::VariantObject *v = value->as<QV4::VariantObject>()) + if (QV4::VariantObject *v = value.as<QV4::VariantObject>()) return v->d()->data; if (typeHint == QVariant::Bool) - return QVariant(value->toBoolean()); + return QVariant(value.toBoolean()); if (typeHint == QMetaType::QJsonValue) return QVariant::fromValue(QV4::JsonObject::toJsonValue(value)); @@ -1185,10 +1185,10 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::ValueRef value, in if (typeHint == qMetaTypeId<QJSValue>()) return QVariant::fromValue(QJSValue(e, value.asReturnedValue())); - if (value->asObject()) { + if (value.asObject()) { QV4::ScopedObject object(scope, value); if (typeHint == QMetaType::QJsonObject - && !value->asArrayObject() && !value->asFunctionObject()) { + && !value.asArrayObject() && !value.asFunctionObject()) { return QVariant::fromValue(QV4::JsonObject::toJsonObject(object)); } else if (QV4::QObjectWrapper *wrapper = object->as<QV4::QObjectWrapper>()) { return qVariantFromValue<QObject *>(wrapper->object()); @@ -1204,7 +1204,7 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::ValueRef value, in return QV4::SequencePrototype::toVariant(object); } - if (value->asArrayObject()) { + if (value.asArrayObject()) { QV4::ScopedArrayObject a(scope, value); if (typeHint == qMetaTypeId<QList<QObject *> >()) { QList<QObject *> list; @@ -1230,21 +1230,21 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::ValueRef value, in return retn; } - if (value->isUndefined()) + if (value.isUndefined()) return QVariant(); - if (value->isNull()) + if (value.isNull()) return QVariant(QMetaType::VoidStar, (void *)0); - if (value->isBoolean()) - return value->booleanValue(); - if (value->isInteger()) - return value->integerValue(); - if (value->isNumber()) - return value->asDouble(); - if (value->isString()) - return value->stringValue()->toQString(); - if (QV4::QQmlLocaleData *ld = value->as<QV4::QQmlLocaleData>()) + if (value.isBoolean()) + return value.booleanValue(); + if (value.isInteger()) + return value.integerValue(); + if (value.isNumber()) + return value.asDouble(); + if (value.isString()) + return value.stringValue()->toQString(); + if (QV4::QQmlLocaleData *ld = value.as<QV4::QQmlLocaleData>()) return ld->d()->locale; - if (QV4::DateObject *d = value->asDateObject()) + if (QV4::DateObject *d = value.asDateObject()) return d->toQDateTime(); // NOTE: since we convert QTime to JS Date, round trip will change the variant type (to QDateTime)! @@ -1607,77 +1607,77 @@ QV4::ReturnedValue ExecutionEngine::metaTypeToJS(int type, const void *data) // Converts a JS value to a meta-type. // data must point to a place that can store a value of the given type. // Returns true if conversion succeeded, false otherwise. -bool ExecutionEngine::metaTypeFromJS(const QV4::ValueRef value, int type, void *data) +bool ExecutionEngine::metaTypeFromJS(const QV4::Value &value, int type, void *data) { QV4::Scope scope(this); // check if it's one of the types we know switch (QMetaType::Type(type)) { case QMetaType::Bool: - *reinterpret_cast<bool*>(data) = value->toBoolean(); + *reinterpret_cast<bool*>(data) = value.toBoolean(); return true; case QMetaType::Int: - *reinterpret_cast<int*>(data) = value->toInt32(); + *reinterpret_cast<int*>(data) = value.toInt32(); return true; case QMetaType::UInt: - *reinterpret_cast<uint*>(data) = value->toUInt32(); + *reinterpret_cast<uint*>(data) = value.toUInt32(); return true; case QMetaType::LongLong: - *reinterpret_cast<qlonglong*>(data) = qlonglong(value->toInteger()); + *reinterpret_cast<qlonglong*>(data) = qlonglong(value.toInteger()); return true; case QMetaType::ULongLong: - *reinterpret_cast<qulonglong*>(data) = qulonglong(value->toInteger()); + *reinterpret_cast<qulonglong*>(data) = qulonglong(value.toInteger()); return true; case QMetaType::Double: - *reinterpret_cast<double*>(data) = value->toNumber(); + *reinterpret_cast<double*>(data) = value.toNumber(); return true; case QMetaType::QString: - if (value->isUndefined() || value->isNull()) + if (value.isUndefined() || value.isNull()) *reinterpret_cast<QString*>(data) = QString(); else - *reinterpret_cast<QString*>(data) = value->toQString(); + *reinterpret_cast<QString*>(data) = value.toQString(); return true; case QMetaType::Float: - *reinterpret_cast<float*>(data) = value->toNumber(); + *reinterpret_cast<float*>(data) = value.toNumber(); return true; case QMetaType::Short: - *reinterpret_cast<short*>(data) = short(value->toInt32()); + *reinterpret_cast<short*>(data) = short(value.toInt32()); return true; case QMetaType::UShort: - *reinterpret_cast<unsigned short*>(data) = value->toUInt16(); + *reinterpret_cast<unsigned short*>(data) = value.toUInt16(); return true; case QMetaType::Char: - *reinterpret_cast<char*>(data) = char(value->toInt32()); + *reinterpret_cast<char*>(data) = char(value.toInt32()); return true; case QMetaType::UChar: - *reinterpret_cast<unsigned char*>(data) = (unsigned char)(value->toInt32()); + *reinterpret_cast<unsigned char*>(data) = (unsigned char)(value.toInt32()); return true; case QMetaType::QChar: - if (value->isString()) { - QString str = value->stringValue()->toQString(); + if (value.isString()) { + QString str = value.stringValue()->toQString(); *reinterpret_cast<QChar*>(data) = str.isEmpty() ? QChar() : str.at(0); } else { - *reinterpret_cast<QChar*>(data) = QChar(ushort(value->toUInt16())); + *reinterpret_cast<QChar*>(data) = QChar(ushort(value.toUInt16())); } return true; case QMetaType::QDateTime: - if (QV4::DateObject *d = value->asDateObject()) { + if (QV4::DateObject *d = value.asDateObject()) { *reinterpret_cast<QDateTime *>(data) = d->toQDateTime(); return true; } break; case QMetaType::QDate: - if (QV4::DateObject *d = value->asDateObject()) { + if (QV4::DateObject *d = value.asDateObject()) { *reinterpret_cast<QDate *>(data) = d->toQDateTime().date(); return true; } break; case QMetaType::QRegExp: - if (QV4::RegExpObject *r = value->as<QV4::RegExpObject>()) { + if (QV4::RegExpObject *r = value.as<QV4::RegExpObject>()) { *reinterpret_cast<QRegExp *>(data) = r->toQRegExp(); return true; } break; case QMetaType::QObjectStar: { - QV4::QObjectWrapper *qobjectWrapper = value->as<QV4::QObjectWrapper>(); - if (qobjectWrapper || value->isNull()) { + QV4::QObjectWrapper *qobjectWrapper = value.as<QV4::QObjectWrapper>(); + if (qobjectWrapper || value.isNull()) { *reinterpret_cast<QObject* *>(data) = qtObjectFromJS(scope.engine, value); return true; } break; @@ -1761,16 +1761,16 @@ bool ExecutionEngine::metaTypeFromJS(const QV4::ValueRef value, int type, void * QByteArray name = QMetaType::typeName(type); if (convertToNativeQObject(this, value, name, reinterpret_cast<void* *>(data))) return true; - if (value->as<QV4::VariantObject>() && name.endsWith('*')) { + if (value.as<QV4::VariantObject>() && name.endsWith('*')) { int valueType = QMetaType::type(name.left(name.size()-1)); - QVariant &var = value->as<QV4::VariantObject>()->d()->data; + QVariant &var = value.as<QV4::VariantObject>()->d()->data; if (valueType == var.userType()) { // We have T t, T* is requested, so return &t. *reinterpret_cast<void* *>(data) = var.data(); return true; - } else if (value->isObject()) { + } else if (value.isObject()) { // Look in the prototype chain. - QV4::ScopedObject proto(scope, value->objectValue()->prototype()); + QV4::ScopedObject proto(scope, value.objectValue()->prototype()); while (proto) { bool canCast = false; if (QV4::VariantObject *vo = proto->as<QV4::VariantObject>()) { @@ -1794,7 +1794,7 @@ bool ExecutionEngine::metaTypeFromJS(const QV4::ValueRef value, int type, void * proto = proto->prototype(); } } - } else if (value->isNull() && name.endsWith('*')) { + } else if (value.isNull() && name.endsWith('*')) { *reinterpret_cast<void* *>(data) = 0; return true; } else if (type == qMetaTypeId<QJSValue>()) { @@ -1805,7 +1805,7 @@ bool ExecutionEngine::metaTypeFromJS(const QV4::ValueRef value, int type, void * return false; } -static bool convertToNativeQObject(QV4::ExecutionEngine *e, const QV4::ValueRef value, const QByteArray &targetType, void **result) +static bool convertToNativeQObject(QV4::ExecutionEngine *e, const Value &value, const QByteArray &targetType, void **result) { if (!targetType.endsWith('*')) return false; @@ -1820,9 +1820,9 @@ static bool convertToNativeQObject(QV4::ExecutionEngine *e, const QV4::ValueRef return false; } -static QObject *qtObjectFromJS(QV4::ExecutionEngine *engine, const QV4::ValueRef value) +static QObject *qtObjectFromJS(QV4::ExecutionEngine *engine, const Value &value) { - if (!value->isObject()) + if (!value.isObject()) return 0; QV4::Scope scope(engine); diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 9ccebf6a8d..e482aeffa9 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -260,29 +260,29 @@ public: Heap::String *newString(const QString &s = QString()); Heap::String *newIdentifier(const QString &text); - Heap::Object *newStringObject(const ValueRef value); - Heap::Object *newNumberObject(const ValueRef value); - Heap::Object *newBooleanObject(const ValueRef value); + Heap::Object *newStringObject(const Value &value); + Heap::Object *newNumberObject(const Value &value); + Heap::Object *newBooleanObject(const Value &value); Heap::ArrayObject *newArrayObject(int count = 0); Heap::ArrayObject *newArrayObject(const QStringList &list); Heap::ArrayObject *newArrayObject(InternalClass *ic, Object *prototype); - Heap::DateObject *newDateObject(const ValueRef value); + Heap::DateObject *newDateObject(const Value &value); Heap::DateObject *newDateObject(const QDateTime &dt); Heap::RegExpObject *newRegExpObject(const QString &pattern, int flags); Heap::RegExpObject *newRegExpObject(RegExp *re, bool global); Heap::RegExpObject *newRegExpObject(const QRegExp &re); - Heap::Object *newErrorObject(const ValueRef value); + Heap::Object *newErrorObject(const Value &value); Heap::Object *newSyntaxErrorObject(const QString &message, const QString &fileName, int line, int column); Heap::Object *newSyntaxErrorObject(const QString &message); Heap::Object *newReferenceErrorObject(const QString &message); Heap::Object *newReferenceErrorObject(const QString &message, const QString &fileName, int lineNumber, int columnNumber); Heap::Object *newTypeErrorObject(const QString &message); Heap::Object *newRangeErrorObject(const QString &message); - Heap::Object *newURIErrorObject(const ValueRef message); + Heap::Object *newURIErrorObject(const Value &message); Heap::Object *newVariantObject(const QVariant &v); @@ -310,7 +310,7 @@ public: Value exceptionValue; StackTrace exceptionStackTrace; - ReturnedValue throwError(const ValueRef value); + ReturnedValue throwError(const Value &value); ReturnedValue catchException(StackTrace *trace = 0); ReturnedValue throwError(const QString &message); @@ -318,23 +318,23 @@ public: ReturnedValue throwSyntaxError(const QString &message, const QString &fileName, int lineNumber, int column); ReturnedValue throwTypeError(); ReturnedValue throwTypeError(const QString &message); - ReturnedValue throwReferenceError(const ValueRef value); + ReturnedValue throwReferenceError(const Value &value); ReturnedValue throwReferenceError(const QString &value, const QString &fileName, int lineNumber, int column); - ReturnedValue throwRangeError(const ValueRef value); + ReturnedValue throwRangeError(const Value &value); ReturnedValue throwRangeError(const QString &message); - ReturnedValue throwURIError(const ValueRef msg); + ReturnedValue throwURIError(const Value &msg); ReturnedValue throwUnimplemented(const QString &message); // Use only inside catch(...) -- will re-throw if no JS exception QQmlError catchExceptionAsQmlError(); // variant conversions - QVariant toVariant(const QV4::ValueRef value, int typeHint, bool createJSValueForObjects = true); + QVariant toVariant(const QV4::Value &value, int typeHint, bool createJSValueForObjects = true); QV4::ReturnedValue fromVariant(const QVariant &); QVariantMap variantMapFromJS(QV4::Object *o); - bool metaTypeFromJS(const QV4::ValueRef value, int type, void *data); + bool metaTypeFromJS(const Value &value, int type, void *data); QV4::ReturnedValue metaTypeToJS(int type, const void *data); private: diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index 30c7fe188a..bdbec790ca 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -73,7 +73,7 @@ Heap::ErrorObject::ErrorObject(InternalClass *ic, QV4::Object *prototype) e->defineDefaultProperty(QStringLiteral("name"), s); } -Heap::ErrorObject::ErrorObject(InternalClass *ic, QV4::Object *prototype, const ValueRef message, ErrorType t) +Heap::ErrorObject::ErrorObject(InternalClass *ic, QV4::Object *prototype, const Value &message, ErrorType t) : Heap::Object(ic, prototype) { errorType = t; @@ -83,7 +83,7 @@ Heap::ErrorObject::ErrorObject(InternalClass *ic, QV4::Object *prototype, const e->defineAccessorProperty(QStringLiteral("stack"), QV4::ErrorObject::method_get_stack, 0); - if (!message->isUndefined()) + if (!message.isUndefined()) e->defineDefaultProperty(QStringLiteral("message"), message); ScopedString s(scope); e->defineDefaultProperty(QStringLiteral("name"), (s = scope.engine->newString(e->className()))); @@ -182,7 +182,7 @@ DEFINE_OBJECT_VTABLE(ErrorObject); DEFINE_OBJECT_VTABLE(SyntaxErrorObject); -Heap::SyntaxErrorObject::SyntaxErrorObject(ExecutionEngine *engine, const ValueRef msg) +Heap::SyntaxErrorObject::SyntaxErrorObject(ExecutionEngine *engine, const Value &msg) : Heap::ErrorObject(engine->emptyClass, engine->syntaxErrorPrototype.asObject(), msg, SyntaxError) { } @@ -192,12 +192,12 @@ Heap::SyntaxErrorObject::SyntaxErrorObject(ExecutionEngine *engine, const QStrin { } -Heap::EvalErrorObject::EvalErrorObject(ExecutionEngine *engine, const ValueRef message) +Heap::EvalErrorObject::EvalErrorObject(ExecutionEngine *engine, const Value &message) : Heap::ErrorObject(engine->emptyClass, engine->evalErrorPrototype.asObject(), message, EvalError) { } -Heap::RangeErrorObject::RangeErrorObject(ExecutionEngine *engine, const ValueRef message) +Heap::RangeErrorObject::RangeErrorObject(ExecutionEngine *engine, const Value &message) : Heap::ErrorObject(engine->emptyClass, engine->rangeErrorPrototype.asObject(), message, RangeError) { } @@ -207,7 +207,7 @@ Heap::RangeErrorObject::RangeErrorObject(ExecutionEngine *engine, const QString { } -Heap::ReferenceErrorObject::ReferenceErrorObject(ExecutionEngine *engine, const ValueRef message) +Heap::ReferenceErrorObject::ReferenceErrorObject(ExecutionEngine *engine, const Value &message) : Heap::ErrorObject(engine->emptyClass, engine->referenceErrorPrototype.asObject(), message, ReferenceError) { } @@ -222,7 +222,7 @@ Heap::ReferenceErrorObject::ReferenceErrorObject(ExecutionEngine *engine, const { } -Heap::TypeErrorObject::TypeErrorObject(ExecutionEngine *engine, const ValueRef message) +Heap::TypeErrorObject::TypeErrorObject(ExecutionEngine *engine, const Value &message) : Heap::ErrorObject(engine->emptyClass, engine->typeErrorPrototype.asObject(), message, TypeError) { } @@ -232,7 +232,7 @@ Heap::TypeErrorObject::TypeErrorObject(ExecutionEngine *engine, const QString &m { } -Heap::URIErrorObject::URIErrorObject(ExecutionEngine *engine, const ValueRef message) +Heap::URIErrorObject::URIErrorObject(ExecutionEngine *engine, const Value &message) : Heap::ErrorObject(engine->emptyClass, engine->uRIErrorPrototype.asObject(), message, URIError) { } diff --git a/src/qml/jsruntime/qv4errorobject_p.h b/src/qml/jsruntime/qv4errorobject_p.h index 54762d8172..c583ea0372 100644 --- a/src/qml/jsruntime/qv4errorobject_p.h +++ b/src/qml/jsruntime/qv4errorobject_p.h @@ -56,7 +56,7 @@ struct ErrorObject : Object { }; ErrorObject(InternalClass *ic, QV4::Object *prototype); - ErrorObject(InternalClass *ic, QV4::Object *prototype, const ValueRef message, ErrorType t = Error); + ErrorObject(InternalClass *ic, QV4::Object *prototype, const Value &message, ErrorType t = Error); ErrorObject(InternalClass *ic, QV4::Object *prototype, const QString &message, ErrorType t = Error); ErrorObject(InternalClass *ic, QV4::Object *prototype, const QString &message, const QString &fileName, int line, int column, ErrorType t = Error); @@ -66,32 +66,32 @@ struct ErrorObject : Object { }; struct EvalErrorObject : ErrorObject { - EvalErrorObject(ExecutionEngine *engine, const ValueRef message); + EvalErrorObject(ExecutionEngine *engine, const Value &message); }; struct RangeErrorObject : ErrorObject { - RangeErrorObject(ExecutionEngine *engine, const ValueRef message); + RangeErrorObject(ExecutionEngine *engine, const Value &message); RangeErrorObject(ExecutionEngine *engine, const QString &msg); }; struct ReferenceErrorObject : ErrorObject { - ReferenceErrorObject(ExecutionEngine *engine, const ValueRef message); + ReferenceErrorObject(ExecutionEngine *engine, const Value &message); ReferenceErrorObject(ExecutionEngine *engine, const QString &msg); ReferenceErrorObject(ExecutionEngine *engine, const QString &msg, const QString &fileName, int lineNumber, int columnNumber); }; struct SyntaxErrorObject : ErrorObject { - SyntaxErrorObject(ExecutionEngine *engine, const ValueRef message); + SyntaxErrorObject(ExecutionEngine *engine, const Value &message); SyntaxErrorObject(ExecutionEngine *engine, const QString &msg, const QString &fileName, int lineNumber, int columnNumber); }; struct TypeErrorObject : ErrorObject { - TypeErrorObject(ExecutionEngine *engine, const ValueRef message); + TypeErrorObject(ExecutionEngine *engine, const Value &message); TypeErrorObject(ExecutionEngine *engine, const QString &msg); }; struct URIErrorObject : ErrorObject { - URIErrorObject(ExecutionEngine *engine, const ValueRef message); + URIErrorObject(ExecutionEngine *engine, const Value &message); }; struct ErrorCtor : Heap::FunctionObject { diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 2678186a6a..f49d53f6f6 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -620,7 +620,7 @@ DEFINE_OBJECT_VTABLE(IndexedBuiltinFunction); DEFINE_OBJECT_VTABLE(BoundFunction); Heap::BoundFunction::BoundFunction(QV4::ExecutionContext *scope, QV4::FunctionObject *target, - const ValueRef boundThis, QV4::MemberData *boundArgs) + const Value &boundThis, QV4::MemberData *boundArgs) : Heap::FunctionObject(scope, QStringLiteral("__bound function__")) , target(target->d()) , boundArgs(boundArgs ? boundArgs->d() : 0) diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index b971ca6568..844b622837 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -95,7 +95,7 @@ struct ScriptFunction : SimpleScriptFunction { }; struct BoundFunction : FunctionObject { - BoundFunction(QV4::ExecutionContext *scope, QV4::FunctionObject *target, const ValueRef boundThis, QV4::MemberData *boundArgs); + BoundFunction(QV4::ExecutionContext *scope, QV4::FunctionObject *target, const Value &boundThis, QV4::MemberData *boundArgs); FunctionObject *target; Value boundThis; MemberData *boundArgs; @@ -221,7 +221,7 @@ struct ScriptFunction: SimpleScriptFunction { struct BoundFunction: FunctionObject { V4_OBJECT2(BoundFunction, FunctionObject) - static Heap::BoundFunction *create(ExecutionContext *scope, FunctionObject *target, const ValueRef boundThis, QV4::MemberData *boundArgs) + static Heap::BoundFunction *create(ExecutionContext *scope, FunctionObject *target, const Value &boundThis, QV4::MemberData *boundArgs) { return scope->engine()->memoryManager->alloc<BoundFunction>(scope, target, boundThis, boundArgs); } diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 56e7717c26..57aea74313 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -50,11 +50,11 @@ QT_BEGIN_NAMESPACE QV4Include::QV4Include(const QUrl &url, QV4::ExecutionEngine *engine, QQmlContextData *context, - const QV4::ValueRef qmlglobal, const QV4::ValueRef callback) + const QV4::Value &qmlglobal, const QV4::Value &callback) : v4(engine), m_network(0), m_reply(0), m_url(url), m_redirectCount(0), m_context(context) { m_qmlglobal.set(engine, qmlglobal); - if (callback->asFunctionObject()) + if (callback.asFunctionObject()) m_callbackFunction.set(engine, callback); m_resultObject.set(v4, resultValue(v4)); @@ -90,11 +90,11 @@ QV4::ReturnedValue QV4Include::resultValue(QV4::ExecutionEngine *v4, Status stat return o.asReturnedValue(); } -void QV4Include::callback(const QV4::ValueRef callback, const QV4::ValueRef status) +void QV4Include::callback(const QV4::Value &callback, const QV4::Value &status) { - if (!callback->isObject()) + if (!callback.isObject()) return; - QV4::ExecutionEngine *v4 = callback->asObject()->engine(); + QV4::ExecutionEngine *v4 = callback.asObject()->engine(); QV4::Scope scope(v4); QV4::ScopedFunctionObject f(scope, callback); if (!f) diff --git a/src/qml/jsruntime/qv4include_p.h b/src/qml/jsruntime/qv4include_p.h index c6b153502f..419314f40d 100644 --- a/src/qml/jsruntime/qv4include_p.h +++ b/src/qml/jsruntime/qv4include_p.h @@ -77,13 +77,13 @@ private Q_SLOTS: private: QV4Include(const QUrl &url, QV4::ExecutionEngine *engine, QQmlContextData *context, - const QV4::ValueRef qmlglobal, const QV4::ValueRef callback); + const QV4::Value &qmlglobal, const QV4::Value &callback); ~QV4Include(); QV4::ReturnedValue result(); static QV4::ReturnedValue resultValue(QV4::ExecutionEngine *v4, Status status = Loading); - static void callback(const QV4::ValueRef callback, const QV4::ValueRef status); + static void callback(const QV4::Value &callback, const QV4::Value &status); QV4::ExecutionEngine *v4; QNetworkAccessManager *m_network; diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index aa16b62716..ffeaa1b1db 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -752,8 +752,7 @@ QString Stringify::Str(const QString &key, ValueRef v) if (o) { if (!o->asFunctionObject()) { if (o->asArrayObject()) { - ScopedArrayObject a(scope, o); - return JA(a); + return JA(static_cast<ArrayObject *>(o.getPointer())); } else { return JO(o); } @@ -973,29 +972,28 @@ ReturnedValue JsonObject::fromJsonValue(ExecutionEngine *engine, const QJsonValu return Encode::undefined(); } -QJsonValue JsonObject::toJsonValue(const ValueRef value, - V4ObjectSet &visitedObjects) +QJsonValue JsonObject::toJsonValue(const Value &value, V4ObjectSet &visitedObjects) { - if (value->isNumber()) - return QJsonValue(value->toNumber()); - else if (value->isBoolean()) - return QJsonValue((bool)value->booleanValue()); - else if (value->isNull()) + if (value.isNumber()) + return QJsonValue(value.toNumber()); + else if (value.isBoolean()) + return QJsonValue((bool)value.booleanValue()); + else if (value.isNull()) return QJsonValue(QJsonValue::Null); - else if (value->isUndefined()) + else if (value.isUndefined()) return QJsonValue(QJsonValue::Undefined); - else if (value->isString()) - return QJsonValue(value->toQString()); + else if (value.isString()) + return QJsonValue(value.toQString()); - Q_ASSERT(value->isObject()); - Scope scope(value->asObject()->engine()); + Q_ASSERT(value.isObject()); + Scope scope(value.asObject()->engine()); ScopedArrayObject a(scope, value); if (a) return toJsonArray(a, visitedObjects); ScopedObject o(scope, value); if (o) return toJsonObject(o, visitedObjects); - return QJsonValue(value->toQString()); + return QJsonValue(value.toQString()); } QV4::ReturnedValue JsonObject::fromJsonObject(ExecutionEngine *engine, const QJsonObject &object) diff --git a/src/qml/jsruntime/qv4jsonobject_p.h b/src/qml/jsruntime/qv4jsonobject_p.h index 32d890c488..c257c51762 100644 --- a/src/qml/jsruntime/qv4jsonobject_p.h +++ b/src/qml/jsruntime/qv4jsonobject_p.h @@ -65,7 +65,7 @@ public: static ReturnedValue fromJsonObject(ExecutionEngine *engine, const QJsonObject &object); static ReturnedValue fromJsonArray(ExecutionEngine *engine, const QJsonArray &array); - static inline QJsonValue toJsonValue(const QV4::ValueRef value) + static inline QJsonValue toJsonValue(const QV4::Value &value) { V4ObjectSet visitedObjects; return toJsonValue(value, visitedObjects); } static inline QJsonObject toJsonObject(QV4::Object *o) { V4ObjectSet visitedObjects; return toJsonObject(o, visitedObjects); } @@ -73,7 +73,7 @@ public: { V4ObjectSet visitedObjects; return toJsonArray(a, visitedObjects); } private: - static QJsonValue toJsonValue(const QV4::ValueRef value, V4ObjectSet &visitedObjects); + static QJsonValue toJsonValue(const QV4::Value &value, V4ObjectSet &visitedObjects); static QJsonObject toJsonObject(Object *o, V4ObjectSet &visitedObjects); static QJsonArray toJsonArray(ArrayObject *a, V4ObjectSet &visitedObjects); diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index c0297696db..68c7407149 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE using namespace QV4; -ReturnedValue Lookup::lookup(ValueRef thisObject, Object *o, PropertyAttributes *attrs) +ReturnedValue Lookup::lookup(const Value &thisObject, Object *o, PropertyAttributes *attrs) { ExecutionEngine *engine = o->engine(); Identifier *name = engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]->identifier; @@ -105,25 +105,25 @@ ReturnedValue Lookup::lookup(Object *thisObject, PropertyAttributes *attrs) return Primitive::emptyValue().asReturnedValue(); } -ReturnedValue Lookup::indexedGetterGeneric(Lookup *l, const ValueRef object, const ValueRef index) +ReturnedValue Lookup::indexedGetterGeneric(Lookup *l, const Value &object, const Value &index) { - if (object->isObject() && index->asArrayIndex() < UINT_MAX) { + if (object.isObject() && index.asArrayIndex() < UINT_MAX) { l->indexedGetter = indexedGetterObjectInt; return indexedGetterObjectInt(l, object, index); } return indexedGetterFallback(l, object, index); } -ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const ValueRef object, const ValueRef index) +ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const Value &object, const Value &index) { Q_UNUSED(l); Scope scope(l->engine); - uint idx = index->asArrayIndex(); + uint idx = index.asArrayIndex(); ScopedObject o(scope, object); if (!o) { if (idx < UINT_MAX) { - if (String *str = object->asString()) { + if (String *str = object.asString()) { if (idx >= (uint)str->toQString().length()) { return Encode::undefined(); } @@ -132,8 +132,8 @@ ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const ValueRef object, co } } - if (object->isNullOrUndefined()) { - QString message = QStringLiteral("Cannot read property '%1' of %2").arg(index->toQStringNoThrow()).arg(object->toQStringNoThrow()); + if (object.isNullOrUndefined()) { + QString message = QStringLiteral("Cannot read property '%1' of %2").arg(index.toQStringNoThrow()).arg(object.toQStringNoThrow()); return l->engine->throwTypeError(message); } @@ -152,7 +152,7 @@ ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const ValueRef object, co return o->getIndexed(idx); } - ScopedString name(scope, index->toString(scope.engine)); + ScopedString name(scope, index.toString(scope.engine)); if (scope.hasException()) return Encode::undefined(); return o->get(name); @@ -160,13 +160,13 @@ ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const ValueRef object, co } -ReturnedValue Lookup::indexedGetterObjectInt(Lookup *l, const ValueRef object, const ValueRef index) +ReturnedValue Lookup::indexedGetterObjectInt(Lookup *l, const Value &object, const Value &index) { - uint idx = index->asArrayIndex(); - if (idx == UINT_MAX || !object->isObject()) + uint idx = index.asArrayIndex(); + if (idx == UINT_MAX || !object.isObject()) return indexedGetterGeneric(l, object, index); - Object *o = object->objectValue(); + Object *o = object.objectValue(); if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) { Heap::SimpleArrayData *s = static_cast<Heap::SimpleArrayData *>(o->d()->arrayData); if (idx < s->len) @@ -177,11 +177,11 @@ ReturnedValue Lookup::indexedGetterObjectInt(Lookup *l, const ValueRef object, c return indexedGetterFallback(l, object, index); } -void Lookup::indexedSetterGeneric(Lookup *l, const ValueRef object, const ValueRef index, const ValueRef v) +void Lookup::indexedSetterGeneric(Lookup *l, const Value &object, const Value &index, const Value &v) { - if (object->isObject()) { - Object *o = object->objectValue(); - if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple && index->asArrayIndex() < UINT_MAX) { + if (object.isObject()) { + Object *o = object.objectValue(); + if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple && index.asArrayIndex() < UINT_MAX) { l->indexedSetter = indexedSetterObjectInt; indexedSetterObjectInt(l, object, index, v); return; @@ -190,14 +190,14 @@ void Lookup::indexedSetterGeneric(Lookup *l, const ValueRef object, const ValueR indexedSetterFallback(l, object, index, v); } -void Lookup::indexedSetterFallback(Lookup *l, const ValueRef object, const ValueRef index, const ValueRef value) +void Lookup::indexedSetterFallback(Lookup *l, const Value &object, const Value &index, const Value &value) { Scope scope(l->engine); - ScopedObject o(scope, object->toObject(scope.engine)); + ScopedObject o(scope, object.toObject(scope.engine)); if (scope.engine->hasException) return; - uint idx = index->asArrayIndex(); + uint idx = index.asArrayIndex(); if (idx < UINT_MAX) { if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) { Heap::SimpleArrayData *s = static_cast<Heap::SimpleArrayData *>(o->d()->arrayData); @@ -210,19 +210,19 @@ void Lookup::indexedSetterFallback(Lookup *l, const ValueRef object, const Value return; } - ScopedString name(scope, index->toString(scope.engine)); + ScopedString name(scope, index.toString(scope.engine)); o->put(name, value); } -void Lookup::indexedSetterObjectInt(Lookup *l, const ValueRef object, const ValueRef index, const ValueRef v) +void Lookup::indexedSetterObjectInt(Lookup *l, const Value &object, const Value &index, const Value &v) { - uint idx = index->asArrayIndex(); - if (idx == UINT_MAX || !object->isObject()) { + uint idx = index.asArrayIndex(); + if (idx == UINT_MAX || !object.isObject()) { indexedSetterGeneric(l, object, index, v); return; } - Object *o = object->objectValue(); + Object *o = object.objectValue(); if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) { Heap::SimpleArrayData *s = static_cast<Heap::SimpleArrayData *>(o->d()->arrayData); if (idx < s->len) { @@ -233,13 +233,13 @@ void Lookup::indexedSetterObjectInt(Lookup *l, const ValueRef object, const Valu indexedSetterFallback(l, object, index, v); } -ReturnedValue Lookup::getterGeneric(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::getterGeneric(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (Object *o = object->asObject()) + if (Object *o = object.asObject()) return o->getLookup(l); Object *proto; - switch (object->type()) { + switch (object.type()) { case Value::Undefined_Type: case Value::Null_Type: return engine->throwTypeError(); @@ -247,7 +247,7 @@ ReturnedValue Lookup::getterGeneric(Lookup *l, ExecutionEngine *engine, const Va proto = engine->booleanPrototype.asObject(); break; case Value::Managed_Type: { - Q_ASSERT(object->isString()); + Q_ASSERT(object.isString()); proto = engine->stringPrototype.asObject(); Scope scope(engine); ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]); @@ -266,7 +266,7 @@ ReturnedValue Lookup::getterGeneric(Lookup *l, ExecutionEngine *engine, const Va PropertyAttributes attrs; ReturnedValue v = l->lookup(object, proto, &attrs); if (v != Primitive::emptyValue().asReturnedValue()) { - l->type = object->type(); + l->type = object.type(); l->proto = proto; if (attrs.isData()) { if (l->level == 0) @@ -286,12 +286,12 @@ ReturnedValue Lookup::getterGeneric(Lookup *l, ExecutionEngine *engine, const Va return Encode::undefined(); } -ReturnedValue Lookup::getterTwoClasses(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::getterTwoClasses(Lookup *l, ExecutionEngine *engine, const Value &object) { Lookup l1 = *l; if (l1.getter == Lookup::getter0 || l1.getter == Lookup::getter1) { - if (Object *o = object->asObject()) { + if (Object *o = object.asObject()) { ReturnedValue v = o->getLookup(l); Lookup l2 = *l; @@ -322,34 +322,34 @@ ReturnedValue Lookup::getterTwoClasses(Lookup *l, ExecutionEngine *engine, const return getterFallback(l, engine, object); } -ReturnedValue Lookup::getterFallback(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::getterFallback(Lookup *l, ExecutionEngine *engine, const Value &object) { QV4::Scope scope(engine); - QV4::ScopedObject o(scope, object->toObject(scope.engine)); + QV4::ScopedObject o(scope, object.toObject(scope.engine)); if (!o) return Encode::undefined(); ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]); return o->get(name); } -ReturnedValue Lookup::getter0(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::getter0(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object->isManaged()) { + if (object.isManaged()) { // we can safely cast to a QV4::Object here. If object is actually a string, // the internal class won't match - Object *o = object->objectValue(); + Object *o = object.objectValue(); if (l->classList[0] == o->internalClass()) return o->memberData()->data[l->index].asReturnedValue(); } return getterTwoClasses(l, engine, object); } -ReturnedValue Lookup::getter1(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::getter1(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object->isManaged()) { + if (object.isManaged()) { // we can safely cast to a QV4::Object here. If object is actually a string, // the internal class won't match - Object *o = object->objectValue(); + Object *o = object.objectValue(); if (l->classList[0] == o->internalClass() && l->classList[1] == o->prototype()->internalClass) return o->prototype()->memberData->data[l->index].asReturnedValue(); @@ -357,12 +357,12 @@ ReturnedValue Lookup::getter1(Lookup *l, ExecutionEngine *engine, const ValueRef return getterTwoClasses(l, engine, object); } -ReturnedValue Lookup::getter2(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::getter2(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object->isManaged()) { + if (object.isManaged()) { // we can safely cast to a QV4::Object here. If object is actually a string, // the internal class won't match - Object *o = object->objectValue(); + Object *o = object.objectValue(); if (l->classList[0] == o->internalClass()) { Heap::Object *p = o->prototype(); if (l->classList[1] == p->internalClass) { @@ -376,12 +376,12 @@ ReturnedValue Lookup::getter2(Lookup *l, ExecutionEngine *engine, const ValueRef return getterFallback(l, engine, object); } -ReturnedValue Lookup::getter0getter0(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::getter0getter0(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object->isManaged()) { + if (object.isManaged()) { // we can safely cast to a QV4::Object here. If object is actually a string, // the internal class won't match - Object *o = object->objectValue(); + Object *o = object.objectValue(); if (l->classList[0] == o->internalClass()) return o->memberData()->data[l->index].asReturnedValue(); if (l->classList[2] == o->internalClass()) @@ -391,12 +391,12 @@ ReturnedValue Lookup::getter0getter0(Lookup *l, ExecutionEngine *engine, const V return getterFallback(l, engine, object); } -ReturnedValue Lookup::getter0getter1(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::getter0getter1(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object->isManaged()) { + if (object.isManaged()) { // we can safely cast to a QV4::Object here. If object is actually a string, // the internal class won't match - Object *o = object->objectValue(); + Object *o = object.objectValue(); if (l->classList[0] == o->internalClass()) return o->memberData()->data[l->index].asReturnedValue(); if (l->classList[2] == o->internalClass() && @@ -407,12 +407,12 @@ ReturnedValue Lookup::getter0getter1(Lookup *l, ExecutionEngine *engine, const V return getterFallback(l, engine, object); } -ReturnedValue Lookup::getter1getter1(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::getter1getter1(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object->isManaged()) { + if (object.isManaged()) { // we can safely cast to a QV4::Object here. If object is actually a string, // the internal class won't match - Object *o = object->objectValue(); + Object *o = object.objectValue(); if (l->classList[0] == o->internalClass() && l->classList[1] == o->prototype()->internalClass) return o->prototype()->memberData->data[l->index].asReturnedValue(); @@ -426,12 +426,12 @@ ReturnedValue Lookup::getter1getter1(Lookup *l, ExecutionEngine *engine, const V } -ReturnedValue Lookup::getterAccessor0(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::getterAccessor0(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object->isManaged()) { + if (object.isManaged()) { // we can safely cast to a QV4::Object here. If object is actually a string, // the internal class won't match - Object *o = object->objectValue(); + Object *o = object.objectValue(); if (l->classList[0] == o->internalClass()) { Scope scope(o->engine()); ScopedFunctionObject getter(scope, o->propertyAt(l->index)->getter()); @@ -439,7 +439,7 @@ ReturnedValue Lookup::getterAccessor0(Lookup *l, ExecutionEngine *engine, const return Encode::undefined(); ScopedCallData callData(scope, 0); - callData->thisObject = *object; + callData->thisObject = object; return getter->call(callData); } } @@ -447,12 +447,12 @@ ReturnedValue Lookup::getterAccessor0(Lookup *l, ExecutionEngine *engine, const return getterFallback(l, engine, object); } -ReturnedValue Lookup::getterAccessor1(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::getterAccessor1(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object->isManaged()) { + if (object.isManaged()) { // we can safely cast to a QV4::Object here. If object is actually a string, // the internal class won't match - Heap::Object *o = object->objectValue()->d(); + Heap::Object *o = object.objectValue()->d(); if (l->classList[0] == o->internalClass && l->classList[1] == o->prototype->internalClass) { Scope scope(o->internalClass->engine); @@ -461,7 +461,7 @@ ReturnedValue Lookup::getterAccessor1(Lookup *l, ExecutionEngine *engine, const return Encode::undefined(); ScopedCallData callData(scope, 0); - callData->thisObject = *object; + callData->thisObject = object; return getter->call(callData); } } @@ -469,12 +469,12 @@ ReturnedValue Lookup::getterAccessor1(Lookup *l, ExecutionEngine *engine, const return getterFallback(l, engine, object); } -ReturnedValue Lookup::getterAccessor2(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::getterAccessor2(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object->isManaged()) { + if (object.isManaged()) { // we can safely cast to a QV4::Object here. If object is actually a string, // the internal class won't match - Heap::Object *o = object->objectValue()->d(); + Heap::Object *o = object.objectValue()->d(); if (l->classList[0] == o->internalClass) { o = o->prototype; if (l->classList[1] == o->internalClass) { @@ -486,7 +486,7 @@ ReturnedValue Lookup::getterAccessor2(Lookup *l, ExecutionEngine *engine, const return Encode::undefined(); ScopedCallData callData(scope, 0); - callData->thisObject = *object; + callData->thisObject = object; return getter->call(callData); } } @@ -496,9 +496,9 @@ ReturnedValue Lookup::getterAccessor2(Lookup *l, ExecutionEngine *engine, const return getterFallback(l, engine, object); } -ReturnedValue Lookup::primitiveGetter0(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::primitiveGetter0(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object->type() == l->type) { + if (object.type() == l->type) { Object *o = l->proto; if (l->classList[0] == o->internalClass()) return o->memberData()->data[l->index].asReturnedValue(); @@ -507,9 +507,9 @@ ReturnedValue Lookup::primitiveGetter0(Lookup *l, ExecutionEngine *engine, const return getterGeneric(l, engine, object); } -ReturnedValue Lookup::primitiveGetter1(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::primitiveGetter1(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object->type() == l->type) { + if (object.type() == l->type) { Object *o = l->proto; if (l->classList[0] == o->internalClass() && l->classList[1] == o->prototype()->internalClass) @@ -519,9 +519,9 @@ ReturnedValue Lookup::primitiveGetter1(Lookup *l, ExecutionEngine *engine, const return getterGeneric(l, engine, object); } -ReturnedValue Lookup::primitiveGetterAccessor0(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::primitiveGetterAccessor0(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object->type() == l->type) { + if (object.type() == l->type) { Object *o = l->proto; if (l->classList[0] == o->internalClass()) { Scope scope(o->engine()); @@ -530,7 +530,7 @@ ReturnedValue Lookup::primitiveGetterAccessor0(Lookup *l, ExecutionEngine *engin return Encode::undefined(); ScopedCallData callData(scope, 0); - callData->thisObject = *object; + callData->thisObject = object; return getter->call(callData); } } @@ -538,9 +538,9 @@ ReturnedValue Lookup::primitiveGetterAccessor0(Lookup *l, ExecutionEngine *engin return getterGeneric(l, engine, object); } -ReturnedValue Lookup::primitiveGetterAccessor1(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::primitiveGetterAccessor1(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object->type() == l->type) { + if (object.type() == l->type) { Object *o = l->proto; if (l->classList[0] == o->internalClass() && l->classList[1] == o->prototype()->internalClass) { @@ -550,7 +550,7 @@ ReturnedValue Lookup::primitiveGetterAccessor1(Lookup *l, ExecutionEngine *engin return Encode::undefined(); ScopedCallData callData(scope, 0); - callData->thisObject = *object; + callData->thisObject = object; return getter->call(callData); } } @@ -558,18 +558,18 @@ ReturnedValue Lookup::primitiveGetterAccessor1(Lookup *l, ExecutionEngine *engin return getterGeneric(l, engine, object); } -ReturnedValue Lookup::stringLengthGetter(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::stringLengthGetter(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (String *s = object->asString()) + if (String *s = object.asString()) return Encode(s->d()->length()); l->getter = getterGeneric; return getterGeneric(l, engine, object); } -ReturnedValue Lookup::arrayLengthGetter(Lookup *l, ExecutionEngine *engine, const ValueRef object) +ReturnedValue Lookup::arrayLengthGetter(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (ArrayObject *a = object->asArrayObject()) + if (ArrayObject *a = object.asArrayObject()) return a->memberData()->data[Heap::ArrayObject::LengthPropertyIndex].asReturnedValue(); l->getter = getterGeneric; @@ -701,7 +701,7 @@ ReturnedValue Lookup::globalGetterAccessor2(Lookup *l, ExecutionEngine *engine) return globalGetterGeneric(l, engine); } -void Lookup::setterGeneric(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value) +void Lookup::setterGeneric(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value) { Scope scope(engine); ScopedObject o(scope, object); @@ -716,11 +716,11 @@ void Lookup::setterGeneric(Lookup *l, ExecutionEngine *engine, const ValueRef ob o->setLookup(l, value); } -void Lookup::setterTwoClasses(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value) +void Lookup::setterTwoClasses(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value) { Lookup l1 = *l; - if (Object *o = object->asObject()) { + if (Object *o = object.asObject()) { o->setLookup(l, value); if (l->setter == Lookup::setter0) { @@ -735,35 +735,35 @@ void Lookup::setterTwoClasses(Lookup *l, ExecutionEngine *engine, const ValueRef setterFallback(l, engine, object, value); } -void Lookup::setterFallback(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value) +void Lookup::setterFallback(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value) { QV4::Scope scope(engine); - QV4::ScopedObject o(scope, object->toObject(scope.engine)); + QV4::ScopedObject o(scope, object.toObject(scope.engine)); if (o) { ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]); o->put(name, value); } } -void Lookup::setter0(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value) +void Lookup::setter0(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value) { - Object *o = static_cast<Object *>(object->asManaged()); + Object *o = static_cast<Object *>(object.asManaged()); if (o && o->internalClass() == l->classList[0]) { - o->memberData()->data[l->index] = *value; + o->memberData()->data[l->index] = value; return; } setterTwoClasses(l, engine, object, value); } -void Lookup::setterInsert0(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value) +void Lookup::setterInsert0(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value) { - Object *o = static_cast<Object *>(object->asManaged()); + Object *o = static_cast<Object *>(object.asManaged()); if (o && o->internalClass() == l->classList[0]) { if (!o->prototype()) { if (!o->memberData() || l->index >= o->memberData()->size) o->ensureMemberIndex(l->index); - o->memberData()->data[l->index] = *value; + o->memberData()->data[l->index] = value; o->setInternalClass(l->classList[3]); return; } @@ -773,15 +773,15 @@ void Lookup::setterInsert0(Lookup *l, ExecutionEngine *engine, const ValueRef ob setterFallback(l, engine, object, value); } -void Lookup::setterInsert1(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value) +void Lookup::setterInsert1(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value) { - Object *o = static_cast<Object *>(object->asManaged()); + Object *o = static_cast<Object *>(object.asManaged()); if (o && o->internalClass() == l->classList[0]) { Heap::Object *p = o->prototype(); if (p && p->internalClass == l->classList[1]) { if (!o->memberData() || l->index >= o->memberData()->size) o->ensureMemberIndex(l->index); - o->memberData()->data[l->index] = *value; + o->memberData()->data[l->index] = value; o->setInternalClass(l->classList[3]); return; } @@ -791,9 +791,9 @@ void Lookup::setterInsert1(Lookup *l, ExecutionEngine *engine, const ValueRef ob setterFallback(l, engine, object, value); } -void Lookup::setterInsert2(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value) +void Lookup::setterInsert2(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value) { - Object *o = static_cast<Object *>(object->asManaged()); + Object *o = static_cast<Object *>(object.asManaged()); if (o && o->internalClass() == l->classList[0]) { Heap::Object *p = o->prototype(); if (p && p->internalClass == l->classList[1]) { @@ -801,7 +801,7 @@ void Lookup::setterInsert2(Lookup *l, ExecutionEngine *engine, const ValueRef ob if (p && p->internalClass == l->classList[2]) { if (!o->memberData() || l->index >= o->memberData()->size) o->ensureMemberIndex(l->index); - o->memberData()->data[l->index] = *value; + o->memberData()->data[l->index] = value; o->setInternalClass(l->classList[3]); return; } @@ -812,16 +812,16 @@ void Lookup::setterInsert2(Lookup *l, ExecutionEngine *engine, const ValueRef ob setterFallback(l, engine, object, value); } -void Lookup::setter0setter0(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value) +void Lookup::setter0setter0(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value) { - Object *o = static_cast<Object *>(object->asManaged()); + Object *o = static_cast<Object *>(object.asManaged()); if (o) { if (o->internalClass() == l->classList[0]) { - o->memberData()->data[l->index] = *value; + o->memberData()->data[l->index] = value; return; } if (o->internalClass() == l->classList[1]) { - o->memberData()->data[l->index2] = *value; + o->memberData()->data[l->index2] = value; return; } } diff --git a/src/qml/jsruntime/qv4lookup_p.h b/src/qml/jsruntime/qv4lookup_p.h index d491a62ddc..73cfddca5d 100644 --- a/src/qml/jsruntime/qv4lookup_p.h +++ b/src/qml/jsruntime/qv4lookup_p.h @@ -47,11 +47,11 @@ namespace QV4 { struct Lookup { enum { Size = 4 }; union { - ReturnedValue (*indexedGetter)(Lookup *l, const ValueRef object, const ValueRef index); - void (*indexedSetter)(Lookup *l, const ValueRef object, const ValueRef index, const ValueRef v); - ReturnedValue (*getter)(Lookup *l, ExecutionEngine *engine, const ValueRef object); + ReturnedValue (*indexedGetter)(Lookup *l, const Value &object, const Value &index); + void (*indexedSetter)(Lookup *l, const Value &object, const Value &index, const Value &v); + ReturnedValue (*getter)(Lookup *l, ExecutionEngine *engine, const Value &object); ReturnedValue (*globalGetter)(Lookup *l, ExecutionEngine *engine); - void (*setter)(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef v); + void (*setter)(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &v); }; union { ExecutionEngine *engine; @@ -70,34 +70,34 @@ struct Lookup { uint index; uint nameIndex; - static ReturnedValue indexedGetterGeneric(Lookup *l, const ValueRef object, const ValueRef index); - static ReturnedValue indexedGetterFallback(Lookup *l, const ValueRef object, const ValueRef index); - static ReturnedValue indexedGetterObjectInt(Lookup *l, const ValueRef object, const ValueRef index); - - static void indexedSetterGeneric(Lookup *l, const ValueRef object, const ValueRef index, const ValueRef v); - static void indexedSetterFallback(Lookup *l, const ValueRef object, const ValueRef index, const ValueRef value); - static void indexedSetterObjectInt(Lookup *l, const ValueRef object, const ValueRef index, const ValueRef v); - - static ReturnedValue getterGeneric(Lookup *l, ExecutionEngine *engine, const ValueRef object); - static ReturnedValue getterTwoClasses(Lookup *l, ExecutionEngine *engine, const ValueRef object); - static ReturnedValue getterFallback(Lookup *l, ExecutionEngine *engine, const ValueRef object); - - static ReturnedValue getter0(Lookup *l, ExecutionEngine *engine, const ValueRef object); - static ReturnedValue getter1(Lookup *l, ExecutionEngine *engine, const ValueRef object); - static ReturnedValue getter2(Lookup *l, ExecutionEngine *engine, const ValueRef object); - static ReturnedValue getter0getter0(Lookup *l, ExecutionEngine *engine, const ValueRef object); - static ReturnedValue getter0getter1(Lookup *l, ExecutionEngine *engine, const ValueRef object); - static ReturnedValue getter1getter1(Lookup *l, ExecutionEngine *engine, const ValueRef object); - static ReturnedValue getterAccessor0(Lookup *l, ExecutionEngine *engine, const ValueRef object); - static ReturnedValue getterAccessor1(Lookup *l, ExecutionEngine *engine, const ValueRef object); - static ReturnedValue getterAccessor2(Lookup *l, ExecutionEngine *engine, const ValueRef object); - - static ReturnedValue primitiveGetter0(Lookup *l, ExecutionEngine *engine, const ValueRef object); - static ReturnedValue primitiveGetter1(Lookup *l, ExecutionEngine *engine, const ValueRef object); - static ReturnedValue primitiveGetterAccessor0(Lookup *l, ExecutionEngine *engine, const ValueRef object); - static ReturnedValue primitiveGetterAccessor1(Lookup *l, ExecutionEngine *engine, const ValueRef object); - static ReturnedValue stringLengthGetter(Lookup *l, ExecutionEngine *engine, const ValueRef object); - static ReturnedValue arrayLengthGetter(Lookup *l, ExecutionEngine *engine, const ValueRef object); + static ReturnedValue indexedGetterGeneric(Lookup *l, const Value &object, const Value &index); + static ReturnedValue indexedGetterFallback(Lookup *l, const Value &object, const Value &index); + static ReturnedValue indexedGetterObjectInt(Lookup *l, const Value &object, const Value &index); + + static void indexedSetterGeneric(Lookup *l, const Value &object, const Value &index, const Value &v); + static void indexedSetterFallback(Lookup *l, const Value &object, const Value &index, const Value &value); + static void indexedSetterObjectInt(Lookup *l, const Value &object, const Value &index, const Value &v); + + static ReturnedValue getterGeneric(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterTwoClasses(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterFallback(Lookup *l, ExecutionEngine *engine, const Value &object); + + static ReturnedValue getter0(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getter1(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getter2(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getter0getter0(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getter0getter1(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getter1getter1(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterAccessor0(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterAccessor1(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterAccessor2(Lookup *l, ExecutionEngine *engine, const Value &object); + + static ReturnedValue primitiveGetter0(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue primitiveGetter1(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue primitiveGetterAccessor0(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue primitiveGetterAccessor1(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue stringLengthGetter(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue arrayLengthGetter(Lookup *l, ExecutionEngine *engine, const Value &object); static ReturnedValue globalGetterGeneric(Lookup *l, ExecutionEngine *engine); static ReturnedValue globalGetter0(Lookup *l, ExecutionEngine *engine); @@ -107,16 +107,16 @@ struct Lookup { static ReturnedValue globalGetterAccessor1(Lookup *l, ExecutionEngine *engine); static ReturnedValue globalGetterAccessor2(Lookup *l, ExecutionEngine *engine); - static void setterGeneric(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value); - static void setterTwoClasses(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value); - static void setterFallback(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value); - static void setter0(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value); - static void setterInsert0(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value); - static void setterInsert1(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value); - static void setterInsert2(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value); - static void setter0setter0(Lookup *l, ExecutionEngine *engine, const ValueRef object, const ValueRef value); + static void setterGeneric(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value); + static void setterTwoClasses(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value); + static void setterFallback(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value); + static void setter0(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value); + static void setterInsert0(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value); + static void setterInsert1(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value); + static void setterInsert2(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value); + static void setter0setter0(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &value); - ReturnedValue lookup(ValueRef thisObject, Object *obj, PropertyAttributes *attrs); + ReturnedValue lookup(const Value &thisObject, Object *obj, PropertyAttributes *attrs); ReturnedValue lookup(Object *obj, PropertyAttributes *attrs); }; diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 6636cb19cf..5f73ab61b3 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -129,14 +129,14 @@ struct ObjectVTable ReturnedValue (*construct)(Managed *, CallData *data); ReturnedValue (*get)(Managed *, String *name, bool *hasProperty); ReturnedValue (*getIndexed)(Managed *, uint index, bool *hasProperty); - void (*put)(Managed *, String *name, const ValueRef value); - void (*putIndexed)(Managed *, uint index, const ValueRef value); + void (*put)(Managed *, String *name, const Value &value); + void (*putIndexed)(Managed *, uint index, const Value &value); PropertyAttributes (*query)(const Managed *, String *name); PropertyAttributes (*queryIndexed)(const Managed *, uint index); bool (*deleteProperty)(Managed *m, String *name); bool (*deleteIndexedProperty)(Managed *m, uint index); ReturnedValue (*getLookup)(Managed *m, Lookup *l); - void (*setLookup)(Managed *m, Lookup *l, const ValueRef v); + void (*setLookup)(Managed *m, Lookup *l, const Value &v); uint (*getLength)(const Managed *m); void (*advanceIterator)(Managed *m, ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attributes); }; diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 13c792d784..f83e2c67bf 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -73,14 +73,14 @@ bool Object::setPrototype(Object *proto) return true; } -void Object::put(ExecutionEngine *engine, const QString &name, const ValueRef value) +void Object::put(ExecutionEngine *engine, const QString &name, const Value &value) { Scope scope(engine); ScopedString n(scope, engine->newString(name)); put(n, value); } -ReturnedValue Object::getValue(const ValueRef thisObject, const Property *p, PropertyAttributes attrs) +ReturnedValue Object::getValue(const Value &thisObject, const Property *p, PropertyAttributes attrs) { if (!attrs.isAccessor()) return p->value.asReturnedValue(); @@ -90,11 +90,11 @@ ReturnedValue Object::getValue(const ValueRef thisObject, const Property *p, Pro Scope scope(p->getter()->internalClass->engine); ScopedFunctionObject getter(scope, p->getter()); ScopedCallData callData(scope); - callData->thisObject = *thisObject; + callData->thisObject = thisObject; return getter->call(callData); } -void Object::putValue(Property *pd, PropertyAttributes attrs, const ValueRef value) +void Object::putValue(Property *pd, PropertyAttributes attrs, const Value &value) { if (internalClass()->engine->hasException) return; @@ -104,7 +104,7 @@ void Object::putValue(Property *pd, PropertyAttributes attrs, const ValueRef val Scope scope(set->internalClass->engine); ScopedFunctionObject setter(scope, set); ScopedCallData callData(scope, 1); - callData->args[0] = *value; + callData->args[0] = value; callData->thisObject = this; setter->call(callData); return; @@ -115,7 +115,7 @@ void Object::putValue(Property *pd, PropertyAttributes attrs, const ValueRef val if (!attrs.isWritable()) goto reject; - pd->value = *value; + pd->value = value; return; reject: @@ -123,7 +123,7 @@ void Object::putValue(Property *pd, PropertyAttributes attrs, const ValueRef val engine()->throwTypeError(); } -void Object::defineDefaultProperty(const QString &name, ValueRef value) +void Object::defineDefaultProperty(const QString &name, const Value &value) { ExecutionEngine *e = engine(); Scope scope(e); @@ -171,7 +171,7 @@ void Object::defineAccessorProperty(String *name, ReturnedValue (*getter)(CallCo insertMember(name, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); } -void Object::defineReadonlyProperty(const QString &name, ValueRef value) +void Object::defineReadonlyProperty(const QString &name, const Value &value) { QV4::ExecutionEngine *e = engine(); Scope scope(e); @@ -179,7 +179,7 @@ void Object::defineReadonlyProperty(const QString &name, ValueRef value) defineReadonlyProperty(s, value); } -void Object::defineReadonlyProperty(String *name, ValueRef value) +void Object::defineReadonlyProperty(String *name, const Value &value) { insertMember(name, value, Attr_ReadOnly); } @@ -385,12 +385,12 @@ ReturnedValue Object::getIndexed(Managed *m, uint index, bool *hasProperty) return static_cast<Object *>(m)->internalGetIndexed(index, hasProperty); } -void Object::put(Managed *m, String *name, const ValueRef value) +void Object::put(Managed *m, String *name, const Value &value) { static_cast<Object *>(m)->internalPut(name, value); } -void Object::putIndexed(Managed *m, uint index, const ValueRef value) +void Object::putIndexed(Managed *m, uint index, const Value &value) { static_cast<Object *>(m)->internalPutIndexed(index, value); } @@ -464,7 +464,7 @@ ReturnedValue Object::getLookup(Managed *m, Lookup *l) return Encode::undefined(); } -void Object::setLookup(Managed *m, Lookup *l, const ValueRef value) +void Object::setLookup(Managed *m, Lookup *l, const Value &value) { Scope scope(static_cast<Object *>(m)->engine()); ScopedObject o(scope, static_cast<Object *>(m)); @@ -477,7 +477,7 @@ void Object::setLookup(Managed *m, Lookup *l, const ValueRef value) l->classList[0] = o->internalClass(); l->index = idx; l->setter = Lookup::setter0; - o->memberData()->data[idx] = *value; + o->memberData()->data[idx] = value; return; } @@ -647,7 +647,7 @@ ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty) // Section 8.12.5 -void Object::internalPut(String *name, const ValueRef value) +void Object::internalPut(String *name, const Value &value) { if (internalClass()->engine->hasException) return; @@ -676,7 +676,7 @@ void Object::internalPut(String *name, const ValueRef value) goto reject; else if (isArrayObject() && name->equals(engine()->id_length)) { bool ok; - uint l = value->asArrayLength(&ok); + uint l = value.asArrayLength(&ok); if (!ok) { engine()->throwRangeError(value); return; @@ -685,7 +685,7 @@ void Object::internalPut(String *name, const ValueRef value) if (!ok) goto reject; } else { - pd->value = *value; + pd->value = value; } return; } else if (!prototype()) { @@ -715,7 +715,7 @@ void Object::internalPut(String *name, const ValueRef value) Scope scope(engine()); ScopedFunctionObject setter(scope, pd->setter()); ScopedCallData callData(scope, 1); - callData->args[0] = *value; + callData->args[0] = value; callData->thisObject = this; setter->call(callData); return; @@ -733,7 +733,7 @@ void Object::internalPut(String *name, const ValueRef value) } } -void Object::internalPutIndexed(uint index, const ValueRef value) +void Object::internalPutIndexed(uint index, const Value &value) { if (internalClass()->engine->hasException) return; @@ -760,7 +760,7 @@ void Object::internalPutIndexed(uint index, const ValueRef value) } else if (!attrs.isWritable()) goto reject; else - pd->value = *value; + pd->value = value; return; } else if (!prototype()) { if (!isExtensible()) @@ -789,7 +789,7 @@ void Object::internalPutIndexed(uint index, const ValueRef value) Scope scope(engine()); ScopedFunctionObject setter(scope, pd->setter()); ScopedCallData callData(scope, 1); - callData->args[0] = *value; + callData->args[0] = value; callData->thisObject = this; setter->call(callData); return; diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index a566716590..bbc9f4ae40 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -106,38 +106,38 @@ struct Q_QML_EXPORT Object: Managed { // // helpers // - void put(ExecutionEngine *engine, const QString &name, const ValueRef value); + void put(ExecutionEngine *engine, const QString &name, const Value &value); - static ReturnedValue getValue(const ValueRef thisObject, const Property *p, PropertyAttributes attrs); + static ReturnedValue getValue(const Value &thisObject, const Property *p, PropertyAttributes attrs); ReturnedValue getValue(const Property *p, PropertyAttributes attrs) const { Scope scope(this->engine()); ScopedValue t(scope, const_cast<Object *>(this)); return getValue(t, p, attrs); } - void putValue(Property *pd, PropertyAttributes attrs, const ValueRef value); + void putValue(Property *pd, PropertyAttributes attrs, const Value &value); /* The spec default: Writable: true, Enumerable: false, Configurable: true */ - void defineDefaultProperty(String *name, ValueRef value) { + void defineDefaultProperty(String *name, const Value &value) { insertMember(name, value, Attr_Data|Attr_NotEnumerable); } - void defineDefaultProperty(const QString &name, ValueRef value); + void defineDefaultProperty(const QString &name, const Value &value); void defineDefaultProperty(const QString &name, ReturnedValue (*code)(CallContext *), int argumentCount = 0); void defineDefaultProperty(String *name, ReturnedValue (*code)(CallContext *), int argumentCount = 0); void defineAccessorProperty(const QString &name, ReturnedValue (*getter)(CallContext *), ReturnedValue (*setter)(CallContext *)); void defineAccessorProperty(String *name, ReturnedValue (*getter)(CallContext *), ReturnedValue (*setter)(CallContext *)); /* Fixed: Writable: false, Enumerable: false, Configurable: false */ - void defineReadonlyProperty(const QString &name, ValueRef value); - void defineReadonlyProperty(String *name, ValueRef value); + void defineReadonlyProperty(const QString &name, const Value &value); + void defineReadonlyProperty(String *name, const Value &value); void ensureMemberIndex(QV4::ExecutionEngine *e, uint idx) { d()->memberData = MemberData::reallocate(e, d()->memberData, idx); } - void insertMember(String *s, const ValueRef v, PropertyAttributes attributes = Attr_Data) { + void insertMember(String *s, const Value &v, PropertyAttributes attributes = Attr_Data) { Scope scope(engine()); ScopedProperty p(scope); - p->value = *v; + p->value = v; insertMember(s, p, attributes); } void insertMember(String *s, const Property *p, PropertyAttributes attributes); @@ -155,9 +155,9 @@ public: void setArrayLengthUnchecked(uint l); void arraySet(uint index, const Property *p, PropertyAttributes attributes = Attr_Data); - void arraySet(uint index, ValueRef value); + void arraySet(uint index, const Value &value); - bool arrayPut(uint index, ValueRef value) { + bool arrayPut(uint index, const Value &value) { return arrayData()->vtable()->put(this, index, value); } bool arrayPut(uint index, Value *values, uint n) { @@ -172,7 +172,7 @@ public: } } - void push_back(const ValueRef v); + void push_back(const Value &v); ArrayData::Type arrayType() const { return arrayData() ? d()->arrayData->type : Heap::ArrayData::Simple; @@ -216,9 +216,9 @@ public: { return vtable()->get(this, name, hasProperty); } inline ReturnedValue getIndexed(uint idx, bool *hasProperty = 0) { return vtable()->getIndexed(this, idx, hasProperty); } - inline void put(String *name, const ValueRef v) + inline void put(String *name, const Value &v) { vtable()->put(this, name, v); } - inline void putIndexed(uint idx, const ValueRef v) + inline void putIndexed(uint idx, const Value &v) { vtable()->putIndexed(this, idx, v); } PropertyAttributes query(String *name) const { return vtable()->query(this, name); } @@ -230,7 +230,7 @@ public: { return vtable()->deleteIndexedProperty(this, index); } ReturnedValue getLookup(Lookup *l) { return vtable()->getLookup(this, l); } - void setLookup(Lookup *l, const ValueRef v) + void setLookup(Lookup *l, const Value &v) { vtable()->setLookup(this, l, v); } void advanceIterator(ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attributes) { vtable()->advanceIterator(this, it, name, index, p, attributes); } @@ -246,22 +246,22 @@ protected: static ReturnedValue call(Managed *m, CallData *); static ReturnedValue get(Managed *m, String *name, bool *hasProperty); static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); - static void put(Managed *m, String *name, const ValueRef value); - static void putIndexed(Managed *m, uint index, const ValueRef value); + static void put(Managed *m, String *name, const Value &value); + static void putIndexed(Managed *m, uint index, const Value &value); static PropertyAttributes query(const Managed *m, String *name); static PropertyAttributes queryIndexed(const Managed *m, uint index); static bool deleteProperty(Managed *m, String *name); static bool deleteIndexedProperty(Managed *m, uint index); static ReturnedValue getLookup(Managed *m, Lookup *l); - static void setLookup(Managed *m, Lookup *l, const ValueRef v); + static void setLookup(Managed *m, Lookup *l, const Value &v); static void advanceIterator(Managed *m, ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attributes); static uint getLength(const Managed *m); private: ReturnedValue internalGet(String *name, bool *hasProperty); ReturnedValue internalGetIndexed(uint index, bool *hasProperty); - void internalPut(String *name, const ValueRef value); - void internalPutIndexed(uint index, const ValueRef value); + void internalPut(String *name, const Value &value); + void internalPutIndexed(uint index, const Value &value); bool internalDeleteProperty(String *name); bool internalDeleteIndexedProperty(uint index); @@ -278,7 +278,7 @@ struct BooleanObject : Object { value = Encode((bool)false); } - BooleanObject(ExecutionEngine *engine, const ValueRef val) + BooleanObject(ExecutionEngine *engine, const Value &val) : Object(engine->emptyClass, engine->booleanPrototype.asObject()) { value = val; @@ -293,7 +293,7 @@ struct NumberObject : Object { value = Encode((int)0); } - NumberObject(ExecutionEngine *engine, const ValueRef val) + NumberObject(ExecutionEngine *engine, const Value &val) : Object(engine->emptyClass, engine->numberPrototype.asObject()) { value = val; @@ -353,7 +353,7 @@ inline void Object::setArrayLengthUnchecked(uint l) memberData()->data[Heap::ArrayObject::LengthPropertyIndex] = Primitive::fromUInt32(l); } -inline void Object::push_back(const ValueRef v) +inline void Object::push_back(const Value &v) { arrayCreate(); @@ -382,14 +382,14 @@ inline void Object::arraySet(uint index, const Property *p, PropertyAttributes a } -inline void Object::arraySet(uint index, ValueRef value) +inline void Object::arraySet(uint index, const Value &value) { arrayCreate(); if (index > 0x1000 && index > 2*d()->arrayData->alloc) { initSparseArray(); } Property *pd = ArrayData::insert(this, index); - pd->value = value ? *value : Primitive::undefinedValue(); + pd->value = value; if (isArrayObject() && index >= getLength()) setArrayLengthUnchecked(index + 1); } diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index b1bc6ab5c0..b3302d214d 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -135,7 +135,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptor(CallContext *ctx) return ctx->engine()->throwTypeError(); if (ArgumentsObject::isNonStrictArgumentsObject(O)) - Scoped<ArgumentsObject>(scope, O)->fullyCreate(); + static_cast<ArgumentsObject *>(O.getPointer())->fullyCreate(); ScopedValue v(scope, ctx->argument(1)); ScopedString name(scope, v->toString(scope.engine)); @@ -266,7 +266,7 @@ ReturnedValue ObjectPrototype::method_freeze(CallContext *ctx) return ctx->engine()->throwTypeError(); if (ArgumentsObject::isNonStrictArgumentsObject(o)) - Scoped<ArgumentsObject>(scope, o)->fullyCreate(); + static_cast<ArgumentsObject *>(o.getPointer())->fullyCreate(); o->setInternalClass(o->internalClass()->frozen()); @@ -560,7 +560,7 @@ ReturnedValue ObjectPrototype::method_set_proto(CallContext *ctx) return Encode::undefined(); } -void ObjectPrototype::toPropertyDescriptor(ExecutionEngine *engine, const ValueRef v, Property *desc, PropertyAttributes *attrs) +void ObjectPrototype::toPropertyDescriptor(ExecutionEngine *engine, const Value &v, Property *desc, PropertyAttributes *attrs) { Scope scope(engine); ScopedObject o(scope, v); @@ -666,7 +666,7 @@ ReturnedValue ObjectPrototype::fromPropertyDescriptor(ExecutionEngine *engine, c } -Heap::ArrayObject *ObjectPrototype::getOwnPropertyNames(ExecutionEngine *v4, const ValueRef o) +Heap::ArrayObject *ObjectPrototype::getOwnPropertyNames(ExecutionEngine *v4, const Value &o) { Scope scope(v4); ScopedArrayObject array(scope, v4->newArrayObject()); diff --git a/src/qml/jsruntime/qv4objectproto_p.h b/src/qml/jsruntime/qv4objectproto_p.h index 4bbcb297be..65893a3ccf 100644 --- a/src/qml/jsruntime/qv4objectproto_p.h +++ b/src/qml/jsruntime/qv4objectproto_p.h @@ -88,10 +88,10 @@ struct ObjectPrototype: Object static ReturnedValue method_get_proto(CallContext *ctx); static ReturnedValue method_set_proto(CallContext *ctx); - static void toPropertyDescriptor(ExecutionEngine *engine, const ValueRef v, Property *desc, PropertyAttributes *attrs); + static void toPropertyDescriptor(ExecutionEngine *engine, const Value &v, Property *desc, PropertyAttributes *attrs); static ReturnedValue fromPropertyDescriptor(ExecutionEngine *engine, const Property *desc, PropertyAttributes attrs); - static Heap::ArrayObject *getOwnPropertyNames(ExecutionEngine *v4, const ValueRef o); + static Heap::ArrayObject *getOwnPropertyNames(ExecutionEngine *v4, const Value &o); }; diff --git a/src/qml/jsruntime/qv4persistent.cpp b/src/qml/jsruntime/qv4persistent.cpp index 1b191f3384..0b3c7a4da0 100644 --- a/src/qml/jsruntime/qv4persistent.cpp +++ b/src/qml/jsruntime/qv4persistent.cpp @@ -216,7 +216,7 @@ PersistentValue::PersistentValue(const PersistentValue &other) } } -PersistentValue::PersistentValue(ExecutionEngine *engine, const ValueRef value) +PersistentValue::PersistentValue(ExecutionEngine *engine, const Value &value) { val = engine->memoryManager->m_persistentValues->allocate(); *val = value; @@ -228,6 +228,16 @@ PersistentValue::PersistentValue(ExecutionEngine *engine, ReturnedValue value) *val = value; } +PersistentValue::PersistentValue(ExecutionEngine *engine, Object *object) + : val(0) +{ + if (!object) + return; + + val = engine->memoryManager->m_persistentValues->allocate(); + *val = object; +} + PersistentValue::~PersistentValue() { PersistentValueStorage::free(val); @@ -274,7 +284,7 @@ PersistentValue &PersistentValue::operator=(Object *object) return *this; } -void PersistentValue::set(ExecutionEngine *engine, const ValueRef value) +void PersistentValue::set(ExecutionEngine *engine, const Value &value) { if (!val) val = engine->memoryManager->m_persistentValues->allocate(); @@ -323,7 +333,7 @@ WeakValue::~WeakValue() PersistentValueStorage::free(val); } -void WeakValue::set(ExecutionEngine *engine, const ValueRef value) +void WeakValue::set(ExecutionEngine *engine, const Value &value) { if (!val) val = engine->memoryManager->m_weakValues->allocate(); diff --git a/src/qml/jsruntime/qv4persistent_p.h b/src/qml/jsruntime/qv4persistent_p.h index b71f943f80..02d4007f62 100644 --- a/src/qml/jsruntime/qv4persistent_p.h +++ b/src/qml/jsruntime/qv4persistent_p.h @@ -79,10 +79,11 @@ public: PersistentValue &operator=(Object *object); ~PersistentValue(); - PersistentValue(ExecutionEngine *engine, const ValueRef value); + PersistentValue(ExecutionEngine *engine, const Value &value); PersistentValue(ExecutionEngine *engine, ReturnedValue value); + PersistentValue(ExecutionEngine *engine, Object *object); - void set(ExecutionEngine *engine, const ValueRef value); + void set(ExecutionEngine *engine, const Value &value); void set(ExecutionEngine *engine, ReturnedValue value); void set(ExecutionEngine *engine, Heap::Base *obj); @@ -126,7 +127,7 @@ public: WeakValue &operator=(const WeakValue &other); ~WeakValue(); - void set(ExecutionEngine *engine, const ValueRef value); + void set(ExecutionEngine *engine, const Value &value); void set(ExecutionEngine *engine, ReturnedValue value); void set(ExecutionEngine *engine, Heap::Base *obj); diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 9fb7ad96fa..6190dd0bad 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -94,10 +94,10 @@ static QPair<QObject *, int> extractQtMethod(QV4::FunctionObject *function) return qMakePair((QObject *)0, -1); } -static QPair<QObject *, int> extractQtSignal(const ValueRef value) +static QPair<QObject *, int> extractQtSignal(const Value &value) { - if (value->isObject()) { - QV4::ExecutionEngine *v4 = value->asObject()->engine(); + if (value.isObject()) { + QV4::ExecutionEngine *v4 = value.asObject()->engine(); QV4::Scope scope(v4); QV4::ScopedFunctionObject function(scope, value); if (function) @@ -418,7 +418,7 @@ ReturnedValue QObjectWrapper::getQmlProperty(QV4::ExecutionEngine *engine, QQmlC } bool QObjectWrapper::setQmlProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, QObject *object, String *name, - QObjectWrapper::RevisionMode revisionMode, const ValueRef value) + QObjectWrapper::RevisionMode revisionMode, const Value &value) { if (QQmlData::wasDeleted(object)) return false; @@ -444,7 +444,7 @@ bool QObjectWrapper::setQmlProperty(ExecutionEngine *engine, QQmlContextData *qm return true; } -void QObjectWrapper::setProperty(QObject *object, ExecutionContext *ctx, QQmlPropertyData *property, const ValueRef value) +void QObjectWrapper::setProperty(QObject *object, ExecutionContext *ctx, QQmlPropertyData *property, const Value &value) { if (!property->isWritable() && !property->isQList()) { QString error = QLatin1String("Cannot assign to read-only property \"") + @@ -472,7 +472,7 @@ void QObjectWrapper::setProperty(QObject *object, ExecutionContext *ctx, QQmlPro // binding assignment. QQmlContextData *callingQmlContext = QV4::QmlContextWrapper::callingContext(ctx->d()->engine); - QV4::Scoped<QQmlBindingFunction> bindingFunction(scope, f); + QV4::Scoped<QQmlBindingFunction> bindingFunction(scope, (const Value &)f); bindingFunction->initBindingLocation(); newBinding = new QQmlBinding(value, object, callingQmlContext); @@ -500,18 +500,18 @@ void QObjectWrapper::setProperty(QObject *object, ExecutionContext *ctx, QQmlPro void *argv[] = { &o, 0, &status, &flags }; \ QMetaObject::metacall(object, QMetaObject::WriteProperty, property->coreIndex, argv); - if (value->isNull() && property->isQObject()) { + if (value.isNull() && property->isQObject()) { PROPERTY_STORE(QObject*, 0); - } else if (value->isUndefined() && property->isResettable()) { + } else if (value.isUndefined() && property->isResettable()) { void *a[] = { 0 }; QMetaObject::metacall(object, QMetaObject::ResetProperty, property->coreIndex, a); - } else if (value->isUndefined() && property->propType == qMetaTypeId<QVariant>()) { + } else if (value.isUndefined() && property->propType == qMetaTypeId<QVariant>()) { PROPERTY_STORE(QVariant, QVariant()); - } else if (value->isUndefined() && property->propType == QMetaType::QJsonValue) { + } else if (value.isUndefined() && property->propType == QMetaType::QJsonValue) { PROPERTY_STORE(QJsonValue, QJsonValue(QJsonValue::Undefined)); } else if (!newBinding && property->propType == qMetaTypeId<QJSValue>()) { PROPERTY_STORE(QJSValue, QJSValue(ctx->d()->engine, value.asReturnedValue())); - } else if (value->isUndefined() && property->propType != qMetaTypeId<QQmlScriptString>()) { + } else if (value.isUndefined() && property->propType != qMetaTypeId<QQmlScriptString>()) { QString error = QLatin1String("Cannot assign [undefined] to "); if (!QMetaType::typeName(property->propType)) error += QLatin1String("[unknown property type]"); @@ -519,28 +519,28 @@ void QObjectWrapper::setProperty(QObject *object, ExecutionContext *ctx, QQmlPro error += QLatin1String(QMetaType::typeName(property->propType)); ctx->engine()->throwError(error); return; - } else if (value->asFunctionObject()) { + } else if (value.asFunctionObject()) { // this is handled by the binding creation above - } else if (property->propType == QMetaType::Int && value->isNumber()) { - PROPERTY_STORE(int, value->asDouble()); - } else if (property->propType == QMetaType::QReal && value->isNumber()) { - PROPERTY_STORE(qreal, qreal(value->asDouble())); - } else if (property->propType == QMetaType::Float && value->isNumber()) { - PROPERTY_STORE(float, float(value->asDouble())); - } else if (property->propType == QMetaType::Double && value->isNumber()) { - PROPERTY_STORE(double, double(value->asDouble())); - } else if (property->propType == QMetaType::QString && value->isString()) { - PROPERTY_STORE(QString, value->toQStringNoThrow()); + } else if (property->propType == QMetaType::Int && value.isNumber()) { + PROPERTY_STORE(int, value.asDouble()); + } else if (property->propType == QMetaType::QReal && value.isNumber()) { + PROPERTY_STORE(qreal, qreal(value.asDouble())); + } else if (property->propType == QMetaType::Float && value.isNumber()) { + PROPERTY_STORE(float, float(value.asDouble())); + } else if (property->propType == QMetaType::Double && value.isNumber()) { + PROPERTY_STORE(double, double(value.asDouble())); + } else if (property->propType == QMetaType::QString && value.isString()) { + PROPERTY_STORE(QString, value.toQStringNoThrow()); } else if (property->isVarProperty()) { QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object); Q_ASSERT(vmemo); vmemo->setVMEProperty(property->coreIndex, value); - } else if (property->propType == qMetaTypeId<QQmlScriptString>() && (value->isUndefined() || value->isPrimitive())) { - QQmlScriptString ss(value->toQStringNoThrow(), 0 /* context */, object); - if (value->isNumber()) { - ss.d->numberValue = value->toNumber(); + } else if (property->propType == qMetaTypeId<QQmlScriptString>() && (value.isUndefined() || value.isPrimitive())) { + QQmlScriptString ss(value.toQStringNoThrow(), 0 /* context */, object); + if (value.isNumber()) { + ss.d->numberValue = value.toNumber(); ss.d->isNumberLiteral = true; - } else if (value->isString()) { + } else if (value.isString()) { ss.d->script = QV4::CompiledData::Binding::escapedString(ss.d->script); ss.d->isStringLiteral = true; } @@ -639,7 +639,7 @@ ReturnedValue QObjectWrapper::getProperty(QObject *object, ExecutionContext *ctx return getProperty(object, ctx, property, captureRequired); } -void QObjectWrapper::setProperty(ExecutionContext *ctx, int propertyIndex, const ValueRef value) +void QObjectWrapper::setProperty(ExecutionContext *ctx, int propertyIndex, const Value &value) { if (QQmlData::wasDeleted(d()->object)) return; @@ -681,7 +681,7 @@ QV4::ReturnedValue QObjectWrapper::get(Managed *m, String *name, bool *hasProper return that->getQmlProperty(qmlContext, name, IgnoreRevision, hasProperty, /*includeImports*/ true); } -void QObjectWrapper::put(Managed *m, String *name, const ValueRef value) +void QObjectWrapper::put(Managed *m, String *name, const Value &value) { QObjectWrapper *that = static_cast<QObjectWrapper*>(m); ExecutionEngine *v4 = that->engine(); @@ -853,7 +853,7 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase if (slotIndexToDisconnect != -1) { // This is a QObject function wrapper if (connection->thisObject.isUndefined() == thisObject->isUndefined() && - (connection->thisObject.isUndefined() || RuntimeHelpers::strictEqual(connection->thisObject, thisObject))) { + (connection->thisObject.isUndefined() || RuntimeHelpers::strictEqual(*connection->thisObject.valueRef(), thisObject))) { QV4::ScopedFunctionObject f(scope, connection->function.value()); QPair<QObject *, int> connectedFunctionData = extractQtMethod(f); @@ -865,9 +865,9 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase } } else { // This is a normal JS function - if (RuntimeHelpers::strictEqual(connection->function, function) && + if (RuntimeHelpers::strictEqual(*connection->function.valueRef(), function) && connection->thisObject.isUndefined() == thisObject->isUndefined() && - (connection->thisObject.isUndefined() || RuntimeHelpers::strictEqual(connection->thisObject, thisObject))) { + (connection->thisObject.isUndefined() || RuntimeHelpers::strictEqual(*connection->thisObject.valueRef(), thisObject))) { *ret = true; return; } @@ -1089,7 +1089,7 @@ struct CallArgument { inline void *dataPtr(); inline void initAsType(int type); - inline void fromValue(int type, ExecutionEngine *, const ValueRef); + inline void fromValue(int type, ExecutionEngine *, const Value &); inline ReturnedValue toValue(ExecutionEngine *); private: @@ -1174,9 +1174,9 @@ static QV4::ReturnedValue CallMethod(const QQmlObjectOrGadget &object, int index The conversion table is copied out of the \l QScript::callQtMethod() function. */ -static int MatchScore(const QV4::ValueRef actual, int conversionType) +static int MatchScore(const QV4::Value &actual, int conversionType) { - if (actual->isNumber()) { + if (actual.isNumber()) { switch (conversionType) { case QMetaType::Double: return 0; @@ -1203,7 +1203,7 @@ static int MatchScore(const QV4::ValueRef actual, int conversionType) default: return 10; } - } else if (actual->isString()) { + } else if (actual.isString()) { switch (conversionType) { case QMetaType::QString: return 0; @@ -1212,7 +1212,7 @@ static int MatchScore(const QV4::ValueRef actual, int conversionType) default: return 10; } - } else if (actual->isBoolean()) { + } else if (actual.isBoolean()) { switch (conversionType) { case QMetaType::Bool: return 0; @@ -1221,7 +1221,7 @@ static int MatchScore(const QV4::ValueRef actual, int conversionType) default: return 10; } - } else if (actual->asDateObject()) { + } else if (actual.asDateObject()) { switch (conversionType) { case QMetaType::QDateTime: return 0; @@ -1232,14 +1232,14 @@ static int MatchScore(const QV4::ValueRef actual, int conversionType) default: return 10; } - } else if (actual->as<QV4::RegExpObject>()) { + } else if (actual.as<QV4::RegExpObject>()) { switch (conversionType) { case QMetaType::QRegExp: return 0; default: return 10; } - } else if (actual->asArrayObject()) { + } else if (actual.asArrayObject()) { switch (conversionType) { case QMetaType::QJsonArray: return 3; @@ -1254,7 +1254,7 @@ static int MatchScore(const QV4::ValueRef actual, int conversionType) default: return 10; } - } else if (actual->isNull()) { + } else if (actual.isNull()) { switch (conversionType) { case QMetaType::VoidStar: case QMetaType::QObjectStar: @@ -1268,7 +1268,7 @@ static int MatchScore(const QV4::ValueRef actual, int conversionType) return 10; } } - } else if (QV4::Object *obj = actual->asObject()) { + } else if (QV4::Object *obj = actual.asObject()) { if (obj->as<QV4::VariantObject>()) { if (conversionType == qMetaTypeId<QVariant>()) return 0; @@ -1562,7 +1562,7 @@ void CallArgument::initAsType(int callType) } } -void CallArgument::fromValue(int callType, QV4::ExecutionEngine *engine, const QV4::ValueRef value) +void CallArgument::fromValue(int callType, QV4::ExecutionEngine *engine, const QV4::Value &value) { if (type != 0) { cleanup(); @@ -1576,31 +1576,31 @@ void CallArgument::fromValue(int callType, QV4::ExecutionEngine *engine, const Q qjsValuePtr = new (&allocData) QJSValue(scope.engine, value.asReturnedValue()); type = qMetaTypeId<QJSValue>(); } else if (callType == QMetaType::Int) { - intValue = quint32(value->toInt32()); + intValue = quint32(value.toInt32()); type = callType; } else if (callType == QMetaType::UInt) { - intValue = quint32(value->toUInt32()); + intValue = quint32(value.toUInt32()); type = callType; } else if (callType == QMetaType::Bool) { - boolValue = value->toBoolean(); + boolValue = value.toBoolean(); type = callType; } else if (callType == QMetaType::Double) { - doubleValue = double(value->toNumber()); + doubleValue = double(value.toNumber()); type = callType; } else if (callType == QMetaType::Float) { - floatValue = float(value->toNumber()); + floatValue = float(value.toNumber()); type = callType; } else if (callType == QMetaType::QString) { - if (value->isNull() || value->isUndefined()) + if (value.isNull() || value.isUndefined()) qstringPtr = new (&allocData) QString(); else - qstringPtr = new (&allocData) QString(value->toQStringNoThrow()); + qstringPtr = new (&allocData) QString(value.toQStringNoThrow()); type = callType; } else if (callType == QMetaType::QObjectStar) { qobjectPtr = 0; - if (QV4::QObjectWrapper *qobjectWrapper = value->as<QV4::QObjectWrapper>()) + if (QV4::QObjectWrapper *qobjectWrapper = value.as<QV4::QObjectWrapper>()) qobjectPtr = qobjectWrapper->object(); - else if (QV4::QmlTypeWrapper *qmlTypeWrapper = value->as<QV4::QmlTypeWrapper>()) + else if (QV4::QmlTypeWrapper *qmlTypeWrapper = value.as<QV4::QmlTypeWrapper>()) queryEngine = qmlTypeWrapper->isSingleton(); type = callType; } else if (callType == qMetaTypeId<QVariant>()) { @@ -1622,13 +1622,13 @@ void CallArgument::fromValue(int callType, QV4::ExecutionEngine *engine, const Q } } else { QObject *o = 0; - if (QV4::QObjectWrapper *qobjectWrapper = value->as<QV4::QObjectWrapper>()) + if (QV4::QObjectWrapper *qobjectWrapper = value.as<QV4::QObjectWrapper>()) o = qobjectWrapper->object(); qlistPtr->append(o); } type = callType; } else if (callType == qMetaTypeId<QQmlV4Handle>()) { - handlePtr = new (&allocData) QQmlV4Handle(value->asReturnedValue()); + handlePtr = new (&allocData) QQmlV4Handle(value.asReturnedValue()); type = callType; } else if (callType == QMetaType::QJsonArray) { QV4::ScopedArrayObject a(scope, value); @@ -1731,7 +1731,7 @@ QV4::ReturnedValue CallArgument::toValue(QV4::ExecutionEngine *engine) } } -ReturnedValue QObjectMethod::create(ExecutionContext *scope, QObject *object, int index, const ValueRef qmlGlobal) +ReturnedValue QObjectMethod::create(ExecutionContext *scope, QObject *object, int index, const Value &qmlGlobal) { Scope valueScope(scope); Scoped<QObjectMethod> method(valueScope, scope->d()->engine->memoryManager->alloc<QObjectMethod>(scope)); @@ -1746,7 +1746,7 @@ ReturnedValue QObjectMethod::create(ExecutionContext *scope, QObject *object, in return method.asReturnedValue(); } -ReturnedValue QObjectMethod::create(ExecutionContext *scope, QQmlValueTypeWrapper *valueType, int index, const ValueRef qmlGlobal) +ReturnedValue QObjectMethod::create(ExecutionContext *scope, QQmlValueTypeWrapper *valueType, int index, const Value &qmlGlobal) { Scope valueScope(scope); Scoped<QObjectMethod> method(valueScope, scope->d()->engine->memoryManager->alloc<QObjectMethod>(scope)); @@ -1795,7 +1795,7 @@ QV4::ReturnedValue QObjectMethod::method_toString(QV4::ExecutionContext *ctx) return ctx->d()->engine->newString(result)->asReturnedValue(); } -QV4::ReturnedValue QObjectMethod::method_destroy(QV4::ExecutionContext *ctx, const ValueRef args, int argc) +QV4::ReturnedValue QObjectMethod::method_destroy(QV4::ExecutionContext *ctx, const Value *args, int argc) { if (!d()->object) return Encode::undefined(); diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index f0dd440ce3..742391a72b 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -107,28 +107,28 @@ struct Q_QML_EXPORT QObjectWrapper : public Object ReturnedValue getQmlProperty(QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, bool *hasProperty = 0, bool includeImports = false); static ReturnedValue getQmlProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, QObject *object, String *name, RevisionMode revisionMode, bool *hasProperty = 0); - static bool setQmlProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, QObject *object, String *name, RevisionMode revisionMode, const ValueRef value); + static bool setQmlProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, QObject *object, String *name, RevisionMode revisionMode, const Value &value); static ReturnedValue wrap(ExecutionEngine *engine, QObject *object); using Object::get; static ReturnedValue getProperty(QObject *object, ExecutionContext *ctx, int propertyIndex, bool captureRequired); - void setProperty(ExecutionContext *ctx, int propertyIndex, const ValueRef value); + void setProperty(ExecutionContext *ctx, int propertyIndex, const Value &value); protected: static bool isEqualTo(Managed *that, Managed *o); private: static ReturnedValue getProperty(QObject *object, ExecutionContext *ctx, QQmlPropertyData *property, bool captureRequired = true); - static void setProperty(QObject *object, ExecutionContext *ctx, QQmlPropertyData *property, const ValueRef value); + static void setProperty(QObject *object, ExecutionContext *ctx, QQmlPropertyData *property, const Value &value); static ReturnedValue create(ExecutionEngine *engine, QObject *object); QQmlPropertyData *findProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local) const; static ReturnedValue get(Managed *m, String *name, bool *hasProperty); - static void put(Managed *m, String *name, const ValueRef value); + static void put(Managed *m, String *name, const Value &value); static PropertyAttributes query(const Managed *, String *name); static void advanceIterator(Managed *m, ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attributes); static void markObjects(Heap::Base *that, QV4::ExecutionEngine *e); @@ -147,14 +147,14 @@ struct Q_QML_EXPORT QObjectMethod : public QV4::FunctionObject enum { DestroyMethod = -1, ToStringMethod = -2 }; - static ReturnedValue create(QV4::ExecutionContext *scope, QObject *object, int index, const ValueRef qmlGlobal = Primitive::undefinedValue()); - static ReturnedValue create(QV4::ExecutionContext *scope, QQmlValueTypeWrapper *valueType, int index, const ValueRef qmlGlobal = Primitive::undefinedValue()); + static ReturnedValue create(QV4::ExecutionContext *scope, QObject *object, int index, const Value &qmlGlobal = Primitive::undefinedValue()); + static ReturnedValue create(QV4::ExecutionContext *scope, QQmlValueTypeWrapper *valueType, int index, const Value &qmlGlobal = Primitive::undefinedValue()); int methodIndex() const { return d()->index; } QObject *object() const { return d()->object.data(); } QV4::ReturnedValue method_toString(QV4::ExecutionContext *ctx); - QV4::ReturnedValue method_destroy(QV4::ExecutionContext *ctx, const ValueRef args, int argc); + QV4::ReturnedValue method_destroy(QV4::ExecutionContext *ctx, const Value *args, int argc); static ReturnedValue call(Managed *, CallData *callData); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 61a277b9b5..fdff79538c 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -272,32 +272,32 @@ ReturnedValue Runtime::closure(ExecutionEngine *engine, int functionId) return FunctionObject::createScriptFunction(ScopedContext(scope, engine->currentContext()), clos)->asReturnedValue(); } -ReturnedValue Runtime::deleteElement(ExecutionEngine *engine, const ValueRef base, const ValueRef index) +ReturnedValue Runtime::deleteElement(ExecutionEngine *engine, const Value &base, const Value &index) { Scope scope(engine); ScopedObject o(scope, base); if (o) { - uint n = index->asArrayIndex(); + uint n = index.asArrayIndex(); if (n < UINT_MAX) { return Encode((bool)o->deleteIndexedProperty(n)); } } - ScopedString name(scope, index->toString(engine)); + ScopedString name(scope, index.toString(engine)); return Runtime::deleteMemberString(engine, base, name); } -ReturnedValue Runtime::deleteMember(ExecutionEngine *engine, const ValueRef base, int nameIndex) +ReturnedValue Runtime::deleteMember(ExecutionEngine *engine, const Value &base, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); return deleteMemberString(engine, base, name); } -ReturnedValue Runtime::deleteMemberString(ExecutionEngine *engine, const ValueRef base, String *name) +ReturnedValue Runtime::deleteMemberString(ExecutionEngine *engine, const Value &base, String *name) { Scope scope(engine); - ScopedObject obj(scope, base->toObject(engine)); + ScopedObject obj(scope, base.toObject(engine)); if (scope.engine->hasException) return Encode::undefined(); return Encode(obj->deleteProperty(name)); @@ -311,17 +311,17 @@ ReturnedValue Runtime::deleteName(ExecutionEngine *engine, int nameIndex) return Encode(ctx->deleteProperty(name)); } -QV4::ReturnedValue Runtime::instanceof(ExecutionEngine *engine, const ValueRef left, const ValueRef right) +QV4::ReturnedValue Runtime::instanceof(ExecutionEngine *engine, const Value &left, const Value &right) { Scope scope(engine); - ScopedFunctionObject f(scope, right->asFunctionObject()); + ScopedFunctionObject f(scope, right.asFunctionObject()); if (!f) return engine->throwTypeError(); if (f->isBoundFunction()) f = static_cast<BoundFunction *>(f.getPointer())->target(); - ScopedObject v(scope, left->asObject()); + ScopedObject v(scope, left.asObject()); if (!v) return Encode(false); @@ -341,15 +341,15 @@ QV4::ReturnedValue Runtime::instanceof(ExecutionEngine *engine, const ValueRef l return Encode(false); } -QV4::ReturnedValue Runtime::in(ExecutionEngine *engine, const ValueRef left, const ValueRef right) +QV4::ReturnedValue Runtime::in(ExecutionEngine *engine, const Value &left, const Value &right) { - if (!right->isObject()) + if (!right.isObject()) return engine->throwTypeError(); Scope scope(engine); - ScopedString s(scope, left->toString(engine)); + ScopedString s(scope, left.toString(engine)); if (scope.hasException()) return Encode::undefined(); - bool r = right->objectValue()->hasProperty(s); + bool r = right.objectValue()->hasProperty(s); return Encode(r); } @@ -426,10 +426,10 @@ ReturnedValue RuntimeHelpers::objectDefaultValue(Object *object, int typeHint) -Heap::Object *RuntimeHelpers::convertToObject(ExecutionEngine *engine, const ValueRef value) +Heap::Object *RuntimeHelpers::convertToObject(ExecutionEngine *engine, const Value &value) { - Q_ASSERT(!value->isObject()); - switch (value->type()) { + Q_ASSERT(!value.isObject()); + switch (value.type()) { case Value::Undefined_Type: case Value::Null_Type: engine->throwTypeError(); @@ -437,7 +437,7 @@ Heap::Object *RuntimeHelpers::convertToObject(ExecutionEngine *engine, const Val case Value::Boolean_Type: return engine->newBooleanObject(value); case Value::Managed_Type: - Q_ASSERT(value->isString()); + Q_ASSERT(value.isString()); return engine->newStringObject(value); case Value::Integer_Type: default: // double @@ -445,9 +445,9 @@ Heap::Object *RuntimeHelpers::convertToObject(ExecutionEngine *engine, const Val } } -Heap::String *RuntimeHelpers::convertToString(ExecutionEngine *engine, const ValueRef value) +Heap::String *RuntimeHelpers::convertToString(ExecutionEngine *engine, const Value &value) { - switch (value->type()) { + switch (value.type()) { case Value::Empty_Type: Q_ASSERT(!"empty Value encountered"); case Value::Undefined_Type: @@ -455,30 +455,30 @@ Heap::String *RuntimeHelpers::convertToString(ExecutionEngine *engine, const Val case Value::Null_Type: return engine->id_null->d(); case Value::Boolean_Type: - if (value->booleanValue()) + if (value.booleanValue()) return engine->id_true->d(); else return engine->id_false->d(); case Value::Managed_Type: - if (value->isString()) - return value->stringValue()->d(); + if (value.isString()) + return value.stringValue()->d(); { Scope scope(engine); ScopedValue prim(scope, RuntimeHelpers::toPrimitive(value, STRING_HINT)); return RuntimeHelpers::convertToString(engine, prim); } case Value::Integer_Type: - return RuntimeHelpers::stringFromNumber(engine, value->int_32); + return RuntimeHelpers::stringFromNumber(engine, value.int_32); default: // double - return RuntimeHelpers::stringFromNumber(engine, value->doubleValue()); + return RuntimeHelpers::stringFromNumber(engine, value.doubleValue()); } // switch } // This is slightly different from the method above, as // the + operator requires a slightly different conversion -static Heap::String *convert_to_string_add(ExecutionEngine *engine, const ValueRef value) +static Heap::String *convert_to_string_add(ExecutionEngine *engine, const Value &value) { - switch (value->type()) { + switch (value.type()) { case Value::Empty_Type: Q_ASSERT(!"empty Value encountered"); case Value::Undefined_Type: @@ -486,26 +486,26 @@ static Heap::String *convert_to_string_add(ExecutionEngine *engine, const ValueR case Value::Null_Type: return engine->id_null->d(); case Value::Boolean_Type: - if (value->booleanValue()) + if (value.booleanValue()) return engine->id_true->d(); else return engine->id_false->d(); case Value::Managed_Type: - if (value->isString()) - return value->stringValue()->d(); + if (value.isString()) + return value.stringValue()->d(); { Scope scope(engine); ScopedValue prim(scope, RuntimeHelpers::toPrimitive(value, PREFERREDTYPE_HINT)); return RuntimeHelpers::convertToString(engine, prim); } case Value::Integer_Type: - return RuntimeHelpers::stringFromNumber(engine, value->int_32); + return RuntimeHelpers::stringFromNumber(engine, value.int_32); default: // double - return RuntimeHelpers::stringFromNumber(engine, value->doubleValue()); + return RuntimeHelpers::stringFromNumber(engine, value.doubleValue()); } // switch } -QV4::ReturnedValue RuntimeHelpers::addHelper(ExecutionEngine *engine, const ValueRef left, const ValueRef right) +QV4::ReturnedValue RuntimeHelpers::addHelper(ExecutionEngine *engine, const Value &left, const Value &right) { Scope scope(engine); @@ -529,21 +529,21 @@ QV4::ReturnedValue RuntimeHelpers::addHelper(ExecutionEngine *engine, const Valu return Encode(x + y); } -QV4::ReturnedValue Runtime::addString(ExecutionEngine *engine, const QV4::ValueRef left, const QV4::ValueRef right) +QV4::ReturnedValue Runtime::addString(ExecutionEngine *engine, const Value &left, const Value &right) { - Q_ASSERT(left->isString() || right->isString()); + Q_ASSERT(left.isString() || right.isString()); - if (left->isString() && right->isString()) { - if (!left->stringValue()->d()->length()) - return right->asReturnedValue(); - if (!right->stringValue()->d()->length()) - return left->asReturnedValue(); - return (engine->memoryManager->alloc<String>(left->stringValue()->d(), right->stringValue()->d()))->asReturnedValue(); + if (left.isString() && right.isString()) { + if (!left.stringValue()->d()->length()) + return right.asReturnedValue(); + if (!right.stringValue()->d()->length()) + return left.asReturnedValue(); + return (engine->memoryManager->alloc<String>(left.stringValue()->d(), right.stringValue()->d()))->asReturnedValue(); } Scope scope(engine); - ScopedValue pleft(scope, *left); - ScopedValue pright(scope, *right); + ScopedValue pleft(scope, left); + ScopedValue pright(scope, right); if (!pleft->isString()) pleft = convert_to_string_add(engine, left); @@ -558,25 +558,25 @@ QV4::ReturnedValue Runtime::addString(ExecutionEngine *engine, const QV4::ValueR return (engine->memoryManager->alloc<String>(pleft->stringValue()->d(), pright->stringValue()->d()))->asReturnedValue(); } -void Runtime::setProperty(ExecutionEngine *engine, const ValueRef object, int nameIndex, const ValueRef value) +void Runtime::setProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value) { Scope scope(engine); ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); - ScopedObject o(scope, object->toObject(engine)); + ScopedObject o(scope, object.toObject(engine)); if (!o) return; o->put(name, value); } -ReturnedValue Runtime::getElement(ExecutionEngine *engine, const ValueRef object, const ValueRef index) +ReturnedValue Runtime::getElement(ExecutionEngine *engine, const Value &object, const Value &index) { Scope scope(engine); - uint idx = index->asArrayIndex(); + uint idx = index.asArrayIndex(); ScopedObject o(scope, object); if (!o) { if (idx < UINT_MAX) { - if (String *str = object->asString()) { + if (String *str = object.asString()) { if (idx >= (uint)str->toQString().length()) { return Encode::undefined(); } @@ -585,8 +585,8 @@ ReturnedValue Runtime::getElement(ExecutionEngine *engine, const ValueRef object } } - if (object->isNullOrUndefined()) { - QString message = QStringLiteral("Cannot read property '%1' of %2").arg(index->toQStringNoThrow()).arg(object->toQStringNoThrow()); + if (object.isNullOrUndefined()) { + QString message = QStringLiteral("Cannot read property '%1' of %2").arg(index.toQStringNoThrow()).arg(object.toQStringNoThrow()); return engine->throwTypeError(message); } @@ -605,20 +605,20 @@ ReturnedValue Runtime::getElement(ExecutionEngine *engine, const ValueRef object return o->getIndexed(idx); } - ScopedString name(scope, index->toString(engine)); + ScopedString name(scope, index.toString(engine)); if (scope.hasException()) return Encode::undefined(); return o->get(name); } -void Runtime::setElement(ExecutionEngine *engine, const ValueRef object, const ValueRef index, const ValueRef value) +void Runtime::setElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value) { Scope scope(engine); - ScopedObject o(scope, object->toObject(engine)); + ScopedObject o(scope, object.toObject(engine)); if (scope.engine->hasException) return; - uint idx = index->asArrayIndex(); + uint idx = index.asArrayIndex(); if (idx < UINT_MAX) { if (o->arrayType() == Heap::ArrayData::Simple) { Heap::SimpleArrayData *s = static_cast<Heap::SimpleArrayData *>(o->arrayData()); @@ -631,31 +631,31 @@ void Runtime::setElement(ExecutionEngine *engine, const ValueRef object, const V return; } - ScopedString name(scope, index->toString(engine)); + ScopedString name(scope, index.toString(engine)); o->put(name, value); } -ReturnedValue Runtime::foreachIterator(ExecutionEngine *engine, const ValueRef in) +ReturnedValue Runtime::foreachIterator(ExecutionEngine *engine, const Value &in) { Scope scope(engine); ScopedObject o(scope, (Object *)0); - if (!in->isNullOrUndefined()) - o = in->toObject(engine); + if (!in.isNullOrUndefined()) + o = in.toObject(engine); return engine->newForEachIteratorObject(o)->asReturnedValue(); } -ReturnedValue Runtime::foreachNextPropertyName(const ValueRef foreach_iterator) +ReturnedValue Runtime::foreachNextPropertyName(const Value &foreach_iterator) { - Q_ASSERT(foreach_iterator->isObject()); + Q_ASSERT(foreach_iterator.isObject()); - ForEachIteratorObject *it = static_cast<ForEachIteratorObject *>(foreach_iterator->objectValue()); + ForEachIteratorObject *it = static_cast<ForEachIteratorObject *>(foreach_iterator.objectValue()); Q_ASSERT(it->as<ForEachIteratorObject>()); return it->nextPropertyName(); } -void Runtime::setActivationProperty(ExecutionEngine *engine, int nameIndex, const ValueRef value) +void Runtime::setActivationProperty(ExecutionEngine *engine, int nameIndex, const Value &value) { Scope scope(engine); ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); @@ -663,7 +663,7 @@ void Runtime::setActivationProperty(ExecutionEngine *engine, int nameIndex, cons ctx->setProperty(name, value); } -ReturnedValue Runtime::getProperty(ExecutionEngine *engine, const ValueRef object, int nameIndex) +ReturnedValue Runtime::getProperty(ExecutionEngine *engine, const Value &object, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); @@ -672,8 +672,8 @@ ReturnedValue Runtime::getProperty(ExecutionEngine *engine, const ValueRef objec if (o) return o->get(name); - if (object->isNullOrUndefined()) { - QString message = QStringLiteral("Cannot read property '%1' of %2").arg(name->toQString()).arg(object->toQStringNoThrow()); + if (object.isNullOrUndefined()) { + QString message = QStringLiteral("Cannot read property '%1' of %2").arg(name->toQString()).arg(object.toQStringNoThrow()); return engine->throwTypeError(message); } @@ -693,36 +693,36 @@ ReturnedValue Runtime::getActivationProperty(ExecutionEngine *engine, int nameIn #endif // V4_BOOTSTRAP -uint RuntimeHelpers::equalHelper(const ValueRef x, const ValueRef y) +uint RuntimeHelpers::equalHelper(const Value &x, const Value &y) { - Q_ASSERT(x->type() != y->type() || (x->isManaged() && (x->isString() != y->isString()))); + Q_ASSERT(x.type() != y.type() || (x.isManaged() && (x.isString() != y.isString()))); - if (x->isNumber() && y->isNumber()) - return x->asDouble() == y->asDouble(); - if (x->isNull() && y->isUndefined()) { + if (x.isNumber() && y.isNumber()) + return x.asDouble() == y.asDouble(); + if (x.isNull() && y.isUndefined()) { return true; - } else if (x->isUndefined() && y->isNull()) { + } else if (x.isUndefined() && y.isNull()) { return true; - } else if (x->isNumber() && y->isString()) { + } else if (x.isNumber() && y.isString()) { double dy = RuntimeHelpers::toNumber(y); - return x->asDouble() == dy; - } else if (x->isString() && y->isNumber()) { + return x.asDouble() == dy; + } else if (x.isString() && y.isNumber()) { double dx = RuntimeHelpers::toNumber(x); - return dx == y->asDouble(); - } else if (x->isBoolean()) { - return Runtime::compareEqual(Primitive::fromDouble((double) x->booleanValue()), y); - } else if (y->isBoolean()) { - return Runtime::compareEqual(x, Primitive::fromDouble((double) y->booleanValue())); + return dx == y.asDouble(); + } else if (x.isBoolean()) { + return Runtime::compareEqual(Primitive::fromDouble((double) x.booleanValue()), y); + } else if (y.isBoolean()) { + return Runtime::compareEqual(x, Primitive::fromDouble((double) y.booleanValue())); } else { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); #else - if ((x->isNumber() || x->isString()) && y->isObject()) { - Scope scope(y->objectValue()->engine()); + if ((x.isNumber() || x.isString()) && y.isObject()) { + Scope scope(y.objectValue()->engine()); ScopedValue py(scope, RuntimeHelpers::toPrimitive(y, PREFERREDTYPE_HINT)); return Runtime::compareEqual(x, py); - } else if (x->isObject() && (y->isNumber() || y->isString())) { - Scope scope(x->objectValue()->engine()); + } else if (x.isObject() && (y.isNumber() || y.isString())) { + Scope scope(x.objectValue()->engine()); ScopedValue px(scope, RuntimeHelpers::toPrimitive(x, PREFERREDTYPE_HINT)); return Runtime::compareEqual(px, y); } @@ -732,42 +732,42 @@ uint RuntimeHelpers::equalHelper(const ValueRef x, const ValueRef y) return false; } -Bool RuntimeHelpers::strictEqual(const ValueRef x, const ValueRef y) +Bool RuntimeHelpers::strictEqual(const Value &x, const Value &y) { TRACE2(x, y); - if (x->rawValue() == y->rawValue()) + if (x.rawValue() == y.rawValue()) // NaN != NaN - return !x->isNaN(); + return !x.isNaN(); - if (x->isNumber()) - return y->isNumber() && x->asDouble() == y->asDouble(); - if (x->isManaged()) - return y->isManaged() && x->cast<Managed>()->isEqualTo(y->cast<Managed>()); + if (x.isNumber()) + return y.isNumber() && x.asDouble() == y.asDouble(); + if (x.isManaged()) + return y.isManaged() && x.cast<Managed>()->isEqualTo(y.cast<Managed>()); return false; } -QV4::Bool Runtime::compareGreaterThan(const QV4::ValueRef l, const QV4::ValueRef r) +QV4::Bool Runtime::compareGreaterThan(const Value &l, const Value &r) { TRACE2(l, r); - if (l->isInteger() && r->isInteger()) - return l->integerValue() > r->integerValue(); - if (l->isNumber() && r->isNumber()) - return l->asDouble() > r->asDouble(); - if (l->isString() && r->isString()) { + if (l.isInteger() && r.isInteger()) + return l.integerValue() > r.integerValue(); + if (l.isNumber() && r.isNumber()) + return l.asDouble() > r.asDouble(); + if (l.isString() && r.isString()) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); return false; #else - return r->stringValue()->compare(l->stringValue()); + return r.stringValue()->compare(l.stringValue()); #endif } - if (l->isObject() || r->isObject()) { + if (l.isObject() || r.isObject()) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); #else - QV4::ExecutionEngine *e = (l->isObject() ? l->objectValue() : r->objectValue())->engine(); + QV4::ExecutionEngine *e = (l.isObject() ? l.objectValue() : r.objectValue())->engine(); QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); @@ -780,27 +780,27 @@ QV4::Bool Runtime::compareGreaterThan(const QV4::ValueRef l, const QV4::ValueRef return dl > dr; } -QV4::Bool Runtime::compareLessThan(const QV4::ValueRef l, const QV4::ValueRef r) +QV4::Bool Runtime::compareLessThan(const Value &l, const Value &r) { TRACE2(l, r); - if (l->isInteger() && r->isInteger()) - return l->integerValue() < r->integerValue(); - if (l->isNumber() && r->isNumber()) - return l->asDouble() < r->asDouble(); - if (l->isString() && r->isString()) { + if (l.isInteger() && r.isInteger()) + return l.integerValue() < r.integerValue(); + if (l.isNumber() && r.isNumber()) + return l.asDouble() < r.asDouble(); + if (l.isString() && r.isString()) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); return false; #else - return l->stringValue()->compare(r->stringValue()); + return l.stringValue()->compare(r.stringValue()); #endif } - if (l->isObject() || r->isObject()) { + if (l.isObject() || r.isObject()) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); #else - QV4::ExecutionEngine *e = (l->isObject() ? l->objectValue() : r->objectValue())->engine(); + QV4::ExecutionEngine *e = (l.isObject() ? l.objectValue() : r.objectValue())->engine(); QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); @@ -813,27 +813,27 @@ QV4::Bool Runtime::compareLessThan(const QV4::ValueRef l, const QV4::ValueRef r) return dl < dr; } -QV4::Bool Runtime::compareGreaterEqual(const QV4::ValueRef l, const QV4::ValueRef r) +QV4::Bool Runtime::compareGreaterEqual(const Value &l, const Value &r) { TRACE2(l, r); - if (l->isInteger() && r->isInteger()) - return l->integerValue() >= r->integerValue(); - if (l->isNumber() && r->isNumber()) - return l->asDouble() >= r->asDouble(); - if (l->isString() && r->isString()) { + if (l.isInteger() && r.isInteger()) + return l.integerValue() >= r.integerValue(); + if (l.isNumber() && r.isNumber()) + return l.asDouble() >= r.asDouble(); + if (l.isString() && r.isString()) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); return false; #else - return !l->stringValue()->compare(r->stringValue()); + return !l.stringValue()->compare(r.stringValue()); #endif } - if (l->isObject() || r->isObject()) { + if (l.isObject() || r.isObject()) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); #else - QV4::ExecutionEngine *e = (l->isObject() ? l->objectValue() : r->objectValue())->engine(); + QV4::ExecutionEngine *e = (l.isObject() ? l.objectValue() : r.objectValue())->engine(); QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); @@ -846,27 +846,27 @@ QV4::Bool Runtime::compareGreaterEqual(const QV4::ValueRef l, const QV4::ValueRe return dl >= dr; } -QV4::Bool Runtime::compareLessEqual(const QV4::ValueRef l, const QV4::ValueRef r) +QV4::Bool Runtime::compareLessEqual(const Value &l, const Value &r) { TRACE2(l, r); - if (l->isInteger() && r->isInteger()) - return l->integerValue() <= r->integerValue(); - if (l->isNumber() && r->isNumber()) - return l->asDouble() <= r->asDouble(); - if (l->isString() && r->isString()) { + if (l.isInteger() && r.isInteger()) + return l.integerValue() <= r.integerValue(); + if (l.isNumber() && r.isNumber()) + return l.asDouble() <= r.asDouble(); + if (l.isString() && r.isString()) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); return false; #else - return !r->stringValue()->compare(l->stringValue()); + return !r.stringValue()->compare(l.stringValue()); #endif } - if (l->isObject() || r->isObject()) { + if (l.isObject() || r.isObject()) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); #else - QV4::ExecutionEngine *e = (l->isObject() ? l->objectValue() : r->objectValue())->engine(); + QV4::ExecutionEngine *e = (l.isObject() ? l.objectValue() : r.objectValue())->engine(); QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); @@ -880,7 +880,7 @@ QV4::Bool Runtime::compareLessEqual(const QV4::ValueRef l, const QV4::ValueRef r } #ifndef V4_BOOTSTRAP -Bool Runtime::compareInstanceof(ExecutionEngine *engine, const ValueRef left, const ValueRef right) +Bool Runtime::compareInstanceof(ExecutionEngine *engine, const Value &left, const Value &right) { TRACE2(left, right); @@ -889,7 +889,7 @@ Bool Runtime::compareInstanceof(ExecutionEngine *engine, const ValueRef left, co return v->booleanValue(); } -uint Runtime::compareIn(ExecutionEngine *engine, const ValueRef left, const ValueRef right) +uint Runtime::compareIn(ExecutionEngine *engine, const Value &left, const Value &right) { TRACE2(left, right); @@ -986,11 +986,11 @@ ReturnedValue Runtime::callPropertyLookup(ExecutionEngine *engine, uint index, C return v.objectValue()->call(callData); } -ReturnedValue Runtime::callElement(ExecutionEngine *engine, const ValueRef index, CallData *callData) +ReturnedValue Runtime::callElement(ExecutionEngine *engine, const Value &index, CallData *callData) { Scope scope(engine); ScopedObject baseObject(scope, callData->thisObject.toObject(engine)); - ScopedString s(scope, index->toString(engine)); + ScopedString s(scope, index.toString(engine)); if (scope.engine->hasException) return Encode::undefined(); @@ -1003,12 +1003,12 @@ ReturnedValue Runtime::callElement(ExecutionEngine *engine, const ValueRef index return o->call(callData); } -ReturnedValue Runtime::callValue(ExecutionEngine *engine, const ValueRef func, CallData *callData) +ReturnedValue Runtime::callValue(ExecutionEngine *engine, const Value &func, CallData *callData) { - if (!func->isObject()) + if (!func.isObject()) return engine->throwTypeError(); - return func->objectValue()->call(callData); + return func.objectValue()->call(callData); } @@ -1042,9 +1042,9 @@ ReturnedValue Runtime::constructActivationProperty(ExecutionEngine *engine, int return f->construct(callData); } -ReturnedValue Runtime::constructValue(ExecutionEngine *engine, const ValueRef func, CallData *callData) +ReturnedValue Runtime::constructValue(ExecutionEngine *engine, const Value &func, CallData *callData) { - Object *f = func->asObject(); + Object *f = func.asObject(); if (!f) return engine->throwTypeError(); @@ -1078,17 +1078,17 @@ ReturnedValue Runtime::constructPropertyLookup(ExecutionEngine *engine, uint ind } -void Runtime::throwException(ExecutionEngine *engine, const ValueRef value) +void Runtime::throwException(ExecutionEngine *engine, const Value &value) { - if (!value->isEmpty()) + if (!value.isEmpty()) engine->throwError(value); } -ReturnedValue Runtime::typeofValue(ExecutionEngine *engine, const ValueRef value) +ReturnedValue Runtime::typeofValue(ExecutionEngine *engine, const Value &value) { Scope scope(engine); ScopedString res(scope); - switch (value->type()) { + switch (value.type()) { case Value::Undefined_Type: res = engine->id_undefined; break; @@ -1099,9 +1099,9 @@ ReturnedValue Runtime::typeofValue(ExecutionEngine *engine, const ValueRef value res = engine->id_boolean; break; case Value::Managed_Type: - if (value->isString()) + if (value.isString()) res = engine->id_string; - else if (value->objectValue()->asFunctionObject()) + else if (value.objectValue()->asFunctionObject()) res = engine->id_function; else res = engine->id_object; // ### implementation-defined @@ -1124,32 +1124,32 @@ QV4::ReturnedValue Runtime::typeofName(ExecutionEngine *engine, int nameIndex) return Runtime::typeofValue(engine, prop); } -QV4::ReturnedValue Runtime::typeofMember(ExecutionEngine *engine, const ValueRef base, int nameIndex) +QV4::ReturnedValue Runtime::typeofMember(ExecutionEngine *engine, const Value &base, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); - ScopedObject obj(scope, base->toObject(engine)); + ScopedObject obj(scope, base.toObject(engine)); if (scope.engine->hasException) return Encode::undefined(); ScopedValue prop(scope, obj->get(name)); return Runtime::typeofValue(engine, prop); } -QV4::ReturnedValue Runtime::typeofElement(ExecutionEngine *engine, const ValueRef base, const ValueRef index) +QV4::ReturnedValue Runtime::typeofElement(ExecutionEngine *engine, const Value &base, const Value &index) { Scope scope(engine); - ScopedString name(scope, index->toString(engine)); - ScopedObject obj(scope, base->toObject(engine)); + ScopedString name(scope, index.toString(engine)); + ScopedObject obj(scope, base.toObject(engine)); if (scope.engine->hasException) return Encode::undefined(); ScopedValue prop(scope, obj->get(name)); return Runtime::typeofValue(engine, prop); } -void Runtime::pushWithScope(const ValueRef o, ExecutionEngine *engine) +void Runtime::pushWithScope(const Value &o, ExecutionEngine *engine) { Scope scope(engine); - ScopedObject obj(scope, o->toObject(engine)); + ScopedObject obj(scope, o.toObject(engine)); ScopedContext ctx(scope, engine->currentContext()); ctx->newWithContext(obj); } @@ -1248,42 +1248,42 @@ QV4::ReturnedValue Runtime::setupArgumentsObject(ExecutionEngine *engine) #endif // V4_BOOTSTRAP -QV4::ReturnedValue Runtime::increment(const QV4::ValueRef value) +QV4::ReturnedValue Runtime::increment(const Value &value) { TRACE1(value); - if (value->isInteger() && value->integerValue() < INT_MAX) - return Encode(value->integerValue() + 1); + if (value.isInteger() && value.integerValue() < INT_MAX) + return Encode(value.integerValue() + 1); else { - double d = value->toNumber(); + double d = value.toNumber(); return Encode(d + 1.); } } -QV4::ReturnedValue Runtime::decrement(const QV4::ValueRef value) +QV4::ReturnedValue Runtime::decrement(const Value &value) { TRACE1(value); - if (value->isInteger() && value->integerValue() > INT_MIN) - return Encode(value->integerValue() - 1); + if (value.isInteger() && value.integerValue() > INT_MIN) + return Encode(value.integerValue() - 1); else { - double d = value->toNumber(); + double d = value.toNumber(); return Encode(d - 1.); } } #ifndef V4_BOOTSTRAP -QV4::ReturnedValue RuntimeHelpers::toString(ExecutionEngine *engine, const QV4::ValueRef value) +QV4::ReturnedValue RuntimeHelpers::toString(ExecutionEngine *engine, const Value &value) { - if (value->isString()) + if (value.isString()) return value.asReturnedValue(); return RuntimeHelpers::convertToString(engine, value)->asReturnedValue(); } -QV4::ReturnedValue RuntimeHelpers::toObject(ExecutionEngine *engine, const QV4::ValueRef value) +QV4::ReturnedValue RuntimeHelpers::toObject(ExecutionEngine *engine, const Value &value) { - if (value->isObject()) + if (value.isObject()) return value.asReturnedValue(); Heap::Object *o = RuntimeHelpers::convertToObject(engine, value); @@ -1295,16 +1295,16 @@ QV4::ReturnedValue RuntimeHelpers::toObject(ExecutionEngine *engine, const QV4:: #endif // V4_BOOTSTRAP -ReturnedValue Runtime::toDouble(const ValueRef value) +ReturnedValue Runtime::toDouble(const Value &value) { TRACE1(value); - return Encode(value->toNumber()); + return Encode(value.toNumber()); } -int Runtime::toInt(const ValueRef value) +int Runtime::toInt(const Value &value) { TRACE1(value); - return value->toInt32(); + return value.toInt32(); } int Runtime::doubleToInt(const double &d) @@ -1313,10 +1313,10 @@ int Runtime::doubleToInt(const double &d) return Primitive::toInt32(d); } -unsigned Runtime::toUInt(const ValueRef value) +unsigned Runtime::toUInt(const Value &value) { TRACE1(value); - return value->toUInt32(); + return value.toUInt32(); } unsigned Runtime::doubleToUInt(const double &d) @@ -1355,7 +1355,7 @@ ReturnedValue Runtime::getQmlScopeObject(NoThrowEngine *engine) return QObjectWrapper::wrap(engine, c->getScopeObject()); } -ReturnedValue Runtime::getQmlQObjectProperty(ExecutionEngine *engine, const ValueRef object, int propertyIndex, bool captureRequired) +ReturnedValue Runtime::getQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired) { Scope scope(engine); QV4::Scoped<QObjectWrapper> wrapper(scope, object); @@ -1380,7 +1380,7 @@ QV4::ReturnedValue Runtime::getQmlAttachedProperty(ExecutionEngine *engine, int return QV4::QObjectWrapper::getProperty(attachedObject, ctx, propertyIndex, /*captureRequired*/true); } -ReturnedValue Runtime::getQmlSingletonQObjectProperty(ExecutionEngine *engine, const ValueRef object, int propertyIndex, bool captureRequired) +ReturnedValue Runtime::getQmlSingletonQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired) { Scope scope(engine); QV4::Scoped<QmlTypeWrapper> wrapper(scope, object); @@ -1392,7 +1392,7 @@ ReturnedValue Runtime::getQmlSingletonQObjectProperty(ExecutionEngine *engine, c return QV4::QObjectWrapper::getProperty(wrapper->singletonObject(), ctx, propertyIndex, captureRequired); } -void Runtime::setQmlQObjectProperty(ExecutionEngine *engine, const ValueRef object, int propertyIndex, const ValueRef value) +void Runtime::setQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, const Value &value) { Scope scope(engine); QV4::Scoped<QObjectWrapper> wrapper(scope, object); diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index 4d70a66156..13c28cfea7 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -92,40 +92,40 @@ struct Q_QML_PRIVATE_EXPORT Runtime { static ReturnedValue callActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData); static ReturnedValue callProperty(ExecutionEngine *engine, int nameIndex, CallData *callData); static ReturnedValue callPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData); - static ReturnedValue callElement(ExecutionEngine *engine, const ValueRef index, CallData *callData); - static ReturnedValue callValue(ExecutionEngine *engine, const ValueRef func, CallData *callData); + static ReturnedValue callElement(ExecutionEngine *engine, const Value &index, CallData *callData); + static ReturnedValue callValue(ExecutionEngine *engine, const Value &func, CallData *callData); // construct static ReturnedValue constructGlobalLookup(ExecutionEngine *engine, uint index, CallData *callData); static ReturnedValue constructActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData); static ReturnedValue constructProperty(ExecutionEngine *engine, int nameIndex, CallData *callData); static ReturnedValue constructPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData); - static ReturnedValue constructValue(ExecutionEngine *engine, const ValueRef func, CallData *callData); + static ReturnedValue constructValue(ExecutionEngine *engine, const Value &func, CallData *callData); // set & get - static void setActivationProperty(ExecutionEngine *engine, int nameIndex, const ValueRef value); - static void setProperty(ExecutionEngine *engine, const ValueRef object, int nameIndex, const ValueRef value); - static void setElement(ExecutionEngine *engine, const ValueRef object, const ValueRef index, const ValueRef value); - static ReturnedValue getProperty(ExecutionEngine *engine, const ValueRef object, int nameIndex); + static void setActivationProperty(ExecutionEngine *engine, int nameIndex, const Value &value); + static void setProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value); + static void setElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value); + static ReturnedValue getProperty(ExecutionEngine *engine, const Value &object, int nameIndex); static ReturnedValue getActivationProperty(ExecutionEngine *engine, int nameIndex); - static ReturnedValue getElement(ExecutionEngine *engine, const ValueRef object, const ValueRef index); + static ReturnedValue getElement(ExecutionEngine *engine, const Value &object, const Value &index); // typeof - static ReturnedValue typeofValue(ExecutionEngine *engine, const ValueRef val); + static ReturnedValue typeofValue(ExecutionEngine *engine, const Value &val); static ReturnedValue typeofName(ExecutionEngine *engine, int nameIndex); - static ReturnedValue typeofMember(ExecutionEngine *engine, const ValueRef base, int nameIndex); - static ReturnedValue typeofElement(ExecutionEngine *engine, const ValueRef base, const ValueRef index); + static ReturnedValue typeofMember(ExecutionEngine *engine, const Value &base, int nameIndex); + static ReturnedValue typeofElement(ExecutionEngine *engine, const Value &base, const Value &index); // delete - static ReturnedValue deleteElement(ExecutionEngine *engine, const ValueRef base, const ValueRef index); - static ReturnedValue deleteMember(ExecutionEngine *engine, const ValueRef base, int nameIndex); - static ReturnedValue deleteMemberString(ExecutionEngine *engine, const ValueRef base, String *name); + static ReturnedValue deleteElement(ExecutionEngine *engine, const Value &base, const Value &index); + static ReturnedValue deleteMember(ExecutionEngine *engine, const Value &base, int nameIndex); + static ReturnedValue deleteMemberString(ExecutionEngine *engine, const Value &base, String *name); static ReturnedValue deleteName(ExecutionEngine *engine, int nameIndex); // exceptions & scopes - static void throwException(ExecutionEngine *engine, const ValueRef value); + static void throwException(ExecutionEngine *engine, const Value &value); static ReturnedValue unwindException(ExecutionEngine *engine); - static void pushWithScope(const ValueRef o, ExecutionEngine *engine); + static void pushWithScope(const Value &o, ExecutionEngine *engine); static void pushCatchScope(NoThrowEngine *engine, int exceptionVarNameIndex); static void popScope(ExecutionEngine *engine); @@ -143,66 +143,66 @@ struct Q_QML_PRIVATE_EXPORT Runtime { static ReturnedValue regexpLiteral(ExecutionEngine *engine, int id); // foreach - static ReturnedValue foreachIterator(ExecutionEngine *engine, const ValueRef in); - static ReturnedValue foreachNextPropertyName(const ValueRef foreach_iterator); + static ReturnedValue foreachIterator(ExecutionEngine *engine, const Value &in); + static ReturnedValue foreachNextPropertyName(const Value &foreach_iterator); // unary operators - typedef ReturnedValue (*UnaryOperation)(const ValueRef); - static ReturnedValue uPlus(const ValueRef value); - static ReturnedValue uMinus(const ValueRef value); - static ReturnedValue uNot(const ValueRef value); - static ReturnedValue complement(const ValueRef value); - static ReturnedValue increment(const ValueRef value); - static ReturnedValue decrement(const ValueRef value); + typedef ReturnedValue (*UnaryOperation)(const Value &value); + static ReturnedValue uPlus(const Value &value); + static ReturnedValue uMinus(const Value &value); + static ReturnedValue uNot(const Value &value); + static ReturnedValue complement(const Value &value); + static ReturnedValue increment(const Value &value); + static ReturnedValue decrement(const Value &value); // binary operators - typedef ReturnedValue (*BinaryOperation)(const ValueRef left, const ValueRef right); - typedef ReturnedValue (*BinaryOperationContext)(ExecutionEngine *engine, const ValueRef left, const ValueRef right); - - static ReturnedValue instanceof(ExecutionEngine *engine, const ValueRef left, const ValueRef right); - static ReturnedValue in(ExecutionEngine *engine, const ValueRef left, const ValueRef right); - static ReturnedValue add(ExecutionEngine *engine, const ValueRef left, const ValueRef right); - static ReturnedValue addString(ExecutionEngine *engine, const ValueRef left, const ValueRef right); - static ReturnedValue bitOr(const ValueRef left, const ValueRef right); - static ReturnedValue bitXor(const ValueRef left, const ValueRef right); - static ReturnedValue bitAnd(const ValueRef left, const ValueRef right); - static ReturnedValue sub(const ValueRef left, const ValueRef right); - static ReturnedValue mul(const ValueRef left, const ValueRef right); - static ReturnedValue div(const ValueRef left, const ValueRef right); - static ReturnedValue mod(const ValueRef left, const ValueRef right); - static ReturnedValue shl(const ValueRef left, const ValueRef right); - static ReturnedValue shr(const ValueRef left, const ValueRef right); - static ReturnedValue ushr(const ValueRef left, const ValueRef right); - static ReturnedValue greaterThan(const ValueRef left, const ValueRef right); - static ReturnedValue lessThan(const ValueRef left, const ValueRef right); - static ReturnedValue greaterEqual(const ValueRef left, const ValueRef right); - static ReturnedValue lessEqual(const ValueRef left, const ValueRef right); - static ReturnedValue equal(const ValueRef left, const ValueRef right); - static ReturnedValue notEqual(const ValueRef left, const ValueRef right); - static ReturnedValue strictEqual(const ValueRef left, const ValueRef right); - static ReturnedValue strictNotEqual(const ValueRef left, const ValueRef right); + typedef ReturnedValue (*BinaryOperation)(const Value &left, const Value &right); + typedef ReturnedValue (*BinaryOperationContext)(ExecutionEngine *engine, const Value &left, const Value &right); + + static ReturnedValue instanceof(ExecutionEngine *engine, const Value &left, const Value &right); + static ReturnedValue in(ExecutionEngine *engine, const Value &left, const Value &right); + static ReturnedValue add(ExecutionEngine *engine, const Value &left, const Value &right); + static ReturnedValue addString(ExecutionEngine *engine, const Value &left, const Value &right); + static ReturnedValue bitOr(const Value &left, const Value &right); + static ReturnedValue bitXor(const Value &left, const Value &right); + static ReturnedValue bitAnd(const Value &left, const Value &right); + static ReturnedValue sub(const Value &left, const Value &right); + static ReturnedValue mul(const Value &left, const Value &right); + static ReturnedValue div(const Value &left, const Value &right); + static ReturnedValue mod(const Value &left, const Value &right); + static ReturnedValue shl(const Value &left, const Value &right); + static ReturnedValue shr(const Value &left, const Value &right); + static ReturnedValue ushr(const Value &left, const Value &right); + static ReturnedValue greaterThan(const Value &left, const Value &right); + static ReturnedValue lessThan(const Value &left, const Value &right); + static ReturnedValue greaterEqual(const Value &left, const Value &right); + static ReturnedValue lessEqual(const Value &left, const Value &right); + static ReturnedValue equal(const Value &left, const Value &right); + static ReturnedValue notEqual(const Value &left, const Value &right); + static ReturnedValue strictEqual(const Value &left, const Value &right); + static ReturnedValue strictNotEqual(const Value &left, const Value &right); // comparisons - typedef Bool (*CompareOperation)(const ValueRef left, const ValueRef right); - static Bool compareGreaterThan(const ValueRef l, const ValueRef r); - static Bool compareLessThan(const ValueRef l, const ValueRef r); - static Bool compareGreaterEqual(const ValueRef l, const ValueRef r); - static Bool compareLessEqual(const ValueRef l, const ValueRef r); - static Bool compareEqual(const ValueRef left, const ValueRef right); - static Bool compareNotEqual(const ValueRef left, const ValueRef right); - static Bool compareStrictEqual(const ValueRef left, const ValueRef right); - static Bool compareStrictNotEqual(const ValueRef left, const ValueRef right); - - typedef Bool (*CompareOperationContext)(ExecutionEngine *engine, const ValueRef left, const ValueRef right); - static Bool compareInstanceof(ExecutionEngine *engine, const ValueRef left, const ValueRef right); - static Bool compareIn(ExecutionEngine *engine, const ValueRef left, const ValueRef right); + typedef Bool (*CompareOperation)(const Value &left, const Value &right); + static Bool compareGreaterThan(const Value &l, const Value &r); + static Bool compareLessThan(const Value &l, const Value &r); + static Bool compareGreaterEqual(const Value &l, const Value &r); + static Bool compareLessEqual(const Value &l, const Value &r); + static Bool compareEqual(const Value &left, const Value &right); + static Bool compareNotEqual(const Value &left, const Value &right); + static Bool compareStrictEqual(const Value &left, const Value &right); + static Bool compareStrictNotEqual(const Value &left, const Value &right); + + typedef Bool (*CompareOperationContext)(ExecutionEngine *engine, const Value &left, const Value &right); + static Bool compareInstanceof(ExecutionEngine *engine, const Value &left, const Value &right); + static Bool compareIn(ExecutionEngine *engine, const Value &left, const Value &right); // conversions - static Bool toBoolean(const ValueRef value); - static ReturnedValue toDouble(const ValueRef value); - static int toInt(const ValueRef value); + static Bool toBoolean(const Value &value); + static ReturnedValue toDouble(const Value &value); + static int toInt(const Value &value); static int doubleToInt(const double &d); - static unsigned toUInt(const ValueRef value); + static unsigned toUInt(const Value &value); static unsigned doubleToUInt(const double &d); // qml @@ -212,175 +212,175 @@ struct Q_QML_PRIVATE_EXPORT Runtime { static ReturnedValue getQmlScopeObject(NoThrowEngine *ctx); static ReturnedValue getQmlSingleton(NoThrowEngine *ctx, int nameIndex); static ReturnedValue getQmlAttachedProperty(ExecutionEngine *engine, int attachedPropertiesId, int propertyIndex); - static ReturnedValue getQmlQObjectProperty(ExecutionEngine *engine, const ValueRef object, int propertyIndex, bool captureRequired); - static ReturnedValue getQmlSingletonQObjectProperty(ExecutionEngine *engine, const ValueRef object, int propertyIndex, bool captureRequired); - static void setQmlQObjectProperty(ExecutionEngine *engine, const ValueRef object, int propertyIndex, const ValueRef value); + static ReturnedValue getQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired); + static ReturnedValue getQmlSingletonQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired); + static void setQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, const Value &value); }; struct Q_QML_PRIVATE_EXPORT RuntimeHelpers { static ReturnedValue objectDefaultValue(Object *object, int typeHint); - static ReturnedValue toPrimitive(const ValueRef value, int typeHint); + static ReturnedValue toPrimitive(const Value &value, int typeHint); static double stringToNumber(const QString &s); static Heap::String *stringFromNumber(ExecutionEngine *engine, double number); - static double toNumber(const ValueRef value); + static double toNumber(const Value &value); static void numberToString(QString *result, double num, int radix = 10); - static ReturnedValue toString(ExecutionEngine *engine, const ValueRef value); - static Heap::String *convertToString(ExecutionEngine *engine, const ValueRef value); + static ReturnedValue toString(ExecutionEngine *engine, const Value &value); + static Heap::String *convertToString(ExecutionEngine *engine, const Value &value); - static ReturnedValue toObject(ExecutionEngine *engine, const ValueRef value); - static Heap::Object *convertToObject(ExecutionEngine *engine, const ValueRef value); + static ReturnedValue toObject(ExecutionEngine *engine, const Value &value); + static Heap::Object *convertToObject(ExecutionEngine *engine, const Value &value); - static Bool equalHelper(const ValueRef x, const ValueRef y); - static Bool strictEqual(const ValueRef x, const ValueRef y); + static Bool equalHelper(const Value &x, const Value &y); + static Bool strictEqual(const Value &x, const Value &y); - static ReturnedValue addHelper(ExecutionEngine *engine, const ValueRef left, const ValueRef right); + static ReturnedValue addHelper(ExecutionEngine *engine, const Value &left, const Value &right); }; // type conversion and testing #ifndef V4_BOOTSTRAP -inline ReturnedValue RuntimeHelpers::toPrimitive(const ValueRef value, int typeHint) +inline ReturnedValue RuntimeHelpers::toPrimitive(const Value &value, int typeHint) { - Object *o = value->asObject(); + Object *o = value.asObject(); if (!o) return value.asReturnedValue(); return RuntimeHelpers::objectDefaultValue(o, typeHint); } #endif -inline double RuntimeHelpers::toNumber(const ValueRef value) +inline double RuntimeHelpers::toNumber(const Value &value) { - return value->toNumber(); + return value.toNumber(); } -inline ReturnedValue Runtime::uPlus(const ValueRef value) +inline ReturnedValue Runtime::uPlus(const Value &value) { TRACE1(value); - if (value->isNumber()) + if (value.isNumber()) return value.asReturnedValue(); - if (value->integerCompatible()) - return Encode(value->int_32); + if (value.integerCompatible()) + return Encode(value.int_32); - double n = value->toNumberImpl(); + double n = value.toNumberImpl(); return Encode(n); } -inline ReturnedValue Runtime::uMinus(const ValueRef value) +inline ReturnedValue Runtime::uMinus(const Value &value) { TRACE1(value); // +0 != -0, so we need to convert to double when negating 0 - if (value->isInteger() && value->integerValue()) - return Encode(-value->integerValue()); + if (value.isInteger() && value.integerValue()) + return Encode(-value.integerValue()); else { double n = RuntimeHelpers::toNumber(value); return Encode(-n); } } -inline ReturnedValue Runtime::complement(const ValueRef value) +inline ReturnedValue Runtime::complement(const Value &value) { TRACE1(value); - int n = value->toInt32(); + int n = value.toInt32(); return Encode((int)~n); } -inline ReturnedValue Runtime::uNot(const ValueRef value) +inline ReturnedValue Runtime::uNot(const Value &value) { TRACE1(value); - bool b = value->toBoolean(); + bool b = value.toBoolean(); return Encode(!b); } // binary operators -inline ReturnedValue Runtime::bitOr(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::bitOr(const Value &left, const Value &right) { TRACE2(left, right); - int lval = left->toInt32(); - int rval = right->toInt32(); + int lval = left.toInt32(); + int rval = right.toInt32(); return Encode(lval | rval); } -inline ReturnedValue Runtime::bitXor(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::bitXor(const Value &left, const Value &right) { TRACE2(left, right); - int lval = left->toInt32(); - int rval = right->toInt32(); + int lval = left.toInt32(); + int rval = right.toInt32(); return Encode(lval ^ rval); } -inline ReturnedValue Runtime::bitAnd(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::bitAnd(const Value &left, const Value &right) { TRACE2(left, right); - int lval = left->toInt32(); - int rval = right->toInt32(); + int lval = left.toInt32(); + int rval = right.toInt32(); return Encode(lval & rval); } #ifndef V4_BOOTSTRAP -inline ReturnedValue Runtime::add(ExecutionEngine *engine, const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::add(ExecutionEngine *engine, const Value &left, const Value &right) { TRACE2(left, right); - if (Q_LIKELY(left->isInteger() && right->isInteger())) - return add_int32(left->integerValue(), right->integerValue()); - if (left->isNumber() && right->isNumber()) - return Primitive::fromDouble(left->asDouble() + right->asDouble()).asReturnedValue(); + if (Q_LIKELY(left.isInteger() && right.isInteger())) + return add_int32(left.integerValue(), right.integerValue()); + if (left.isNumber() && right.isNumber()) + return Primitive::fromDouble(left.asDouble() + right.asDouble()).asReturnedValue(); return RuntimeHelpers::addHelper(engine, left, right); } #endif // V4_BOOTSTRAP -inline ReturnedValue Runtime::sub(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::sub(const Value &left, const Value &right) { TRACE2(left, right); - if (Q_LIKELY(left->isInteger() && right->isInteger())) - return sub_int32(left->integerValue(), right->integerValue()); + if (Q_LIKELY(left.isInteger() && right.isInteger())) + return sub_int32(left.integerValue(), right.integerValue()); - double lval = left->isNumber() ? left->asDouble() : left->toNumberImpl(); - double rval = right->isNumber() ? right->asDouble() : right->toNumberImpl(); + double lval = left.isNumber() ? left.asDouble() : left.toNumberImpl(); + double rval = right.isNumber() ? right.asDouble() : right.toNumberImpl(); return Primitive::fromDouble(lval - rval).asReturnedValue(); } -inline ReturnedValue Runtime::mul(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::mul(const Value &left, const Value &right) { TRACE2(left, right); - if (Q_LIKELY(left->isInteger() && right->isInteger())) - return mul_int32(left->integerValue(), right->integerValue()); + if (Q_LIKELY(left.isInteger() && right.isInteger())) + return mul_int32(left.integerValue(), right.integerValue()); - double lval = left->isNumber() ? left->asDouble() : left->toNumberImpl(); - double rval = right->isNumber() ? right->asDouble() : right->toNumberImpl(); + double lval = left.isNumber() ? left.asDouble() : left.toNumberImpl(); + double rval = right.isNumber() ? right.asDouble() : right.toNumberImpl(); return Primitive::fromDouble(lval * rval).asReturnedValue(); } -inline ReturnedValue Runtime::div(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::div(const Value &left, const Value &right) { TRACE2(left, right); - double lval = left->toNumber(); - double rval = right->toNumber(); + double lval = left.toNumber(); + double rval = right.toNumber(); return Primitive::fromDouble(lval / rval).asReturnedValue(); } -inline ReturnedValue Runtime::mod(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::mod(const Value &left, const Value &right) { TRACE2(left, right); - if (Value::integerCompatible(*left, *right) && right->integerValue() != 0) { - int intRes = left->integerValue() % right->integerValue(); - if (intRes != 0 || left->integerValue() >= 0) + if (Value::integerCompatible(left, right) && right.integerValue() != 0) { + int intRes = left.integerValue() % right.integerValue(); + if (intRes != 0 || left.integerValue() >= 0) return Encode(intRes); } @@ -389,36 +389,36 @@ inline ReturnedValue Runtime::mod(const ValueRef left, const ValueRef right) return Primitive::fromDouble(std::fmod(lval, rval)).asReturnedValue(); } -inline ReturnedValue Runtime::shl(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::shl(const Value &left, const Value &right) { TRACE2(left, right); - int lval = left->toInt32(); - int rval = right->toInt32() & 0x1f; + int lval = left.toInt32(); + int rval = right.toInt32() & 0x1f; return Encode((int)(lval << rval)); } -inline ReturnedValue Runtime::shr(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::shr(const Value &left, const Value &right) { TRACE2(left, right); - int lval = left->toInt32(); - unsigned rval = right->toUInt32() & 0x1f; + int lval = left.toInt32(); + unsigned rval = right.toUInt32() & 0x1f; return Encode((int)(lval >> rval)); } -inline ReturnedValue Runtime::ushr(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::ushr(const Value &left, const Value &right) { TRACE2(left, right); - unsigned lval = left->toUInt32(); - unsigned rval = right->toUInt32() & 0x1f; + unsigned lval = left.toUInt32(); + unsigned rval = right.toUInt32() & 0x1f; uint res = lval >> rval; return Encode(res); } -inline ReturnedValue Runtime::greaterThan(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::greaterThan(const Value &left, const Value &right) { TRACE2(left, right); @@ -426,7 +426,7 @@ inline ReturnedValue Runtime::greaterThan(const ValueRef left, const ValueRef ri return Encode(r); } -inline ReturnedValue Runtime::lessThan(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::lessThan(const Value &left, const Value &right) { TRACE2(left, right); @@ -434,7 +434,7 @@ inline ReturnedValue Runtime::lessThan(const ValueRef left, const ValueRef right return Encode(r); } -inline ReturnedValue Runtime::greaterEqual(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::greaterEqual(const Value &left, const Value &right) { TRACE2(left, right); @@ -442,7 +442,7 @@ inline ReturnedValue Runtime::greaterEqual(const ValueRef left, const ValueRef r return Encode(r); } -inline ReturnedValue Runtime::lessEqual(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::lessEqual(const Value &left, const Value &right) { TRACE2(left, right); @@ -450,25 +450,25 @@ inline ReturnedValue Runtime::lessEqual(const ValueRef left, const ValueRef righ return Encode(r); } -inline Bool Runtime::compareEqual(const ValueRef left, const ValueRef right) +inline Bool Runtime::compareEqual(const Value &left, const Value &right) { TRACE2(left, right); - if (left->rawValue() == right->rawValue()) + if (left.rawValue() == right.rawValue()) // NaN != NaN - return !left->isNaN(); + return !left.isNaN(); - if (left->type() == right->type()) { - if (!left->isManaged()) + if (left.type() == right.type()) { + if (!left.isManaged()) return false; - if (left->isString() == right->isString()) - return left->cast<Managed>()->isEqualTo(right->cast<Managed>()); + if (left.isString() == right.isString()) + return left.cast<Managed>()->isEqualTo(right.cast<Managed>()); } return RuntimeHelpers::equalHelper(left, right); } -inline ReturnedValue Runtime::equal(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::equal(const Value &left, const Value &right) { TRACE2(left, right); @@ -476,7 +476,7 @@ inline ReturnedValue Runtime::equal(const ValueRef left, const ValueRef right) return Encode(r); } -inline ReturnedValue Runtime::notEqual(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::notEqual(const Value &left, const Value &right) { TRACE2(left, right); @@ -484,7 +484,7 @@ inline ReturnedValue Runtime::notEqual(const ValueRef left, const ValueRef right return Encode(r); } -inline ReturnedValue Runtime::strictEqual(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::strictEqual(const Value &left, const Value &right) { TRACE2(left, right); @@ -492,7 +492,7 @@ inline ReturnedValue Runtime::strictEqual(const ValueRef left, const ValueRef ri return Encode(r); } -inline ReturnedValue Runtime::strictNotEqual(const ValueRef left, const ValueRef right) +inline ReturnedValue Runtime::strictNotEqual(const Value &left, const Value &right) { TRACE2(left, right); @@ -500,30 +500,30 @@ inline ReturnedValue Runtime::strictNotEqual(const ValueRef left, const ValueRef return Encode(r); } -inline Bool Runtime::compareNotEqual(const ValueRef left, const ValueRef right) +inline Bool Runtime::compareNotEqual(const Value &left, const Value &right) { TRACE2(left, right); return !Runtime::compareEqual(left, right); } -inline Bool Runtime::compareStrictEqual(const ValueRef left, const ValueRef right) +inline Bool Runtime::compareStrictEqual(const Value &left, const Value &right) { TRACE2(left, right); return RuntimeHelpers::strictEqual(left, right); } -inline Bool Runtime::compareStrictNotEqual(const ValueRef left, const ValueRef right) +inline Bool Runtime::compareStrictNotEqual(const Value &left, const Value &right) { TRACE2(left, right); return ! RuntimeHelpers::strictEqual(left, right); } -inline Bool Runtime::toBoolean(const ValueRef value) +inline Bool Runtime::toBoolean(const Value &value) { - return value->toBoolean(); + return value.toBoolean(); } } // namespace QV4 diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 705e5301dc..d72d23bbe9 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -193,6 +193,9 @@ struct ScopedValue return ptr; } + operator Value *() { return ptr; } + operator const Value &() const { return *ptr; } + ReturnedValue asReturnedValue() const { return ptr->val; } Value *ptr; @@ -264,7 +267,14 @@ struct Scoped #endif } - Scoped(const Scope &scope, const ValueRef &v); + Scoped(const Scope &scope, const Value *v) + { + ptr = scope.engine->jsStackTop++; + setPointer(v ? value_cast<T>(*v) : 0); +#ifndef QT_NO_DEBUG + ++scope.size; +#endif + } Scoped(const Scope &scope, T *t) { @@ -326,8 +336,10 @@ struct Scoped setPointer(value_cast<T>(v)); return *this; } - - Scoped<T> &operator=(const ValueRef &v); + Scoped<T> &operator=(Value *v) { + setPointer(v ? value_cast<T>(*v) : 0); + return *this; + } Scoped<T> &operator=(const ReturnedValue &v) { setPointer(value_cast<T>(QV4::Value::fromReturnedValue(v))); @@ -347,6 +359,9 @@ struct Scoped operator T *() { return static_cast<T *>(ptr->managed()); } + operator const Value &() const { + return *ptr; + } T *operator->() { return ptr->cast<T>(); @@ -398,23 +413,6 @@ struct ScopedCallData { }; -template<typename T> -inline Scoped<T>::Scoped(const Scope &scope, const ValueRef &v) -{ - ptr = scope.engine->jsStackTop++; - setPointer(value_cast<T>(*v.operator ->())); -#ifndef QT_NO_DEBUG - ++scope.size; -#endif -} - -template<typename T> -inline Scoped<T> &Scoped<T>::operator=(const ValueRef &v) -{ - setPointer(value_cast<T>(*v.operator ->())); - return *this; -} - inline Value &Value::operator =(const ScopedValue &v) { val = v.ptr->val; @@ -428,12 +426,6 @@ inline Value &Value::operator=(const Scoped<T> &t) return *this; } -inline Value &Value::operator=(const ValueRef v) -{ - val = v.asReturnedValue(); - return *this; -} - template<typename T> inline TypedValue<T> &TypedValue<T>::operator =(T *t) { diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 9f49678a3e..a38e87e550 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -189,7 +189,7 @@ Heap::FunctionObject *QmlBindingWrapper::createQmlCallableForFunction(QQmlContex Script::Script(ExecutionEngine *v4, Object *qml, CompiledData::CompilationUnit *compilationUnit) : line(0), column(0), scope(v4->rootContext()), strictMode(false), inheritContext(true), parsed(false) - , qml(v4, qml->asReturnedValue()), vmFunction(0), parseAsBinding(true) + , qml(v4, qml), vmFunction(0), parseAsBinding(true) { parsed = true; diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h index f2fd9cb7fc..1c17b75186 100644 --- a/src/qml/jsruntime/qv4script_p.h +++ b/src/qml/jsruntime/qv4script_p.h @@ -118,7 +118,7 @@ struct Q_QML_EXPORT Script { Script(ExecutionEngine *engine, Object *qml, const QString &sourceCode, const QString &source = QString(), int line = 1, int column = 0) : sourceFile(source), line(line), column(column), sourceCode(sourceCode) , scope(engine->rootContext()), strictMode(false), inheritContext(true), parsed(false) - , qml(engine, qml->asReturnedValue()), vmFunction(0), parseAsBinding(true) {} + , qml(engine, qml), vmFunction(0), parseAsBinding(true) {} Script(ExecutionEngine *engine, Object *qml, CompiledData::CompilationUnit *compilationUnit); ~Script(); QString sourceFile; diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 496a794b32..83fd2efa60 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -128,31 +128,31 @@ static QString convertElementToString(bool element) return QStringLiteral("false"); } -template <typename ElementType> ElementType convertValueToElement(const QV4::ValueRef value); +template <typename ElementType> ElementType convertValueToElement(const Value &value); -template <> QString convertValueToElement(const QV4::ValueRef value) +template <> QString convertValueToElement(const Value &value) { - return value->toQString(); + return value.toQString(); } -template <> int convertValueToElement(const QV4::ValueRef value) +template <> int convertValueToElement(const Value &value) { - return value->toInt32(); + return value.toInt32(); } -template <> QUrl convertValueToElement(const QV4::ValueRef value) +template <> QUrl convertValueToElement(const Value &value) { - return QUrl(value->toQString()); + return QUrl(value.toQString()); } -template <> qreal convertValueToElement(const QV4::ValueRef value) +template <> qreal convertValueToElement(const Value &value) { - return value->toNumber(); + return value.toNumber(); } -template <> bool convertValueToElement(const ValueRef value) +template <> bool convertValueToElement(const Value &value) { - return value->toBoolean(); + return value.toBoolean(); } namespace QV4 { @@ -215,7 +215,7 @@ public: return Encode::undefined(); } - void containerPutIndexed(uint index, const QV4::ValueRef value) + void containerPutIndexed(uint index, const QV4::Value &value) { if (internalClass()->engine->hasException) return; @@ -345,8 +345,8 @@ public: struct CompareFunctor { - CompareFunctor(QV4::ExecutionContext *ctx, const QV4::ValueRef compareFn) - : m_ctx(ctx), m_compareFn(compareFn) + CompareFunctor(QV4::ExecutionContext *ctx, const QV4::Value &compareFn) + : m_ctx(ctx), m_compareFn(&compareFn) {} bool operator()(typename Container::value_type lhs, typename Container::value_type rhs) @@ -363,7 +363,7 @@ public: private: QV4::ExecutionContext *m_ctx; - QV4::ValueRef m_compareFn; + const QV4::Value *m_compareFn; }; void sort(QV4::CallContext *ctx) @@ -484,7 +484,7 @@ public: static QV4::ReturnedValue getIndexed(QV4::Managed *that, uint index, bool *hasProperty) { return static_cast<QQmlSequence<Container> *>(that)->containerGetIndexed(index, hasProperty); } - static void putIndexed(Managed *that, uint index, const QV4::ValueRef value) + static void putIndexed(Managed *that, uint index, const QV4::Value &value) { static_cast<QQmlSequence<Container> *>(that)->containerPutIndexed(index, value); } static QV4::PropertyAttributes queryIndexed(const QV4::Managed *that, uint index) { return static_cast<const QQmlSequence<Container> *>(that)->containerQueryIndexed(index); } @@ -642,15 +642,15 @@ QVariant SequencePrototype::toVariant(Object *object) return QQml##ElementTypeName##List::toVariant(a); \ } else -QVariant SequencePrototype::toVariant(const QV4::ValueRef array, int typeHint, bool *succeeded) +QVariant SequencePrototype::toVariant(const QV4::Value &array, int typeHint, bool *succeeded) { *succeeded = true; - if (!array->asArrayObject()) { + if (!array.asArrayObject()) { *succeeded = false; return QVariant(); } - QV4::Scope scope(array->asObject()->engine()); + QV4::Scope scope(array.asObject()->engine()); QV4::ScopedArrayObject a(scope, array); FOREACH_QML_SEQUENCE_TYPE(SEQUENCE_TO_VARIANT) { /* else */ *succeeded = false; return QVariant(); } diff --git a/src/qml/jsruntime/qv4sequenceobject_p.h b/src/qml/jsruntime/qv4sequenceobject_p.h index 8d08a90869..0009fa45fa 100644 --- a/src/qml/jsruntime/qv4sequenceobject_p.h +++ b/src/qml/jsruntime/qv4sequenceobject_p.h @@ -72,7 +72,7 @@ struct SequencePrototype : public QV4::Object static ReturnedValue fromVariant(QV4::ExecutionEngine *engine, const QVariant& v, bool *succeeded); static int metaTypeForSequence(Object *object); static QVariant toVariant(Object *object); - static QVariant toVariant(const ValueRef array, int typeHint, bool *succeeded); + static QVariant toVariant(const Value &array, int typeHint, bool *succeeded); }; } diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp index 017a2cbdb1..765fef3332 100644 --- a/src/qml/jsruntime/qv4serialize.cpp +++ b/src/qml/jsruntime/qv4serialize.cpp @@ -139,20 +139,20 @@ static inline void *popPtr(const char *&data) // serialization/deserialization failures #define ALIGN(size) (((size) + 3) & ~3) -void Serialize::serialize(QByteArray &data, const QV4::ValueRef v, ExecutionEngine *engine) +void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine *engine) { QV4::Scope scope(engine); - if (v->isEmpty()) { + if (v.isEmpty()) { Q_ASSERT(!"Serialize: got empty value"); - } else if (v->isUndefined()) { + } else if (v.isUndefined()) { push(data, valueheader(WorkerUndefined)); - } else if (v->isNull()) { + } else if (v.isNull()) { push(data, valueheader(WorkerNull)); - } else if (v->isBoolean()) { - push(data, valueheader(v->booleanValue() == true ? WorkerTrue : WorkerFalse)); - } else if (v->isString()) { - const QString &qstr = v->toQString(); + } else if (v.isBoolean()) { + push(data, valueheader(v.booleanValue() == true ? WorkerTrue : WorkerFalse)); + } else if (v.isString()) { + const QString &qstr = v.toQString(); int length = qstr.length(); if (length > 0xFFFFFF) { push(data, valueheader(WorkerUndefined)); @@ -168,12 +168,11 @@ void Serialize::serialize(QByteArray &data, const QV4::ValueRef v, ExecutionEngi char *buffer = data.data() + offset; memcpy(buffer, qstr.constData(), length*sizeof(QChar)); - } else if (v->asFunctionObject()) { + } else if (v.asFunctionObject()) { // XXX TODO: Implement passing function objects between the main and // worker scripts push(data, valueheader(WorkerUndefined)); - } else if (v->asArrayObject()) { - QV4::ScopedArrayObject array(scope, v); + } else if (QV4::ArrayObject *array = v.asArrayObject()) { uint length = array->getLength(); if (length > 0xFFFFFF) { push(data, valueheader(WorkerUndefined)); @@ -184,24 +183,23 @@ void Serialize::serialize(QByteArray &data, const QV4::ValueRef v, ExecutionEngi ScopedValue val(scope); for (uint ii = 0; ii < length; ++ii) serialize(data, (val = array->getIndexed(ii)), engine); - } else if (v->isInteger()) { + } else if (v.isInteger()) { reserve(data, 2 * sizeof(quint32)); push(data, valueheader(WorkerInt32)); - push(data, (quint32)v->integerValue()); -// } else if (v->IsUint32()) { + push(data, (quint32)v.integerValue()); +// } else if (v.IsUint32()) { // reserve(data, 2 * sizeof(quint32)); // push(data, valueheader(WorkerUint32)); -// push(data, v->Uint32Value()); - } else if (v->isNumber()) { +// push(data, v.Uint32Value()); + } else if (v.isNumber()) { reserve(data, sizeof(quint32) + sizeof(double)); push(data, valueheader(WorkerNumber)); - push(data, v->asDouble()); - } else if (QV4::DateObject *d = v->asDateObject()) { + push(data, v.asDouble()); + } else if (QV4::DateObject *d = v.asDateObject()) { reserve(data, sizeof(quint32) + sizeof(double)); push(data, valueheader(WorkerDate)); push(data, d->date().asDouble()); - } else if (v->as<RegExpObject>()) { - Scoped<RegExpObject> re(scope, v); + } else if (RegExpObject *re = v.as<RegExpObject>()) { quint32 flags = re->flags(); QString pattern = re->source(); int length = pattern.length() + 1; @@ -220,8 +218,7 @@ void Serialize::serialize(QByteArray &data, const QV4::ValueRef v, ExecutionEngi char *buffer = data.data() + offset; memcpy(buffer, pattern.constData(), length*sizeof(QChar)); - } else if (v->as<QV4::QObjectWrapper>()) { - Scoped<QObjectWrapper> qobjectWrapper(scope, v); + } else if (QObjectWrapper *qobjectWrapper = v.as<QV4::QObjectWrapper>()) { // XXX TODO: Generalize passing objects between the main thread and worker scripts so // that others can trivially plug in their elements. QQmlListModel *lm = qobject_cast<QQmlListModel *>(qobjectWrapper->object()); @@ -234,8 +231,7 @@ void Serialize::serialize(QByteArray &data, const QV4::ValueRef v, ExecutionEngi } // No other QObject's are allowed to be sent push(data, valueheader(WorkerUndefined)); - } else if (v->asObject()) { - ScopedObject o(scope, v); + } else if (Object *o = v.asObject()) { if (o->isListType()) { // valid sequence. we generate a length (sequence length + 1 for the sequence type) uint seqLength = ScopedValue(scope, o->get(engine->id_length))->toUInt32(); @@ -255,7 +251,7 @@ void Serialize::serialize(QByteArray &data, const QV4::ValueRef v, ExecutionEngi } // regular object - QV4::ScopedValue val(scope, *v); + QV4::ScopedValue val(scope, v); QV4::ScopedArrayObject properties(scope, QV4::ObjectPrototype::getOwnPropertyNames(engine, val)); quint32 length = properties->getLength(); if (length > 0xFFFFFF) { @@ -265,12 +261,11 @@ void Serialize::serialize(QByteArray &data, const QV4::ValueRef v, ExecutionEngi push(data, valueheader(WorkerObject, length)); QV4::ScopedValue s(scope); - QV4::ScopedString str(scope); for (quint32 ii = 0; ii < length; ++ii) { s = properties->getIndexed(ii); serialize(data, s, engine); - str = s; + QV4::String *str = s->asString(); val = o->get(str); if (scope.hasException()) scope.engine->catchException(); @@ -390,7 +385,7 @@ ReturnedValue Serialize::deserialize(const char *&data, ExecutionEngine *engine) return QV4::Encode::undefined(); } -QByteArray Serialize::serialize(const QV4::ValueRef value, ExecutionEngine *engine) +QByteArray Serialize::serialize(const QV4::Value &value, ExecutionEngine *engine) { QByteArray rv; serialize(rv, value, engine); diff --git a/src/qml/jsruntime/qv4serialize_p.h b/src/qml/jsruntime/qv4serialize_p.h index 8cab3d58c5..85d56da0d5 100644 --- a/src/qml/jsruntime/qv4serialize_p.h +++ b/src/qml/jsruntime/qv4serialize_p.h @@ -57,11 +57,11 @@ namespace QV4 { class Serialize { public: - static QByteArray serialize(const ValueRef, ExecutionEngine *); + static QByteArray serialize(const Value &, ExecutionEngine *); static ReturnedValue deserialize(const QByteArray &, ExecutionEngine *); private: - static void serialize(QByteArray &, const ValueRef, ExecutionEngine *); + static void serialize(QByteArray &, const Value &, ExecutionEngine *); static ReturnedValue deserialize(const char *&, ExecutionEngine *); }; diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index aab1505832..ed4d70270c 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -82,7 +82,7 @@ Heap::StringObject::StringObject(InternalClass *ic, QV4::Object *prototype) s->defineReadonlyProperty(ic->engine->id_length, Primitive::fromInt32(0)); } -Heap::StringObject::StringObject(ExecutionEngine *engine, const ValueRef val) +Heap::StringObject::StringObject(ExecutionEngine *engine, const Value &val) : Heap::Object(engine->emptyClass, engine->stringPrototype.asObject()) { value = val; diff --git a/src/qml/jsruntime/qv4stringobject_p.h b/src/qml/jsruntime/qv4stringobject_p.h index a5851cb9bb..beddbd0e2e 100644 --- a/src/qml/jsruntime/qv4stringobject_p.h +++ b/src/qml/jsruntime/qv4stringobject_p.h @@ -45,7 +45,7 @@ namespace Heap { struct StringObject : Object { StringObject(InternalClass *ic, QV4::Object *prototype); - StringObject(ExecutionEngine *engine, const ValueRef value); + StringObject(ExecutionEngine *engine, const Value &value); Value value; Property *getIndex(uint index) const; diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp index ed18174d1c..1b9c5d58e4 100644 --- a/src/qml/jsruntime/qv4typedarray.cpp +++ b/src/qml/jsruntime/qv4typedarray.cpp @@ -46,9 +46,9 @@ ReturnedValue Int8ArrayRead(const char *data, int index) return Encode((int)(signed char)data[index]); } -void Int8ArrayWrite(ExecutionEngine *e, char *data, int index, ValueRef value) +void Int8ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) { - signed char v = (signed char)value->toUInt32(); + signed char v = (signed char)value.toUInt32(); if (e->hasException) return; data[index] = v; @@ -59,21 +59,21 @@ ReturnedValue UInt8ArrayRead(const char *data, int index) return Encode((int)(unsigned char)data[index]); } -void UInt8ArrayWrite(ExecutionEngine *e, char *data, int index, ValueRef value) +void UInt8ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) { - unsigned char v = (unsigned char)value->toUInt32(); + unsigned char v = (unsigned char)value.toUInt32(); if (e->hasException) return; data[index] = v; } -void UInt8ClampedArrayWrite(ExecutionEngine *e, char *data, int index, ValueRef value) +void UInt8ClampedArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) { - if (value->isInteger()) { - data[index] = (char)(unsigned char)qBound(0, value->integerValue(), 255); + if (value.isInteger()) { + data[index] = (char)(unsigned char)qBound(0, value.integerValue(), 255); return; } - double d = value->toNumber(); + double d = value.toNumber(); if (e->hasException) return; // ### is there a way to optimise this? @@ -107,9 +107,9 @@ ReturnedValue Int16ArrayRead(const char *data, int index) return Encode((int)*(short *)(data + index)); } -void Int16ArrayWrite(ExecutionEngine *e, char *data, int index, ValueRef value) +void Int16ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) { - short v = (short)value->toInt32(); + short v = (short)value.toInt32(); if (e->hasException) return; *(short *)(data + index) = v; @@ -120,9 +120,9 @@ ReturnedValue UInt16ArrayRead(const char *data, int index) return Encode((int)*(unsigned short *)(data + index)); } -void UInt16ArrayWrite(ExecutionEngine *e, char *data, int index, ValueRef value) +void UInt16ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) { - unsigned short v = (unsigned short)value->toInt32(); + unsigned short v = (unsigned short)value.toInt32(); if (e->hasException) return; *(unsigned short *)(data + index) = v; @@ -133,9 +133,9 @@ ReturnedValue Int32ArrayRead(const char *data, int index) return Encode(*(int *)(data + index)); } -void Int32ArrayWrite(ExecutionEngine *e, char *data, int index, ValueRef value) +void Int32ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) { - int v = (int)value->toInt32(); + int v = (int)value.toInt32(); if (e->hasException) return; *(int *)(data + index) = v; @@ -146,9 +146,9 @@ ReturnedValue UInt32ArrayRead(const char *data, int index) return Encode(*(unsigned int *)(data + index)); } -void UInt32ArrayWrite(ExecutionEngine *e, char *data, int index, ValueRef value) +void UInt32ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) { - unsigned int v = (unsigned int)value->toUInt32(); + unsigned int v = (unsigned int)value.toUInt32(); if (e->hasException) return; *(unsigned int *)(data + index) = v; @@ -159,9 +159,9 @@ ReturnedValue Float32ArrayRead(const char *data, int index) return Encode(*(float *)(data + index)); } -void Float32ArrayWrite(ExecutionEngine *e, char *data, int index, ValueRef value) +void Float32ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) { - float v = value->toNumber(); + float v = value.toNumber(); if (e->hasException) return; *(float *)(data + index) = v; @@ -172,9 +172,9 @@ ReturnedValue Float64ArrayRead(const char *data, int index) return Encode(*(double *)(data + index)); } -void Float64ArrayWrite(ExecutionEngine *e, char *data, int index, ValueRef value) +void Float64ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) { - double v = value->toNumber(); + double v = value.toNumber(); if (e->hasException) return; *(double *)(data + index) = v; @@ -361,7 +361,7 @@ ReturnedValue TypedArray::getIndexed(Managed *m, uint index, bool *hasProperty) return a->d()->type->read(a->d()->buffer->data->data(), byteOffset); } -void TypedArray::putIndexed(Managed *m, uint index, const ValueRef value) +void TypedArray::putIndexed(Managed *m, uint index, const Value &value) { ExecutionEngine *v4 = static_cast<Object *>(m)->engine(); if (v4->hasException) diff --git a/src/qml/jsruntime/qv4typedarray_p.h b/src/qml/jsruntime/qv4typedarray_p.h index 6c9bcfbba4..78949226b8 100644 --- a/src/qml/jsruntime/qv4typedarray_p.h +++ b/src/qml/jsruntime/qv4typedarray_p.h @@ -43,7 +43,7 @@ namespace QV4 { struct ArrayBuffer; typedef ReturnedValue (*TypedArrayRead)(const char *data, int index); -typedef void (*TypedArrayWrite)(ExecutionEngine *engine, char *data, int index, ValueRef value); +typedef void (*TypedArrayWrite)(ExecutionEngine *engine, char *data, int index, const Value &value); struct TypedArrayOperations { int bytesPerElement; @@ -101,7 +101,7 @@ struct TypedArray : Object static void markObjects(Heap::Base *that, ExecutionEngine *e); static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); - static void putIndexed(Managed *m, uint index, const ValueRef value); + static void putIndexed(Managed *m, uint index, const Value &value); }; struct TypedArrayCtor: FunctionObject diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp index 784628071b..0f81c94f24 100644 --- a/src/qml/jsruntime/qv4value.cpp +++ b/src/qml/jsruntime/qv4value.cpp @@ -90,7 +90,7 @@ double Value::toNumberImpl() const { Q_ASSERT(isObject()); Scope scope(objectValue()->engine()); - ScopedValue prim(scope, RuntimeHelpers::toPrimitive(ValueRef::fromRawValue(this), NUMBER_HINT)); + ScopedValue prim(scope, RuntimeHelpers::toPrimitive(*this, NUMBER_HINT)); if (scope.engine->hasException) return 0; return prim->toNumber(); diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 58e82f8fe2..22f0e1e4d5 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -394,7 +394,6 @@ struct Q_QML_PRIVATE_EXPORT Value template<typename T> Value &operator=(const Scoped<T> &t); - Value &operator=(const ValueRef v); Value &operator=(const Value &v) { val = v.val; return *this; @@ -423,7 +422,6 @@ struct Q_QML_PRIVATE_EXPORT Primitive : public Value static unsigned int toUInt32(double value); inline operator ValueRef(); - Value asValue() const { return *this; } }; inline Primitive Primitive::undefinedValue() @@ -545,6 +543,9 @@ struct ValueRef { return ptr; } + operator Value &() { return *ptr; } + operator const Value &() const { return *ptr; } + operator Value *() { return ptr; } @@ -555,7 +556,7 @@ struct ValueRef { static ValueRef fromRawValue(Value *v) { return ValueRef(v); } - static const ValueRef fromRawValue(const Value *v) { + static const Value &fromRawValue(const Value *v) { return ValueRef(const_cast<Value *>(v)); } diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index e86c673bf1..87b1387eed 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -229,57 +229,57 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_BEGIN_INSTR(StoreName) TRACE(inline, "property name = %s", runtimeStrings[instr.name]->toQString().toUtf8().constData()); - Runtime::setActivationProperty(engine, instr.name, VALUEPTR(instr.source)); + Runtime::setActivationProperty(engine, instr.name, VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreName) MOTH_BEGIN_INSTR(LoadElement) - STOREVALUE(instr.result, Runtime::getElement(engine, VALUEPTR(instr.base), VALUEPTR(instr.index))); + STOREVALUE(instr.result, Runtime::getElement(engine, VALUE(instr.base), VALUE(instr.index))); MOTH_END_INSTR(LoadElement) MOTH_BEGIN_INSTR(LoadElementLookup) QV4::Lookup *l = context->d()->lookups + instr.lookup; - STOREVALUE(instr.result, l->indexedGetter(l, VALUEPTR(instr.base), VALUEPTR(instr.index))); + STOREVALUE(instr.result, l->indexedGetter(l, VALUE(instr.base), VALUE(instr.index))); MOTH_END_INSTR(LoadElementLookup) MOTH_BEGIN_INSTR(StoreElement) - Runtime::setElement(engine, VALUEPTR(instr.base), VALUEPTR(instr.index), VALUEPTR(instr.source)); + Runtime::setElement(engine, VALUE(instr.base), VALUE(instr.index), VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreElement) MOTH_BEGIN_INSTR(StoreElementLookup) QV4::Lookup *l = context->d()->lookups + instr.lookup; - l->indexedSetter(l, VALUEPTR(instr.base), VALUEPTR(instr.index), VALUEPTR(instr.source)); + l->indexedSetter(l, VALUE(instr.base), VALUE(instr.index), VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreElementLookup) MOTH_BEGIN_INSTR(LoadProperty) - STOREVALUE(instr.result, Runtime::getProperty(engine, VALUEPTR(instr.base), instr.name)); + STOREVALUE(instr.result, Runtime::getProperty(engine, VALUE(instr.base), instr.name)); MOTH_END_INSTR(LoadProperty) MOTH_BEGIN_INSTR(GetLookup) QV4::Lookup *l = context->d()->lookups + instr.index; - STOREVALUE(instr.result, l->getter(l, engine, VALUEPTR(instr.base))); + STOREVALUE(instr.result, l->getter(l, engine, VALUE(instr.base))); MOTH_END_INSTR(GetLookup) MOTH_BEGIN_INSTR(StoreProperty) - Runtime::setProperty(engine, VALUEPTR(instr.base), instr.name, VALUEPTR(instr.source)); + Runtime::setProperty(engine, VALUE(instr.base), instr.name, VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreProperty) MOTH_BEGIN_INSTR(SetLookup) QV4::Lookup *l = context->d()->lookups + instr.index; - l->setter(l, engine, VALUEPTR(instr.base), VALUEPTR(instr.source)); + l->setter(l, engine, VALUE(instr.base), VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(SetLookup) MOTH_BEGIN_INSTR(StoreQObjectProperty) - Runtime::setQmlQObjectProperty(engine, VALUEPTR(instr.base), instr.propertyIndex, VALUEPTR(instr.source)); + Runtime::setQmlQObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreQObjectProperty) MOTH_BEGIN_INSTR(LoadQObjectProperty) - STOREVALUE(instr.result, Runtime::getQmlQObjectProperty(engine, VALUEPTR(instr.base), instr.propertyIndex, instr.captureRequired)); + STOREVALUE(instr.result, Runtime::getQmlQObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, instr.captureRequired)); MOTH_END_INSTR(LoadQObjectProperty) MOTH_BEGIN_INSTR(LoadAttachedQObjectProperty) @@ -287,7 +287,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(LoadAttachedQObjectProperty) MOTH_BEGIN_INSTR(LoadSingletonQObjectProperty) - STOREVALUE(instr.result, Runtime::getQmlSingletonQObjectProperty(engine, VALUEPTR(instr.base), instr.propertyIndex, instr.captureRequired)); + STOREVALUE(instr.result, Runtime::getQmlSingletonQObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, instr.captureRequired)); MOTH_END_INSTR(LoadSingletonQObjectProperty) MOTH_BEGIN_INSTR(Push) @@ -313,7 +313,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = QV4::Primitive::undefinedValue(); - STOREVALUE(instr.result, Runtime::callValue(engine, VALUEPTR(instr.dest), callData)); + STOREVALUE(instr.result, Runtime::callValue(engine, VALUE(instr.dest), callData)); MOTH_END_INSTR(CallValue) MOTH_BEGIN_INSTR(CallProperty) @@ -341,7 +341,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = VALUE(instr.base); - STOREVALUE(instr.result, Runtime::callElement(engine, VALUEPTR(instr.index), callData)); + STOREVALUE(instr.result, Runtime::callElement(engine, VALUE(instr.index), callData)); MOTH_END_INSTR(CallElement) MOTH_BEGIN_INSTR(CallActivationProperty) @@ -367,7 +367,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(SetExceptionHandler) MOTH_BEGIN_INSTR(CallBuiltinThrow) - Runtime::throwException(engine, VALUEPTR(instr.arg)); + Runtime::throwException(engine, VALUE(instr.arg)); CHECK_EXCEPTION; MOTH_END_INSTR(CallBuiltinThrow) @@ -381,7 +381,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(CallBuiltinPushCatchScope) MOTH_BEGIN_INSTR(CallBuiltinPushScope) - Runtime::pushWithScope(VALUEPTR(instr.arg), engine); + Runtime::pushWithScope(VALUE(instr.arg), engine); context = engine->currentContext(); CHECK_EXCEPTION; MOTH_END_INSTR(CallBuiltinPushScope) @@ -392,19 +392,19 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(CallBuiltinPopScope) MOTH_BEGIN_INSTR(CallBuiltinForeachIteratorObject) - STOREVALUE(instr.result, Runtime::foreachIterator(engine, VALUEPTR(instr.arg))); + STOREVALUE(instr.result, Runtime::foreachIterator(engine, VALUE(instr.arg))); MOTH_END_INSTR(CallBuiltinForeachIteratorObject) MOTH_BEGIN_INSTR(CallBuiltinForeachNextPropertyName) - STOREVALUE(instr.result, Runtime::foreachNextPropertyName(VALUEPTR(instr.arg))); + STOREVALUE(instr.result, Runtime::foreachNextPropertyName(VALUE(instr.arg))); MOTH_END_INSTR(CallBuiltinForeachNextPropertyName) MOTH_BEGIN_INSTR(CallBuiltinDeleteMember) - STOREVALUE(instr.result, Runtime::deleteMember(engine, VALUEPTR(instr.base), instr.member)); + STOREVALUE(instr.result, Runtime::deleteMember(engine, VALUE(instr.base), instr.member)); MOTH_END_INSTR(CallBuiltinDeleteMember) MOTH_BEGIN_INSTR(CallBuiltinDeleteSubscript) - STOREVALUE(instr.result, Runtime::deleteElement(engine, VALUEPTR(instr.base), VALUEPTR(instr.index))); + STOREVALUE(instr.result, Runtime::deleteElement(engine, VALUE(instr.base), VALUE(instr.index))); MOTH_END_INSTR(CallBuiltinDeleteSubscript) MOTH_BEGIN_INSTR(CallBuiltinDeleteName) @@ -412,11 +412,11 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(CallBuiltinDeleteName) MOTH_BEGIN_INSTR(CallBuiltinTypeofMember) - STOREVALUE(instr.result, Runtime::typeofMember(engine, VALUEPTR(instr.base), instr.member)); + STOREVALUE(instr.result, Runtime::typeofMember(engine, VALUE(instr.base), instr.member)); MOTH_END_INSTR(CallBuiltinTypeofMember) MOTH_BEGIN_INSTR(CallBuiltinTypeofSubscript) - STOREVALUE(instr.result, Runtime::typeofElement(engine, VALUEPTR(instr.base), VALUEPTR(instr.index))); + STOREVALUE(instr.result, Runtime::typeofElement(engine, VALUE(instr.base), VALUE(instr.index))); MOTH_END_INSTR(CallBuiltinTypeofSubscript) MOTH_BEGIN_INSTR(CallBuiltinTypeofName) @@ -424,7 +424,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(CallBuiltinTypeofName) MOTH_BEGIN_INSTR(CallBuiltinTypeofValue) - STOREVALUE(instr.result, Runtime::typeofValue(engine, VALUEPTR(instr.value))); + STOREVALUE(instr.result, Runtime::typeofValue(engine, VALUE(instr.value))); MOTH_END_INSTR(CallBuiltinTypeofValue) MOTH_BEGIN_INSTR(CallBuiltinDeclareVar) @@ -457,7 +457,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = QV4::Primitive::undefinedValue(); - STOREVALUE(instr.result, Runtime::constructValue(engine, VALUEPTR(instr.func), callData)); + STOREVALUE(instr.result, Runtime::constructValue(engine, VALUE(instr.func), callData)); MOTH_END_INSTR(CreateValue) MOTH_BEGIN_INSTR(CreateProperty) @@ -515,7 +515,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(JumpNe) MOTH_BEGIN_INSTR(UNot) - STOREVALUE(instr.result, Runtime::uNot(VALUEPTR(instr.source))); + STOREVALUE(instr.result, Runtime::uNot(VALUE(instr.source))); MOTH_END_INSTR(UNot) MOTH_BEGIN_INSTR(UNotBool) @@ -524,15 +524,15 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(UNotBool) MOTH_BEGIN_INSTR(UPlus) - STOREVALUE(instr.result, Runtime::uPlus(VALUEPTR(instr.source))); + STOREVALUE(instr.result, Runtime::uPlus(VALUE(instr.source))); MOTH_END_INSTR(UPlus) MOTH_BEGIN_INSTR(UMinus) - STOREVALUE(instr.result, Runtime::uMinus(VALUEPTR(instr.source))); + STOREVALUE(instr.result, Runtime::uMinus(VALUE(instr.source))); MOTH_END_INSTR(UMinus) MOTH_BEGIN_INSTR(UCompl) - STOREVALUE(instr.result, Runtime::complement(VALUEPTR(instr.source))); + STOREVALUE(instr.result, Runtime::complement(VALUE(instr.source))); MOTH_END_INSTR(UCompl) MOTH_BEGIN_INSTR(UComplInt) @@ -540,31 +540,31 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(UComplInt) MOTH_BEGIN_INSTR(Increment) - STOREVALUE(instr.result, Runtime::increment(VALUEPTR(instr.source))); + STOREVALUE(instr.result, Runtime::increment(VALUE(instr.source))); MOTH_END_INSTR(Increment) MOTH_BEGIN_INSTR(Decrement) - STOREVALUE(instr.result, Runtime::decrement(VALUEPTR(instr.source))); + STOREVALUE(instr.result, Runtime::decrement(VALUE(instr.source))); MOTH_END_INSTR(Decrement) MOTH_BEGIN_INSTR(Binop) - STOREVALUE(instr.result, instr.alu(VALUEPTR(instr.lhs), VALUEPTR(instr.rhs))); + STOREVALUE(instr.result, instr.alu(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(Binop) MOTH_BEGIN_INSTR(Add) - STOREVALUE(instr.result, Runtime::add(engine, VALUEPTR(instr.lhs), VALUEPTR(instr.rhs))); + STOREVALUE(instr.result, Runtime::add(engine, VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(Add) MOTH_BEGIN_INSTR(BitAnd) - STOREVALUE(instr.result, Runtime::bitAnd(VALUEPTR(instr.lhs), VALUEPTR(instr.rhs))); + STOREVALUE(instr.result, Runtime::bitAnd(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(BitAnd) MOTH_BEGIN_INSTR(BitOr) - STOREVALUE(instr.result, Runtime::bitOr(VALUEPTR(instr.lhs), VALUEPTR(instr.rhs))); + STOREVALUE(instr.result, Runtime::bitOr(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(BitOr) MOTH_BEGIN_INSTR(BitXor) - STOREVALUE(instr.result, Runtime::bitXor(VALUEPTR(instr.lhs), VALUEPTR(instr.rhs))); + STOREVALUE(instr.result, Runtime::bitXor(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(BitXor) MOTH_BEGIN_INSTR(Shr) @@ -599,15 +599,15 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(ShlConst) MOTH_BEGIN_INSTR(Mul) - STOREVALUE(instr.result, Runtime::mul(VALUEPTR(instr.lhs), VALUEPTR(instr.rhs))); + STOREVALUE(instr.result, Runtime::mul(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(Mul) MOTH_BEGIN_INSTR(Sub) - STOREVALUE(instr.result, Runtime::sub(VALUEPTR(instr.lhs), VALUEPTR(instr.rhs))); + STOREVALUE(instr.result, Runtime::sub(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(Sub) MOTH_BEGIN_INSTR(BinopContext) - STOREVALUE(instr.result, instr.alu(engine, VALUEPTR(instr.lhs), VALUEPTR(instr.rhs))); + STOREVALUE(instr.result, instr.alu(engine, VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(BinopContext) MOTH_BEGIN_INSTR(Ret) |