diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-25 12:24:36 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-28 13:33:24 +0200 |
commit | cf2a253f2f60c9f0c61682527d80143e72b355d4 (patch) | |
tree | d60e8be50437e6f15513e25155817b902a2062c7 /src/qml/jsruntime | |
parent | 7872b380063d0497ba62fecfdc92148f1ea947af (diff) |
Move Value::fromBool, ... to a new Primitive class
This will simplify finding the remaining direct usages of
QV4::Value that need fixing.
Change-Id: I223099727436d5748027c84c53d9dfc4028e38ed
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
40 files changed, 289 insertions, 279 deletions
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index 34ccd0af49..61922c9d53 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -92,7 +92,7 @@ ArgumentsObject::ArgumentsObject(CallContext *context) } Q_ASSERT(LengthPropertyIndex == internalClass->find(context->engine->id_length)); Property *lp = memberData + ArrayObject::LengthPropertyIndex; - lp->value = Value::fromInt32(context->realArgumentCount); + lp->value = Primitive::fromInt32(context->realArgumentCount); } void ArgumentsObject::destroy(Managed *that) @@ -172,8 +172,8 @@ ReturnedValue ArgumentsSetterFunction::call(Managed *setter, CallData *callData) setter->engine()->current->throwTypeError(); assert(s->index < o->context->callData->argc); - o->context->callData->args[s->index] = callData->argc ? callData->args[0] : Value::undefinedValue(); - return Value::undefinedValue().asReturnedValue(); + o->context->callData->args[s->index] = callData->argc ? callData->args[0] : Primitive::undefinedValue(); + return Primitive::undefinedValue().asReturnedValue(); } void ArgumentsObject::markObjects(Managed *that) diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 2c5670ef92..0aa7e93804 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -93,7 +93,7 @@ ArrayPrototype::ArrayPrototype(InternalClass *ic) void ArrayPrototype::init(ExecutionEngine *engine, const Value &ctor) { - ctor.objectValue()->defineReadonlyProperty(engine->id_length, Value::fromInt32(1)); + ctor.objectValue()->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1)); ctor.objectValue()->defineReadonlyProperty(engine->id_prototype, Value::fromObject(this)); ctor.objectValue()->defineDefaultProperty(QStringLiteral("isArray"), method_isArray, 1); defineDefaultProperty(QStringLiteral("constructor"), ctor); @@ -223,7 +223,7 @@ ReturnedValue ArrayPrototype::method_join(SimpleCallContext *ctx) for (quint32 k = 1; k < r2; ++k) { R += r4; - name = Value::fromDouble(k).toString(ctx); + name = Primitive::fromDouble(k).toString(ctx); r12 = self->get(name); if (!r12->isNullOrUndefined()) @@ -242,7 +242,7 @@ ReturnedValue ArrayPrototype::method_pop(SimpleCallContext *ctx) if (!len) { if (!instance->isArrayObject()) - instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromInt32(0))); + instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromInt32(0))); return Encode::undefined(); } @@ -252,7 +252,7 @@ ReturnedValue ArrayPrototype::method_pop(SimpleCallContext *ctx) if (instance->isArrayObject()) instance->setArrayLengthUnchecked(len - 1); else - instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromDouble(len - 1))); + instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - 1))); return result.asReturnedValue(); } @@ -267,15 +267,15 @@ ReturnedValue ArrayPrototype::method_push(SimpleCallContext *ctx) double l = len; ScopedString s(scope); for (int i = 0; i < ctx->callData->argc; ++i) { - s = Value::fromDouble(l + i).toString(ctx); + s = Primitive::fromDouble(l + i).toString(ctx); instance->put(s, ctx->callData->args[i]); } double newLen = l + ctx->callData->argc; if (!instance->isArrayObject()) - instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromDouble(newLen))); + instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(newLen))); else ctx->throwRangeError(Value::fromString(ctx, QStringLiteral("Array.prototype.push: Overflow"))); - return Value::fromDouble(newLen).asReturnedValue(); + return Primitive::fromDouble(newLen).asReturnedValue(); } if (!instance->protoHasArray() && instance->arrayDataLen <= len) { @@ -301,7 +301,7 @@ ReturnedValue ArrayPrototype::method_push(SimpleCallContext *ctx) if (instance->isArrayObject()) instance->setArrayLengthUnchecked(len); else - instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromDouble(len))); + instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len))); return Encode(len); } @@ -340,8 +340,8 @@ ReturnedValue ArrayPrototype::method_shift(SimpleCallContext *ctx) if (!len) { if (!instance->isArrayObject()) - instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromInt32(0))); - return Value::undefinedValue().asReturnedValue(); + instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromInt32(0))); + return Primitive::undefinedValue().asReturnedValue(); } Property *front = 0; @@ -349,7 +349,7 @@ ReturnedValue ArrayPrototype::method_shift(SimpleCallContext *ctx) if (pidx < UINT_MAX && (!instance->arrayAttributes || !instance->arrayAttributes[0].isGeneric())) front = instance->arrayData + pidx; - Value result = front ? Value::fromReturnedValue(instance->getValue(front, instance->arrayAttributes ? instance->arrayAttributes[pidx] : Attr_Data)) : Value::undefinedValue(); + Value result = front ? Value::fromReturnedValue(instance->getValue(front, instance->arrayAttributes ? instance->arrayAttributes[pidx] : Attr_Data)) : Primitive::undefinedValue(); if (!instance->protoHasArray() && instance->arrayDataLen <= len) { if (!instance->sparseArray) { @@ -382,7 +382,7 @@ ReturnedValue ArrayPrototype::method_shift(SimpleCallContext *ctx) if (instance->isArrayObject()) instance->setArrayLengthUnchecked(len - 1); else - instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromDouble(len - 1))); + instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - 1))); return result.asReturnedValue(); } @@ -492,7 +492,7 @@ ReturnedValue ArrayPrototype::method_splice(SimpleCallContext *ctx) instance->putIndexed(start + i, ctx->callData->args[i + 2]); ctx->strictMode = true; - instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromDouble(len - deleteCount + itemCount))); + instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - deleteCount + itemCount))); return newArray.asReturnedValue(); } @@ -542,7 +542,7 @@ ReturnedValue ArrayPrototype::method_unshift(SimpleCallContext *ctx) if (instance->isArrayObject()) instance->setArrayLengthUnchecked(newLen); else - instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromDouble(newLen))); + instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(newLen))); return Encode(newLen); } @@ -554,7 +554,7 @@ ReturnedValue ArrayPrototype::method_indexOf(SimpleCallContext *ctx) ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); if (!len) - return Value::fromInt32(-1).asReturnedValue(); + return Primitive::fromInt32(-1).asReturnedValue(); ScopedValue searchValue(scope); uint fromIndex = 0; @@ -562,7 +562,7 @@ ReturnedValue ArrayPrototype::method_indexOf(SimpleCallContext *ctx) if (ctx->callData->argc >= 1) searchValue = ctx->callData->args[0]; else - searchValue = Value::undefinedValue(); + searchValue = Primitive::undefinedValue(); if (ctx->callData->argc >= 2) { double f = ctx->callData->args[1].toInteger(); @@ -594,7 +594,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(SimpleCallContext *ctx) ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); if (!len) - return Value::fromInt32(-1).asReturnedValue(); + return Primitive::fromInt32(-1).asReturnedValue(); ScopedValue searchValue(scope); uint fromIndex = len; @@ -602,7 +602,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(SimpleCallContext *ctx) if (ctx->callData->argc >= 1) searchValue = ctx->argument(0); else - searchValue = Value::undefinedValue(); + searchValue = Primitive::undefinedValue(); if (ctx->callData->argc >= 2) { double f = ctx->callData->args[1].toInteger(); @@ -624,7 +624,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(SimpleCallContext *ctx) if (exists && __qmljs_strict_equal(v, searchValue)) return Encode(k); } - return Value::fromInt32(-1).asReturnedValue(); + return Primitive::fromInt32(-1).asReturnedValue(); } ReturnedValue ArrayPrototype::method_every(SimpleCallContext *ctx) @@ -652,7 +652,7 @@ ReturnedValue ArrayPrototype::method_every(SimpleCallContext *ctx) continue; callData->args[0] = v; - callData->args[1] = Value::fromDouble(k); + callData->args[1] = Primitive::fromDouble(k); r = callback->call(callData); ok = r->toBoolean(); } @@ -682,7 +682,7 @@ ReturnedValue ArrayPrototype::method_some(SimpleCallContext *ctx) continue; callData->args[0] = v; - callData->args[1] = Value::fromDouble(k); + callData->args[1] = Primitive::fromDouble(k); Value r = Value::fromReturnedValue(callback->call(callData)); if (r.toBoolean()) return Encode(true); @@ -713,7 +713,7 @@ ReturnedValue ArrayPrototype::method_forEach(SimpleCallContext *ctx) continue; callData->args[0] = v; - callData->args[1] = Value::fromDouble(k); + callData->args[1] = Primitive::fromDouble(k); callback->call(callData); } return Encode::undefined(); @@ -747,7 +747,7 @@ ReturnedValue ArrayPrototype::method_map(SimpleCallContext *ctx) continue; callData->args[0] = v; - callData->args[1] = Value::fromDouble(k); + callData->args[1] = Primitive::fromDouble(k); mapped = callback->call(callData); a->arraySet(k, mapped); } @@ -783,7 +783,7 @@ ReturnedValue ArrayPrototype::method_filter(SimpleCallContext *ctx) continue; callData->args[0] = v; - callData->args[1] = Value::fromDouble(k); + callData->args[1] = Primitive::fromDouble(k); selected = callback->call(callData); if (selected->toBoolean()) { a->arraySet(to, v); @@ -823,7 +823,7 @@ ReturnedValue ArrayPrototype::method_reduce(SimpleCallContext *ctx) } ScopedCallData callData(scope, 4); - callData->thisObject = Value::undefinedValue(); + callData->thisObject = Primitive::undefinedValue(); callData->args[0] = acc; callData->args[3] = instance; @@ -833,7 +833,7 @@ ReturnedValue ArrayPrototype::method_reduce(SimpleCallContext *ctx) if (kPresent) { callData->args[0] = acc; callData->args[1] = v; - callData->args[2] = Value::fromDouble(k); + callData->args[2] = Primitive::fromDouble(k); acc = callback->call(callData); } ++k; @@ -876,7 +876,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(SimpleCallContext *ctx) } ScopedCallData callData(scope, 4); - callData->thisObject = Value::undefinedValue(); + callData->thisObject = Primitive::undefinedValue(); callData->args[3] = instance; while (k > 0) { @@ -885,7 +885,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(SimpleCallContext *ctx) if (kPresent) { callData->args[0] = acc; callData->args[1] = v; - callData->args[2] = Value::fromDouble(k - 1); + callData->args[2] = Primitive::fromDouble(k - 1); acc = callback->call(callData); } --k; diff --git a/src/qml/jsruntime/qv4booleanobject.cpp b/src/qml/jsruntime/qv4booleanobject.cpp index 7e0831232c..0a1e5449b7 100644 --- a/src/qml/jsruntime/qv4booleanobject.cpp +++ b/src/qml/jsruntime/qv4booleanobject.cpp @@ -55,7 +55,7 @@ ReturnedValue BooleanCtor::construct(Managed *m, CallData *callData) { Scope scope(m->engine()); bool n = callData->argc ? callData->args[0].toBoolean() : false; - ScopedValue b(scope, QV4::Value::fromBoolean(n)); + ScopedValue b(scope, QV4::Primitive::fromBoolean(n)); return Encode(m->engine()->newBooleanObject(b)); } @@ -67,7 +67,7 @@ ReturnedValue BooleanCtor::call(Managed *, CallData *callData) void BooleanPrototype::init(ExecutionEngine *engine, const Value &ctor) { - ctor.objectValue()->defineReadonlyProperty(engine->id_length, Value::fromInt32(1)); + ctor.objectValue()->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1)); ctor.objectValue()->defineReadonlyProperty(engine->id_prototype, Value::fromObject(this)); defineDefaultProperty(QStringLiteral("constructor"), ctor); defineDefaultProperty(engine->id_toString, method_toString); diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index d47a68423c..e7ac8967a4 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -83,13 +83,13 @@ CallContext *ExecutionContext::newCallContext(void *stackSpace, Value *locals, F c->locals = locals; if (function->varCount) - std::fill(c->locals, c->locals + function->varCount, Value::undefinedValue()); + std::fill(c->locals, c->locals + function->varCount, Primitive::undefinedValue()); if (callData->argc < function->formalParameterCount) { #ifndef QT_NO_DEBUG Q_ASSERT(function->formalParameterCount <= QV4::Global::ReservedArgumentCount); #endif - std::fill(c->callData->args + callData->argc, c->callData->args + function->formalParameterCount, Value::undefinedValue()); + std::fill(c->callData->args + callData->argc, c->callData->args + function->formalParameterCount, Primitive::undefinedValue()); c->callData->argc = function->formalParameterCount; } @@ -124,12 +124,12 @@ CallContext *ExecutionContext::newCallContext(FunctionObject *function, CallData c->locals = (Value *)(c + 1); if (function->varCount) - std::fill(c->locals, c->locals + function->varCount, Value::undefinedValue()); + std::fill(c->locals, c->locals + function->varCount, Primitive::undefinedValue()); c->callData = reinterpret_cast<CallData *>(c->locals + function->varCount); ::memcpy(c->callData, callData, sizeof(CallData) + (callData->argc - 1) * sizeof(Value)); if (callData->argc < function->formalParameterCount) - std::fill(c->callData->args + c->callData->argc, c->callData->args + function->formalParameterCount, Value::undefinedValue()); + std::fill(c->callData->args + c->callData->argc, c->callData->args + function->formalParameterCount, Primitive::undefinedValue()); c->callData->argc = qMax((uint)callData->argc, function->formalParameterCount); return c; @@ -183,7 +183,7 @@ void ExecutionContext::createMutableBinding(const StringRef name, bool deletable if (activation->__hasProperty__(name)) return; - Property desc = Property::fromValue(Value::undefinedValue()); + Property desc = Property::fromValue(Primitive::undefinedValue()); PropertyAttributes attrs(Attr_Data); attrs.setConfigurable(deletable); activation->__defineOwnProperty__(this, name, desc, attrs); @@ -252,7 +252,7 @@ void CallContext::initQmlContext(ExecutionContext *parentContext, Object *qml, F this->callData = reinterpret_cast<CallData *>(this + 1); this->callData->tag = QV4::Value::Integer_Type; this->callData->argc = 0; - this->callData->thisObject = Value::undefinedValue(); + this->callData->thisObject = Primitive::undefinedValue(); strictMode = true; marked = false; @@ -270,7 +270,7 @@ void CallContext::initQmlContext(ExecutionContext *parentContext, Object *qml, F locals = (Value *)(this + 1); if (function->varCount) - std::fill(locals, locals + function->varCount, Value::undefinedValue()); + std::fill(locals, locals + function->varCount, Primitive::undefinedValue()); } @@ -522,7 +522,7 @@ ReturnedValue ExecutionContext::getPropertyNoThrow(const StringRef name) return v.asReturnedValue(); } } - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); } ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, Object **base) diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 05d4b6ee7f..2ecd80c58d 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -692,7 +692,7 @@ ReturnedValue DateCtor::construct(Managed *m, CallData *callData) t = TimeClip(UTC(t)); } - return Encode(m->engine()->newDateObject(Value::fromDouble(t))); + return Encode(m->engine()->newDateObject(Primitive::fromDouble(t))); } ReturnedValue DateCtor::call(Managed *m, CallData *) @@ -704,7 +704,7 @@ ReturnedValue DateCtor::call(Managed *m, CallData *) void DatePrototype::init(ExecutionEngine *engine, const Value &ctor) { ctor.objectValue()->defineReadonlyProperty(engine->id_prototype, Value::fromObject(this)); - ctor.objectValue()->defineReadonlyProperty(engine->id_length, Value::fromInt32(7)); + ctor.objectValue()->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(7)); LocalTZA = getLocalTZA(); ctor.objectValue()->defineDefaultProperty(QStringLiteral("parse"), method_parse, 1); diff --git a/src/qml/jsruntime/qv4dateobject_p.h b/src/qml/jsruntime/qv4dateobject_p.h index 758a2ce197..b560a26b7f 100644 --- a/src/qml/jsruntime/qv4dateobject_p.h +++ b/src/qml/jsruntime/qv4dateobject_p.h @@ -63,7 +63,7 @@ struct DateObject: Object { QDateTime toQDateTime() const; protected: - DateObject(InternalClass *ic): Object(ic), value(Value::fromDouble(qSNaN())) { + DateObject(InternalClass *ic): Object(ic), value(Primitive::fromDouble(qSNaN())) { vtbl = &static_vtbl; type = Type_DateObject; } diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 1721e59abb..2f297c34f5 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -82,7 +82,7 @@ static QBasicAtomicInt engineSerial = Q_BASIC_ATOMIC_INITIALIZER(1); static ReturnedValue throwTypeError(SimpleCallContext *ctx) { ctx->throwTypeError(); - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); } ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) @@ -280,9 +280,9 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) globalObject->defineDefaultProperty(QStringLiteral("Math"), Value::fromObject(new (memoryManager) MathObject(this))); globalObject->defineDefaultProperty(QStringLiteral("JSON"), Value::fromObject(new (memoryManager) JsonObject(this))); - globalObject->defineReadonlyProperty(QStringLiteral("undefined"), Value::undefinedValue()); - globalObject->defineReadonlyProperty(QStringLiteral("NaN"), Value::fromDouble(std::numeric_limits<double>::quiet_NaN())); - globalObject->defineReadonlyProperty(QStringLiteral("Infinity"), Value::fromDouble(Q_INFINITY)); + globalObject->defineReadonlyProperty(QStringLiteral("undefined"), Primitive::undefinedValue()); + globalObject->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(std::numeric_limits<double>::quiet_NaN())); + globalObject->defineReadonlyProperty(QStringLiteral("Infinity"), Primitive::fromDouble(Q_INFINITY)); evalFunction = new (memoryManager) EvalFunction(rootContext); globalObject->defineDefaultProperty(QStringLiteral("eval"), Value::fromObject(evalFunction)); diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index c4870e13bb..d8400cd6d5 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -105,7 +105,7 @@ ErrorObject::ErrorObject(InternalClass *ic, const Value &message, ErrorType t) stackTrace = ic->engine->stackTrace(); if (!stackTrace.isEmpty()) { defineDefaultProperty(QStringLiteral("fileName"), Value::fromString(ic->engine, stackTrace.at(0).source)); - defineDefaultProperty(QStringLiteral("lineNumber"), Value::fromInt32(stackTrace.at(0).line)); + defineDefaultProperty(QStringLiteral("lineNumber"), Primitive::fromInt32(stackTrace.at(0).line)); } } @@ -132,7 +132,7 @@ ErrorObject::ErrorObject(InternalClass *ic, const QString &message, const QStrin if (!stackTrace.isEmpty()) { defineDefaultProperty(QStringLiteral("fileName"), Value::fromString(ic->engine, stackTrace.at(0).source)); - defineDefaultProperty(QStringLiteral("lineNumber"), Value::fromInt32(stackTrace.at(0).line)); + defineDefaultProperty(QStringLiteral("lineNumber"), Primitive::fromInt32(stackTrace.at(0).line)); } defineDefaultProperty(QStringLiteral("message"), Value::fromString(ic->engine->newString(message))); @@ -253,7 +253,7 @@ ErrorCtor::ErrorCtor(ExecutionContext *scope, const QString &name) ReturnedValue ErrorCtor::construct(Managed *m, CallData *callData) { - return Encode(m->engine()->newErrorObject(callData->argc ? callData->args[0] : Value::undefinedValue())); + return Encode(m->engine()->newErrorObject(callData->argc ? callData->args[0] : Primitive::undefinedValue())); } ReturnedValue ErrorCtor::call(Managed *that, CallData *callData) @@ -269,7 +269,7 @@ EvalErrorCtor::EvalErrorCtor(ExecutionContext *scope) ReturnedValue EvalErrorCtor::construct(Managed *m, CallData *callData) { - return Value::fromObject(new (m->engine()->memoryManager) EvalErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())) + return Value::fromObject(new (m->engine()->memoryManager) EvalErrorObject(m->engine(), callData->argc ? callData->args[0] : Primitive::undefinedValue())) .asReturnedValue(); } @@ -281,7 +281,7 @@ RangeErrorCtor::RangeErrorCtor(ExecutionContext *scope) ReturnedValue RangeErrorCtor::construct(Managed *m, CallData *callData) { - return Value::fromObject(new (m->engine()->memoryManager) RangeErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue(); + return Value::fromObject(new (m->engine()->memoryManager) RangeErrorObject(m->engine(), callData->argc ? callData->args[0] : Primitive::undefinedValue())).asReturnedValue(); } ReferenceErrorCtor::ReferenceErrorCtor(ExecutionContext *scope) @@ -292,7 +292,7 @@ ReferenceErrorCtor::ReferenceErrorCtor(ExecutionContext *scope) ReturnedValue ReferenceErrorCtor::construct(Managed *m, CallData *callData) { - return Value::fromObject(new (m->engine()->memoryManager) ReferenceErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue(); + return Value::fromObject(new (m->engine()->memoryManager) ReferenceErrorObject(m->engine(), callData->argc ? callData->args[0] : Primitive::undefinedValue())).asReturnedValue(); } SyntaxErrorCtor::SyntaxErrorCtor(ExecutionContext *scope) @@ -303,7 +303,7 @@ SyntaxErrorCtor::SyntaxErrorCtor(ExecutionContext *scope) ReturnedValue SyntaxErrorCtor::construct(Managed *m, CallData *callData) { - return Value::fromObject(new (m->engine()->memoryManager) SyntaxErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue(); + return Value::fromObject(new (m->engine()->memoryManager) SyntaxErrorObject(m->engine(), callData->argc ? callData->args[0] : Primitive::undefinedValue())).asReturnedValue(); } TypeErrorCtor::TypeErrorCtor(ExecutionContext *scope) @@ -314,7 +314,7 @@ TypeErrorCtor::TypeErrorCtor(ExecutionContext *scope) ReturnedValue TypeErrorCtor::construct(Managed *m, CallData *callData) { - return Value::fromObject(new (m->engine()->memoryManager) TypeErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue(); + return Value::fromObject(new (m->engine()->memoryManager) TypeErrorObject(m->engine(), callData->argc ? callData->args[0] : Primitive::undefinedValue())).asReturnedValue(); } URIErrorCtor::URIErrorCtor(ExecutionContext *scope) @@ -325,13 +325,13 @@ URIErrorCtor::URIErrorCtor(ExecutionContext *scope) ReturnedValue URIErrorCtor::construct(Managed *m, CallData *callData) { - return Value::fromObject(new (m->engine()->memoryManager) URIErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue(); + return Value::fromObject(new (m->engine()->memoryManager) URIErrorObject(m->engine(), callData->argc ? callData->args[0] : Primitive::undefinedValue())).asReturnedValue(); } void ErrorPrototype::init(ExecutionEngine *engine, const Value &ctor, Object *obj) { ctor.objectValue()->defineReadonlyProperty(engine->id_prototype, Value::fromObject(obj)); - ctor.objectValue()->defineReadonlyProperty(engine->id_length, Value::fromInt32(1)); + ctor.objectValue()->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1)); obj->defineDefaultProperty(QStringLiteral("constructor"), ctor); obj->defineDefaultProperty(engine->id_toString, method_toString, 0); obj->defineDefaultProperty(QStringLiteral("message"), Value::fromString(engine, QString())); diff --git a/src/qml/jsruntime/qv4exception.cpp b/src/qml/jsruntime/qv4exception.cpp index 35a4f726e2..2c42e6f773 100644 --- a/src/qml/jsruntime/qv4exception.cpp +++ b/src/qml/jsruntime/qv4exception.cpp @@ -101,7 +101,7 @@ Exception::Exception(ExecutionContext *throwingContext, const Value &exceptionVa Exception::~Exception() { assert(accepted); - e->exceptionValue = Value::undefinedValue(); + e->exceptionValue = Primitive::undefinedValue(); } void Exception::accept(ExecutionContext *catchingContext) diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 7f4c419ddc..b4c39504f0 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -295,10 +295,10 @@ FunctionPrototype::FunctionPrototype(InternalClass *ic) void FunctionPrototype::init(ExecutionEngine *engine, const Value &ctor) { - ctor.objectValue()->defineReadonlyProperty(engine->id_length, Value::fromInt32(1)); + ctor.objectValue()->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1)); ctor.objectValue()->defineReadonlyProperty(engine->id_prototype, Value::fromObject(this)); - defineReadonlyProperty(engine->id_length, Value::fromInt32(0)); + defineReadonlyProperty(engine->id_length, Primitive::fromInt32(0)); defineDefaultProperty(QStringLiteral("constructor"), ctor); defineDefaultProperty(engine->id_toString, method_toString, 0); defineDefaultProperty(QStringLiteral("apply"), method_apply, 2); @@ -349,7 +349,7 @@ ReturnedValue FunctionPrototype::method_apply(SimpleCallContext *ctx) for (quint32 i = 0; i < alen; ++i) callData->args[i] = arr->arrayData[i].value; for (quint32 i = alen; i < len; ++i) - callData->args[i] = Value::undefinedValue(); + callData->args[i] = Primitive::undefinedValue(); } } @@ -415,7 +415,7 @@ ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function) strictMode = function->isStrict(); formalParameterCount = function->formals.size(); formalParameterList = function->formals.constData(); - defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(formalParameterCount)); + defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount)); varCount = function->locals.size(); varList = function->locals.constData(); @@ -514,7 +514,7 @@ SimpleScriptFunction::SimpleScriptFunction(ExecutionContext *scope, Function *fu strictMode = function->isStrict(); formalParameterCount = function->formals.size(); formalParameterList = function->formals.constData(); - defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(formalParameterCount)); + defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount)); varCount = function->locals.size(); varList = function->locals.constData(); @@ -675,7 +675,7 @@ BoundFunction::BoundFunction(ExecutionContext *scope, FunctionObject *target, Va len -= boundArgs.size(); if (len < 0) len = 0; - defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(len)); + defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(len)); ExecutionEngine *v4 = scope->engine; diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index d01a989ae1..1b8a6c51ed 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -199,7 +199,7 @@ struct IndexedBuiltinFunction: FunctionObject static ReturnedValue construct(Managed *m, CallData *) { m->engine()->current->throwTypeError(); - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); } static ReturnedValue call(Managed *that, CallData *callData); diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index 7880b1a69e..014d97a146 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -351,7 +351,7 @@ EvalFunction::EvalFunction(ExecutionContext *scope) : FunctionObject(scope, scope->engine->id_eval) { vtbl = &static_vtbl; - defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(1)); + defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1)); } ReturnedValue EvalFunction::evalCall(Value /*thisObject*/, Value *args, int argc, bool directCall) diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index bde9c23e6b..b0b5e38ea2 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -90,11 +90,11 @@ QV4::ReturnedValue QV4Include::resultValue(QV4::ExecutionEngine *v4, Status stat QV4::ScopedObject o(scope, v4->newObject()); QV4::ScopedString s(scope); QV4::ScopedValue v(scope); - o->put((s = v4->newString("OK")), (v = QV4::Value::fromInt32(Ok))); - o->put((s = v4->newString("LOADING")), (v = QV4::Value::fromInt32(Loading))); - o->put((s = v4->newString("NETWORK_ERROR")), (v = QV4::Value::fromInt32(NetworkError))); - o->put((s = v4->newString("EXCEPTION")), (v = QV4::Value::fromInt32(Exception))); - o->put((s = v4->newString("status")), (v = QV4::Value::fromInt32(status))); + o->put((s = v4->newString("OK")), (v = QV4::Primitive::fromInt32(Ok))); + o->put((s = v4->newString("LOADING")), (v = QV4::Primitive::fromInt32(Loading))); + o->put((s = v4->newString("NETWORK_ERROR")), (v = QV4::Primitive::fromInt32(NetworkError))); + o->put((s = v4->newString("EXCEPTION")), (v = QV4::Primitive::fromInt32(Exception))); + o->put((s = v4->newString("status")), (v = QV4::Primitive::fromInt32(status))); return o.asReturnedValue(); } @@ -158,15 +158,15 @@ void QV4Include::finished() try { script.parse(); script.run(); - resultObj->put(status, QV4::ScopedValue(scope, QV4::Value::fromInt32(Ok))); + resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Ok))); } catch (QV4::Exception &e) { e.accept(ctx); - resultObj->put(status, QV4::ScopedValue(scope, QV4::Value::fromInt32(Exception))); + resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Exception))); QV4::ScopedValue ex(scope, e.value()); resultObj->put(QV4::ScopedString(scope, v4->newString("exception")), ex); } } else { - resultObj->put(QV4::ScopedString(scope, v4->newString("status")), QV4::ScopedValue(scope, QV4::Value::fromInt32(NetworkError))); + resultObj->put(QV4::ScopedString(scope, v4->newString("status")), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(NetworkError))); } QV4::ScopedValue cb(scope, m_callbackFunction.value()); @@ -194,7 +194,7 @@ QV4::ReturnedValue QV4Include::method_include(QV4::SimpleCallContext *ctx) QUrl url(ctx->engine->resolvedUrl(ctx->callData->args[0].toQStringNoThrow())); - QV4::Value callbackFunction = QV4::Value::undefinedValue(); + QV4::Value callbackFunction = QV4::Primitive::undefinedValue(); if (ctx->callData->argc >= 2 && ctx->callData->args[1].asFunctionObject()) callbackFunction = ctx->callData->args[1]; diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index c6a0554d40..30313d2714 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -202,7 +202,7 @@ Value JsonParser::parse(QJsonParseError *error) lastError = QJsonParseError::IllegalValue; error->offset = json - head; error->error = lastError; - return Value::undefinedValue(); + return Primitive::undefinedValue(); } // some input left... @@ -210,7 +210,7 @@ Value JsonParser::parse(QJsonParseError *error) lastError = QJsonParseError::IllegalValue; error->offset = json - head; error->error = lastError; - return Value::undefinedValue(); + return Primitive::undefinedValue(); } END; @@ -356,7 +356,7 @@ bool JsonParser::parseValue(ValueRef val) if (*json++ == 'u' && *json++ == 'l' && *json++ == 'l') { - *val = Value::nullValue(); + *val = Primitive::nullValue(); DEBUG << "value: null"; END; return true; @@ -371,7 +371,7 @@ bool JsonParser::parseValue(ValueRef val) if (*json++ == 'r' && *json++ == 'u' && *json++ == 'e') { - *val = Value::fromBoolean(true); + *val = Primitive::fromBoolean(true); DEBUG << "value: true"; END; return true; @@ -387,7 +387,7 @@ bool JsonParser::parseValue(ValueRef val) *json++ == 'l' && *json++ == 's' && *json++ == 'e') { - *val = Value::fromBoolean(false); + *val = Primitive::fromBoolean(false); DEBUG << "value: false"; END; return true; @@ -495,7 +495,7 @@ bool JsonParser::parseNumber(Value *val) bool ok; int n = number.toInt(&ok); if (ok && n < (1<<25) && n > -(1<<25)) { - *val = Value::fromInt32(n); + *val = Primitive::fromInt32(n); END; return true; } @@ -510,7 +510,7 @@ bool JsonParser::parseNumber(Value *val) return false; } - * val = Value::fromDouble(d); + * val = Primitive::fromDouble(d); END; return true; diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 601b5b9e4b..d71d79e0ef 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -135,7 +135,7 @@ ReturnedValue Lookup::getterGeneric(QV4::Lookup *l, const ValueRef object) } } - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); } ReturnedValue Lookup::getter0(Lookup *l, const ValueRef object) @@ -182,7 +182,7 @@ ReturnedValue Lookup::getterAccessor0(Lookup *l, const ValueRef object) Scope scope(o->engine()); FunctionObject *getter = o->memberData[l->index].getter(); if (!getter) - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); ScopedCallData callData(scope, 0); callData->thisObject = *object; @@ -201,7 +201,7 @@ ReturnedValue Lookup::getterAccessor1(Lookup *l, const ValueRef object) Scope scope(o->engine()); FunctionObject *getter = o->prototype()->memberData[l->index].getter(); if (!getter) - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); ScopedCallData callData(scope, 0); callData->thisObject = *object; @@ -223,7 +223,7 @@ ReturnedValue Lookup::getterAccessor2(Lookup *l, const ValueRef object) Scope scope(o->engine()); FunctionObject *getter = o->memberData[l->index].getter(); if (!getter) - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); ScopedCallData callData(scope, 0); callData->thisObject = *object; @@ -269,7 +269,7 @@ ReturnedValue Lookup::primitiveGetterAccessor0(Lookup *l, const ValueRef object) Value res; FunctionObject *getter = o->memberData[l->index].getter(); if (!getter) - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); ScopedCallData callData(scope, 0); callData->thisObject = *object; @@ -290,7 +290,7 @@ ReturnedValue Lookup::primitiveGetterAccessor1(Lookup *l, const ValueRef object) Value res; FunctionObject *getter = o->prototype()->memberData[l->index].getter(); if (!getter) - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); ScopedCallData callData(scope, 0); callData->thisObject = *object; @@ -304,7 +304,7 @@ ReturnedValue Lookup::primitiveGetterAccessor1(Lookup *l, const ValueRef object) ReturnedValue Lookup::stringLengthGetter(Lookup *l, const ValueRef object) { if (String *s = object->asString()) - return Value::fromUInt32(s->length()).asReturnedValue(); + return Primitive::fromUInt32(s->length()).asReturnedValue(); l->getter = getterGeneric; return getterGeneric(l, object); @@ -384,10 +384,10 @@ ReturnedValue Lookup::globalGetterAccessor0(Lookup *l, ExecutionContext *ctx) Scope scope(o->engine()); FunctionObject *getter = o->memberData[l->index].getter(); if (!getter) - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); ScopedCallData callData(scope, 0); - callData->thisObject = Value::undefinedValue(); + callData->thisObject = Primitive::undefinedValue(); return getter->call(callData); } l->globalGetter = globalGetterGeneric; @@ -402,10 +402,10 @@ ReturnedValue Lookup::globalGetterAccessor1(Lookup *l, ExecutionContext *ctx) Scope scope(o->engine()); FunctionObject *getter = o->prototype()->memberData[l->index].getter(); if (!getter) - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); ScopedCallData callData(scope, 0); - callData->thisObject = Value::undefinedValue(); + callData->thisObject = Primitive::undefinedValue(); return getter->call(callData); } l->globalGetter = globalGetterGeneric; @@ -423,10 +423,10 @@ ReturnedValue Lookup::globalGetterAccessor2(Lookup *l, ExecutionContext *ctx) Scope scope(o->engine()); FunctionObject *getter = o->memberData[l->index].getter(); if (!getter) - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); ScopedCallData callData(scope, 0); - callData->thisObject = Value::undefinedValue(); + callData->thisObject = Primitive::undefinedValue(); return getter->call(callData); } } diff --git a/src/qml/jsruntime/qv4math_p.h b/src/qml/jsruntime/qv4math_p.h index a3a3715545..9ddb57eaaf 100644 --- a/src/qml/jsruntime/qv4math_p.h +++ b/src/qml/jsruntime/qv4math_p.h @@ -72,8 +72,8 @@ static inline QMLJS_READONLY Value add_int32(int a, int b) : "cc" ); if (!overflow) - return Value::fromInt32(aa); - return Value::fromDouble((double)a + (double)b); + return Primitive::fromInt32(aa); + return Primitive::fromDouble((double)a + (double)b); } static inline QMLJS_READONLY Value sub_int32(int a, int b) @@ -88,8 +88,8 @@ static inline QMLJS_READONLY Value sub_int32(int a, int b) : "cc" ); if (!overflow) - return Value::fromInt32(aa); - return Value::fromDouble((double)a - (double)b); + return Primitive::fromInt32(aa); + return Primitive::fromDouble((double)a - (double)b); } static inline QMLJS_READONLY Value mul_int32(int a, int b) @@ -104,8 +104,8 @@ static inline QMLJS_READONLY Value mul_int32(int a, int b) : "cc" ); if (!overflow) - return Value::fromInt32(aa); - return Value::fromDouble((double)a * (double)b); + return Primitive::fromInt32(aa); + return Primitive::fromDouble((double)a * (double)b); } #else @@ -114,24 +114,24 @@ static inline QMLJS_READONLY Value add_int32(int a, int b) { qint64 result = a + b; if (result > INT_MAX || result < INT_MIN) - return Value::fromDouble(result); - return Value::fromInt32(static_cast<int>(result)); + return Primitive::fromDouble(result); + return Primitive::fromInt32(static_cast<int>(result)); } static inline QMLJS_READONLY Value sub_int32(int a, int b) { qint64 result = a - b; if (result > INT_MAX || result < INT_MIN) - return Value::fromDouble(result); - return Value::fromInt32(static_cast<int>(result)); + return Primitive::fromDouble(result); + return Primitive::fromInt32(static_cast<int>(result)); } static inline QMLJS_READONLY Value mul_int32(int a, int b) { qint64 result = a * b; if (result > INT_MAX || result < INT_MIN) - return Value::fromDouble(result); - return Value::fromInt32(static_cast<int>(result)); + return Primitive::fromDouble(result); + return Primitive::fromInt32(static_cast<int>(result)); } #endif // defined(QMLJS_INLINE_MATH) diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp index 57a84d008a..fcff9e4aca 100644 --- a/src/qml/jsruntime/qv4mathobject.cpp +++ b/src/qml/jsruntime/qv4mathobject.cpp @@ -55,14 +55,14 @@ MathObject::MathObject(ExecutionEngine *engine) { type = Type_MathObject; - defineReadonlyProperty(QStringLiteral("E"), Value::fromDouble(::exp(1.0))); - defineReadonlyProperty(QStringLiteral("LN2"), Value::fromDouble(::log(2.0))); - defineReadonlyProperty(QStringLiteral("LN10"), Value::fromDouble(::log(10.0))); - defineReadonlyProperty(QStringLiteral("LOG2E"), Value::fromDouble(1.0/::log(2.0))); - defineReadonlyProperty(QStringLiteral("LOG10E"), Value::fromDouble(1.0/::log(10.0))); - defineReadonlyProperty(QStringLiteral("PI"), Value::fromDouble(qt_PI)); - defineReadonlyProperty(QStringLiteral("SQRT1_2"), Value::fromDouble(::sqrt(0.5))); - defineReadonlyProperty(QStringLiteral("SQRT2"), Value::fromDouble(::sqrt(2.0))); + defineReadonlyProperty(QStringLiteral("E"), Primitive::fromDouble(::exp(1.0))); + defineReadonlyProperty(QStringLiteral("LN2"), Primitive::fromDouble(::log(2.0))); + defineReadonlyProperty(QStringLiteral("LN10"), Primitive::fromDouble(::log(10.0))); + defineReadonlyProperty(QStringLiteral("LOG2E"), Primitive::fromDouble(1.0/::log(2.0))); + defineReadonlyProperty(QStringLiteral("LOG10E"), Primitive::fromDouble(1.0/::log(10.0))); + defineReadonlyProperty(QStringLiteral("PI"), Primitive::fromDouble(qt_PI)); + defineReadonlyProperty(QStringLiteral("SQRT1_2"), Primitive::fromDouble(::sqrt(0.5))); + defineReadonlyProperty(QStringLiteral("SQRT2"), Primitive::fromDouble(::sqrt(2.0))); defineDefaultProperty(QStringLiteral("abs"), method_abs, 1); defineDefaultProperty(QStringLiteral("acos"), method_acos, 1); diff --git a/src/qml/jsruntime/qv4mm.cpp b/src/qml/jsruntime/qv4mm.cpp index d82968345b..54fee80d72 100644 --- a/src/qml/jsruntime/qv4mm.cpp +++ b/src/qml/jsruntime/qv4mm.cpp @@ -413,7 +413,7 @@ std::size_t MemoryManager::sweep(bool lastSweep) } if (Managed *m = weak->value.asManaged()) { if (!m->markBit) { - weak->value = Value::undefinedValue(); + weak->value = Primitive::undefinedValue(); PersistentValuePrivate *n = weak->next; weak->removeFromList(); weak = n; @@ -555,7 +555,7 @@ MemoryManager::~MemoryManager() PersistentValuePrivate *persistent = m_persistentValues; while (persistent) { PersistentValuePrivate *n = persistent->next; - persistent->value = Value::undefinedValue(); + persistent->value = Primitive::undefinedValue(); persistent->engine = 0; persistent->prev = 0; persistent->next = 0; diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp index bc5e225f9b..c8169c0706 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -60,31 +60,31 @@ ReturnedValue NumberCtor::construct(Managed *m, CallData *callData) { Scope scope(m->engine()); double dbl = callData->argc ? callData->args[0].toNumber() : 0.; - ScopedValue d(scope, QV4::Value::fromDouble(dbl)); + ScopedValue d(scope, QV4::Primitive::fromDouble(dbl)); return Encode(m->engine()->newNumberObject(d)); } ReturnedValue NumberCtor::call(Managed *, CallData *callData) { double dbl = callData->argc ? callData->args[0].toNumber() : 0.; - return Value::fromDouble(dbl).asReturnedValue(); + return Primitive::fromDouble(dbl).asReturnedValue(); } void NumberPrototype::init(ExecutionEngine *engine, const Value &ctor) { ctor.objectValue()->defineReadonlyProperty(engine->id_prototype, Value::fromObject(this)); - ctor.objectValue()->defineReadonlyProperty(engine->id_length, Value::fromInt32(1)); + ctor.objectValue()->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1)); - ctor.objectValue()->defineReadonlyProperty(QStringLiteral("NaN"), Value::fromDouble(qSNaN())); - ctor.objectValue()->defineReadonlyProperty(QStringLiteral("NEGATIVE_INFINITY"), Value::fromDouble(-qInf())); - ctor.objectValue()->defineReadonlyProperty(QStringLiteral("POSITIVE_INFINITY"), Value::fromDouble(qInf())); - ctor.objectValue()->defineReadonlyProperty(QStringLiteral("MAX_VALUE"), Value::fromDouble(1.7976931348623158e+308)); + ctor.objectValue()->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(qSNaN())); + ctor.objectValue()->defineReadonlyProperty(QStringLiteral("NEGATIVE_INFINITY"), Primitive::fromDouble(-qInf())); + ctor.objectValue()->defineReadonlyProperty(QStringLiteral("POSITIVE_INFINITY"), Primitive::fromDouble(qInf())); + ctor.objectValue()->defineReadonlyProperty(QStringLiteral("MAX_VALUE"), Primitive::fromDouble(1.7976931348623158e+308)); #ifdef __INTEL_COMPILER # pragma warning( push ) # pragma warning(disable: 239) #endif - ctor.objectValue()->defineReadonlyProperty(QStringLiteral("MIN_VALUE"), Value::fromDouble(5e-324)); + ctor.objectValue()->defineReadonlyProperty(QStringLiteral("MIN_VALUE"), Primitive::fromDouble(5e-324)); #ifdef __INTEL_COMPILER # pragma warning( pop ) #endif @@ -157,7 +157,7 @@ ReturnedValue NumberPrototype::method_toString(SimpleCallContext *ctx) } } - String *str = Value::fromDouble(num).toString(ctx); + String *str = Primitive::fromDouble(num).toString(ctx); return Value::fromString(str).asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 78b963e12d..e0c8974440 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -135,7 +135,7 @@ ReturnedValue Object::getValue(const ValueRef thisObject, const Property *p, Pro return p->value.asReturnedValue(); FunctionObject *getter = p->getter(); if (!getter) - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); Scope scope(getter->engine()); ScopedCallData callData(scope, 0); @@ -235,7 +235,7 @@ void Object::defineDefaultProperty(const QString &name, ReturnedValue (*code)(Si Scope scope(e); ScopedString s(scope, e->newIdentifier(name)); Scoped<FunctionObject> function(scope, e->newBuiltinFunction(e->rootContext, s, code)); - function->defineReadonlyProperty(e->id_length, Value::fromInt32(argumentCount)); + function->defineReadonlyProperty(e->id_length, Primitive::fromInt32(argumentCount)); defineDefaultProperty(s, function.asValue()); } @@ -244,7 +244,7 @@ void Object::defineDefaultProperty(const StringRef name, ReturnedValue (*code)(S ExecutionEngine *e = engine(); Scope scope(e); Scoped<FunctionObject> function(scope, e->newBuiltinFunction(e->rootContext, name, code)); - function->defineReadonlyProperty(e->id_length, Value::fromInt32(argumentCount)); + function->defineReadonlyProperty(e->id_length, Primitive::fromInt32(argumentCount)); defineDefaultProperty(name, function.asValue()); } @@ -538,7 +538,7 @@ ReturnedValue Object::getLookup(Managed *m, Lookup *l) return o->getValue(p, attrs); } } - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); } void Object::setLookup(Managed *m, Lookup *l, const ValueRef value) @@ -710,7 +710,7 @@ ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty) if (hasProperty) *hasProperty = false; - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); } @@ -902,7 +902,7 @@ bool Object::internalDeleteIndexedProperty(uint index) return true; if (!arrayAttributes || arrayAttributes[pidx].isConfigurable()) { - arrayData[pidx].value = Value::undefinedValue(); + arrayData[pidx].value = Primitive::undefinedValue(); if (!arrayAttributes) ensureArrayAttributes(); arrayAttributes[pidx].clear(); @@ -1061,7 +1061,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, Property *current, con // 9c cattrs.setType(PropertyAttributes::Data); cattrs.setWritable(false); - current->value = Value::undefinedValue(); + current->value = Primitive::undefinedValue(); } } else if (cattrs.isData() && attrs.isData()) { // clause 10 if (!cattrs.isConfigurable() && !cattrs.isWritable()) { @@ -1293,12 +1293,12 @@ void Object::initSparse() arrayAlloc += off; int o = off; for (int i = 0; i < o - 1; ++i) { - arrayData[i].value = Value::fromInt32(i + 1); + arrayData[i].value = Primitive::fromInt32(i + 1); } - arrayData[o - 1].value = Value::fromInt32(arrayDataLen + off); + arrayData[o - 1].value = Primitive::fromInt32(arrayDataLen + off); } for (int i = arrayDataLen + off; i < arrayAlloc; ++i) { - arrayData[i].value = Value::fromInt32(i + 1); + arrayData[i].value = Primitive::fromInt32(i + 1); } } } @@ -1327,7 +1327,7 @@ void Object::arrayReserve(uint n) if (sparseArray) { for (uint i = arrayFreeList; i < arrayAlloc; ++i) { arrayData[i].value = Value::emptyValue(); - arrayData[i].value = Value::fromInt32(i + 1); + arrayData[i].value = Primitive::fromInt32(i + 1); } } else { arrayOffset = 0; @@ -1460,7 +1460,7 @@ ArrayObject::ArrayObject(ExecutionEngine *engine, const QStringList &list) void ArrayObject::init(ExecutionEngine *engine) { type = Type_ArrayObject; - memberData[LengthPropertyIndex].value = Value::fromInt32(0); + memberData[LengthPropertyIndex].value = Primitive::fromInt32(0); } QStringList ArrayObject::toQStringList() const diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index ad06ffb552..3f483b03d9 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -353,14 +353,14 @@ struct BooleanObject: Object { Value value; BooleanObject(ExecutionEngine *engine, const ValueRef value): Object(engine->booleanClass), value(*value) { type = Type_BooleanObject; } protected: - BooleanObject(InternalClass *ic): Object(ic), value(Value::fromBoolean(false)) { type = Type_BooleanObject; } + BooleanObject(InternalClass *ic): Object(ic), value(Primitive::fromBoolean(false)) { type = Type_BooleanObject; } }; struct NumberObject: Object { Value value; NumberObject(ExecutionEngine *engine, const ValueRef value): Object(engine->numberClass), value(*value) { type = Type_NumberObject; } protected: - NumberObject(InternalClass *ic): Object(ic), value(Value::fromInt32(0)) { type = Type_NumberObject; } + NumberObject(InternalClass *ic): Object(ic), value(Primitive::fromInt32(0)) { type = Type_NumberObject; } }; struct ArrayObject: Object { @@ -395,7 +395,7 @@ inline void Object::setArrayLengthUnchecked(uint l) if (isArrayObject()) { // length is always the first property of an array Property &lengthProperty = memberData[ArrayObject::LengthPropertyIndex]; - lengthProperty.value = Value::fromUInt32(l); + lengthProperty.value = Primitive::fromUInt32(l); } } diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp index a9c9e817f7..1c12704545 100644 --- a/src/qml/jsruntime/qv4objectiterator.cpp +++ b/src/qml/jsruntime/qv4objectiterator.cpp @@ -53,7 +53,7 @@ ObjectIterator::ObjectIterator(Object *o, uint flags) , memberIndex(0) , flags(flags) { - tmpDynamicProperty.value = Value::undefinedValue(); + tmpDynamicProperty.value = Primitive::undefinedValue(); } Property *ObjectIterator::next(String **name, uint *index, PropertyAttributes *attrs) diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 96426cabfb..bf16073f61 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -106,7 +106,7 @@ void ObjectPrototype::init(ExecutionEngine *v4, const Value &ctor) Scope scope(v4); ctor.objectValue()->defineReadonlyProperty(v4->id_prototype, Value::fromObject(this)); - ctor.objectValue()->defineReadonlyProperty(v4->id_length, Value::fromInt32(1)); + ctor.objectValue()->defineReadonlyProperty(v4->id_length, Primitive::fromInt32(1)); ctor.objectValue()->defineDefaultProperty(QStringLiteral("getPrototypeOf"), method_getPrototypeOf, 1); ctor.objectValue()->defineDefaultProperty(QStringLiteral("getOwnPropertyDescriptor"), method_getOwnPropertyDescriptor, 2); ctor.objectValue()->defineDefaultProperty(QStringLiteral("getOwnPropertyNames"), method_getOwnPropertyNames, 1); @@ -586,7 +586,7 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, Value v, Prope ctx->throwTypeError(); attrs->setWritable(Value::fromReturnedValue(o->get(ctx->engine->id_writable)).toBoolean()); // writable forces it to be a data descriptor - desc->value = Value::undefinedValue(); + desc->value = Primitive::undefinedValue(); } if (o->__hasProperty__(ctx->engine->id_value)) { @@ -618,21 +618,21 @@ ReturnedValue ObjectPrototype::fromPropertyDescriptor(ExecutionContext *ctx, con pd.value = desc->value; s = engine->newString(QStringLiteral("value")); o->__defineOwnProperty__(ctx, s, pd, Attr_Data); - pd.value = Value::fromBoolean(attrs.isWritable()); + pd.value = Primitive::fromBoolean(attrs.isWritable()); s = engine->newString(QStringLiteral("writable")); o->__defineOwnProperty__(ctx, s, pd, Attr_Data); } else { - pd.value = desc->getter() ? Value::fromObject(desc->getter()) : Value::undefinedValue(); + pd.value = desc->getter() ? Value::fromObject(desc->getter()) : Primitive::undefinedValue(); s = engine->newString(QStringLiteral("get")); o->__defineOwnProperty__(ctx, s, pd, Attr_Data); - pd.value = desc->setter() ? Value::fromObject(desc->setter()) : Value::undefinedValue(); + pd.value = desc->setter() ? Value::fromObject(desc->setter()) : Primitive::undefinedValue(); s = engine->newString(QStringLiteral("set")); o->__defineOwnProperty__(ctx, s, pd, Attr_Data); } - pd.value = Value::fromBoolean(attrs.isEnumerable()); + pd.value = Primitive::fromBoolean(attrs.isEnumerable()); s = engine->newString(QStringLiteral("enumerable")); o->__defineOwnProperty__(ctx, s, pd, Attr_Data); - pd.value = Value::fromBoolean(attrs.isConfigurable()); + pd.value = Primitive::fromBoolean(attrs.isConfigurable()); s = engine->newString(QStringLiteral("configurable")); o->__defineOwnProperty__(ctx, s, pd, Attr_Data); diff --git a/src/qml/jsruntime/qv4property_p.h b/src/qml/jsruntime/qv4property_p.h index 024ad3c720..258a190602 100644 --- a/src/qml/jsruntime/qv4property_p.h +++ b/src/qml/jsruntime/qv4property_p.h @@ -63,7 +63,7 @@ struct Property { // Section 8.10 inline void fullyPopulated(PropertyAttributes *attrs) { if (!attrs->hasType()) { - value = Value::undefinedValue(); + value = Primitive::undefinedValue(); } if (attrs->type() == PropertyAttributes::Accessor) { attrs->clearWritable(); diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 876bda3163..a1b8012a13 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -850,8 +850,8 @@ ReturnedValue QObjectWrapper::method_disconnect(SimpleCallContext *ctx) if (signalIndex < 0 || signalObject->metaObject()->method(signalIndex).methodType() != QMetaMethod::Signal) V4THROW_ERROR("Function.prototype.disconnect: this object is not a signal"); - QV4::Value functionValue = QV4::Value::undefinedValue(); - QV4::Value functionThisValue = QV4::Value::undefinedValue(); + QV4::Value functionValue = QV4::Primitive::undefinedValue(); + QV4::Value functionThisValue = QV4::Primitive::undefinedValue(); if (ctx->callData->argc == 1) { functionValue = ctx->callData->args[0]; @@ -1745,7 +1745,7 @@ ReturnedValue QObjectMethod::callInternal(CallData *callData) } if (method.isV4Function()) { - QV4::ScopedValue rv(scope, QV4::Value::undefinedValue()); + QV4::ScopedValue rv(scope, QV4::Primitive::undefinedValue()); QV4::ScopedValue qmlGlobal(scope, m_qmlGlobal.value()); QQmlV4Function func(callData, rv, qmlGlobal, diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index ea2dccccbc..ce0c206a18 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -126,7 +126,7 @@ struct QObjectMethod : public QV4::FunctionObject enum { DestroyMethod = -1, ToStringMethod = -2 }; - static Value create(QV4::ExecutionContext *scope, QObject *object, int index, const Value &qmlGlobal = Value::undefinedValue()); + static Value create(QV4::ExecutionContext *scope, QObject *object, int index, const Value &qmlGlobal = Primitive::undefinedValue()); int methodIndex() const { return m_index; } QObject *object() const { return m_object.data(); } diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp index 9534162ecd..3d9572eb5a 100644 --- a/src/qml/jsruntime/qv4regexp.cpp +++ b/src/qml/jsruntime/qv4regexp.cpp @@ -138,12 +138,12 @@ void RegExp::markObjects(Managed *that) ReturnedValue RegExp::get(Managed *, const StringRef, bool *) { - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); } ReturnedValue RegExp::getIndexed(Managed *m, uint index, bool *hasProperty) { - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); } void RegExp::put(Managed *m, const StringRef name, const ValueRef value) diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index fee66d9d09..d9e8b2419b 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -147,7 +147,7 @@ void RegExpObject::init(ExecutionEngine *engine) ScopedString lastIndex(scope, engine->newIdentifier(QStringLiteral("lastIndex"))); Property *lastIndexProperty = insertMember(lastIndex, Attr_NotEnumerable|Attr_NotConfigurable); - lastIndexProperty->value = Value::fromInt32(0); + lastIndexProperty->value = Primitive::fromInt32(0); if (!this->value) return; @@ -160,9 +160,9 @@ void RegExpObject::init(ExecutionEngine *engine) } defineReadonlyProperty(QStringLiteral("source"), Value::fromString(engine->newString(p))); - defineReadonlyProperty(QStringLiteral("global"), Value::fromBoolean(global)); - defineReadonlyProperty(QStringLiteral("ignoreCase"), Value::fromBoolean(this->value->ignoreCase())); - defineReadonlyProperty(QStringLiteral("multiline"), Value::fromBoolean(this->value->multiLine())); + defineReadonlyProperty(QStringLiteral("global"), Primitive::fromBoolean(global)); + defineReadonlyProperty(QStringLiteral("ignoreCase"), Primitive::fromBoolean(this->value->ignoreCase())); + defineReadonlyProperty(QStringLiteral("multiline"), Primitive::fromBoolean(this->value->multiLine())); } @@ -240,8 +240,8 @@ ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData) ExecutionContext *ctx = m->engine()->current; Scope scope(ctx); - ScopedValue r(scope, callData->argc > 0 ? callData->args[0] : Value::undefinedValue()); - ScopedValue f(scope, callData->argc > 1 ? callData->args[1] : Value::undefinedValue()); + ScopedValue r(scope, callData->argc > 0 ? callData->args[0] : Primitive::undefinedValue()); + ScopedValue f(scope, callData->argc > 1 ? callData->args[1] : Primitive::undefinedValue()); if (RegExpObject *re = r->as<RegExpObject>()) { if (!f->isUndefined()) ctx->throwTypeError(); @@ -292,7 +292,7 @@ ReturnedValue RegExpCtor::call(Managed *that, CallData *callData) void RegExpPrototype::init(ExecutionEngine *engine, const Value &ctor) { ctor.objectValue()->defineReadonlyProperty(engine->id_prototype, Value::fromObject(this)); - ctor.objectValue()->defineReadonlyProperty(engine->id_length, Value::fromInt32(2)); + ctor.objectValue()->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(2)); defineDefaultProperty(QStringLiteral("constructor"), ctor); defineDefaultProperty(QStringLiteral("exec"), method_exec, 1); defineDefaultProperty(QStringLiteral("test"), method_test, 1); @@ -313,14 +313,14 @@ ReturnedValue RegExpPrototype::method_exec(SimpleCallContext *ctx) int offset = r->global ? r->lastIndexProperty(ctx)->value.toInt32() : 0; if (offset < 0 || offset > s.length()) { - r->lastIndexProperty(ctx)->value = Value::fromInt32(0); + r->lastIndexProperty(ctx)->value = Primitive::fromInt32(0); return Encode::null(); } uint* matchOffsets = (uint*)alloca(r->value->captureCount() * 2 * sizeof(uint)); int result = r->value->match(s, offset, matchOffsets); if (result == -1) { - r->lastIndexProperty(ctx)->value = Value::fromInt32(0); + r->lastIndexProperty(ctx)->value = Primitive::fromInt32(0); return Encode::null(); } @@ -331,16 +331,16 @@ ReturnedValue RegExpPrototype::method_exec(SimpleCallContext *ctx) for (int i = 0; i < len; ++i) { int start = matchOffsets[i * 2]; int end = matchOffsets[i * 2 + 1]; - array->arrayData[i].value = (start != -1 && end != -1) ? Value::fromString(ctx, s.mid(start, end - start)) : Value::undefinedValue(); + array->arrayData[i].value = (start != -1 && end != -1) ? Value::fromString(ctx, s.mid(start, end - start)) : Primitive::undefinedValue(); array->arrayDataLen = i + 1; } array->setArrayLengthUnchecked(len); - array->memberData[Index_ArrayIndex].value = Value::fromInt32(result); + array->memberData[Index_ArrayIndex].value = Primitive::fromInt32(result); array->memberData[Index_ArrayInput].value = arg; if (r->global) - r->lastIndexProperty(ctx)->value = Value::fromInt32(matchOffsets[1]); + r->lastIndexProperty(ctx)->value = Primitive::fromInt32(matchOffsets[1]); return array.asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 687f083a80..ec164500cc 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -255,7 +255,7 @@ ReturnedValue __qmljs_delete_subscript(ExecutionContext *ctx, const ValueRef bas if (o) { uint n = index->asArrayIndex(); if (n < UINT_MAX) { - return Value::fromBoolean(o->deleteIndexedProperty(n)).asReturnedValue(); + return Primitive::fromBoolean(o->deleteIndexedProperty(n)).asReturnedValue(); } } @@ -291,7 +291,7 @@ QV4::ReturnedValue __qmljs_add_helper(ExecutionContext *ctx, const ValueRef left } double x = __qmljs_to_number(pleft); double y = __qmljs_to_number(pright); - return Value::fromDouble(x + y).asReturnedValue(); + return Primitive::fromDouble(x + y).asReturnedValue(); } QV4::ReturnedValue __qmljs_instanceof(ExecutionContext *ctx, const ValueRef left, const ValueRef right) @@ -301,7 +301,7 @@ QV4::ReturnedValue __qmljs_instanceof(ExecutionContext *ctx, const ValueRef left ctx->throwTypeError(); bool r = o->hasInstance(left); - return Value::fromBoolean(r).asReturnedValue(); + return Primitive::fromBoolean(r).asReturnedValue(); } QV4::ReturnedValue __qmljs_in(ExecutionContext *ctx, const ValueRef left, const ValueRef right) @@ -311,7 +311,7 @@ QV4::ReturnedValue __qmljs_in(ExecutionContext *ctx, const ValueRef left, const Scope scope(ctx); ScopedString s(scope, left->toString(ctx)); bool r = right->objectValue()->__hasProperty__(s); - return Value::fromBoolean(r).asReturnedValue(); + return Primitive::fromBoolean(r).asReturnedValue(); } static void inplaceBitOp(ExecutionContext *ctx, const StringRef name, const ValueRef value, BinOp op) @@ -602,7 +602,7 @@ ReturnedValue __qmljs_object_default_value(Object *object, int typeHint) } ctx->throwTypeError(); - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); } Bool __qmljs_to_boolean(const ValueRef value) @@ -675,7 +675,7 @@ ReturnedValue __qmljs_get_element(ExecutionContext *ctx, const ValueRef object, if (idx < UINT_MAX) { if (String *str = object->asString()) { if (idx >= (uint)str->toQString().length()) { - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); } const QString s = str->toQString().mid(idx, 1); return Value::fromString(ctx, s).asReturnedValue(); @@ -814,10 +814,10 @@ uint __qmljs_equal_helper(const ValueRef x, const ValueRef y) double dx = __qmljs_to_number(x); return dx == y->asDouble(); } else if (x->isBoolean()) { - Value nx = Value::fromDouble((double) x->booleanValue()); + Value nx = Primitive::fromDouble((double) x->booleanValue()); return __qmljs_cmp_eq(ValueRef(&nx), y); } else if (y->isBoolean()) { - Value ny = Value::fromDouble((double) y->booleanValue()); + Value ny = Primitive::fromDouble((double) y->booleanValue()); return __qmljs_cmp_eq(x, ValueRef(&ny)); } else if ((x->isNumber() || x->isString()) && y->isObject()) { Scope scope(y->objectValue()->engine()); @@ -1175,7 +1175,7 @@ void __qmljs_builtin_define_property(ExecutionContext *ctx, const ValueRef objec uint idx = name->asArrayIndex(); Property *pd = (idx != UINT_MAX) ? o->arrayInsert(idx) : o->insertMember(name, Attr_Data); - pd->value = val ? *val : Value::undefinedValue(); + pd->value = val ? *val : Primitive::undefinedValue(); } ReturnedValue __qmljs_builtin_define_array(ExecutionContext *ctx, Value *values, uint length) @@ -1192,7 +1192,7 @@ ReturnedValue __qmljs_builtin_define_array(ExecutionContext *ctx, Value *values, for (uint i = 0; i < length; ++i) { if (values[i].isEmpty()) { a->ensureArrayAttributes(); - pd->value = Value::undefinedValue(); + pd->value = Primitive::undefinedValue(); a->arrayAttributes[i].clear(); } else { pd->value = values[i]; @@ -1249,10 +1249,10 @@ QV4::ReturnedValue __qmljs_increment(const QV4::ValueRef value) TRACE1(value); if (value->isInteger()) - return Value::fromInt32(value->integerValue() + 1).asReturnedValue(); + return Primitive::fromInt32(value->integerValue() + 1).asReturnedValue(); else { double d = value->toNumber(); - return Value::fromDouble(d + 1).asReturnedValue(); + return Primitive::fromDouble(d + 1).asReturnedValue(); } } @@ -1261,10 +1261,10 @@ QV4::ReturnedValue __qmljs_decrement(const QV4::ValueRef value) TRACE1(value); if (value->isInteger()) - return Value::fromInt32(value->integerValue() - 1).asReturnedValue(); + return Primitive::fromInt32(value->integerValue() - 1).asReturnedValue(); else { double d = value->toNumber(); - return Value::fromDouble(d - 1).asReturnedValue(); + return Primitive::fromDouble(d - 1).asReturnedValue(); } } diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index 6b3325898c..a9e8e01232 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -311,10 +311,10 @@ inline QV4::ReturnedValue __qmljs_uminus(const QV4::ValueRef value) // +0 != -0, so we need to convert to double when negating 0 if (value->isInteger() && value->integerValue()) - return QV4::Value::fromInt32(-value->integerValue()).asReturnedValue(); + return QV4::Primitive::fromInt32(-value->integerValue()).asReturnedValue(); else { double n = __qmljs_to_number(value); - return QV4::Value::fromDouble(-n).asReturnedValue(); + return QV4::Primitive::fromDouble(-n).asReturnedValue(); } } @@ -345,11 +345,11 @@ inline ReturnedValue __qmljs_bit_or(const QV4::ValueRef left, const QV4::ValueRe TRACE2(left, right); if (QV4::Value::integerCompatible(*left, *right)) - return QV4::Value::fromInt32(left->integerValue() | right->integerValue()).asReturnedValue(); + return QV4::Primitive::fromInt32(left->integerValue() | right->integerValue()).asReturnedValue(); int lval = left->toInt32(); int rval = right->toInt32(); - return QV4::Value::fromInt32(lval | rval).asReturnedValue(); + return QV4::Primitive::fromInt32(lval | rval).asReturnedValue(); } inline ReturnedValue __qmljs_bit_xor(const QV4::ValueRef left, const QV4::ValueRef right) @@ -357,11 +357,11 @@ inline ReturnedValue __qmljs_bit_xor(const QV4::ValueRef left, const QV4::ValueR TRACE2(left, right); if (QV4::Value::integerCompatible(*left, *right)) - return QV4::Value::fromInt32(left->integerValue() ^ right->integerValue()).asReturnedValue(); + return QV4::Primitive::fromInt32(left->integerValue() ^ right->integerValue()).asReturnedValue(); int lval = left->toInt32(); int rval = right->toInt32(); - return QV4::Value::fromInt32(lval ^ rval).asReturnedValue(); + return QV4::Primitive::fromInt32(lval ^ rval).asReturnedValue(); } inline ReturnedValue __qmljs_bit_and(const QV4::ValueRef left, const QV4::ValueRef right) @@ -369,11 +369,11 @@ inline ReturnedValue __qmljs_bit_and(const QV4::ValueRef left, const QV4::ValueR TRACE2(left, right); if (QV4::Value::integerCompatible(*left, *right)) - return QV4::Value::fromInt32(left->integerValue() & right->integerValue()).asReturnedValue(); + return QV4::Primitive::fromInt32(left->integerValue() & right->integerValue()).asReturnedValue(); int lval = left->toInt32(); int rval = right->toInt32(); - return QV4::Value::fromInt32(lval & rval).asReturnedValue(); + return QV4::Primitive::fromInt32(lval & rval).asReturnedValue(); } inline QV4::ReturnedValue __qmljs_add(QV4::ExecutionContext *ctx, const QV4::ValueRef left, const QV4::ValueRef right) @@ -384,7 +384,7 @@ inline QV4::ReturnedValue __qmljs_add(QV4::ExecutionContext *ctx, const QV4::Val return add_int32(left->integerValue(), right->integerValue()).asReturnedValue(); if (QV4::Value::bothDouble(*left, *right)) - return QV4::Value::fromDouble(left->doubleValue() + right->doubleValue()).asReturnedValue(); + return QV4::Primitive::fromDouble(left->doubleValue() + right->doubleValue()).asReturnedValue(); return __qmljs_add_helper(ctx, left, right); } @@ -398,7 +398,7 @@ inline QV4::ReturnedValue __qmljs_sub(const QV4::ValueRef left, const QV4::Value double lval = __qmljs_to_number(left); double rval = __qmljs_to_number(right); - return QV4::Value::fromDouble(lval - rval).asReturnedValue(); + return QV4::Primitive::fromDouble(lval - rval).asReturnedValue(); } inline QV4::ReturnedValue __qmljs_mul(const QV4::ValueRef left, const QV4::ValueRef right) @@ -410,7 +410,7 @@ inline QV4::ReturnedValue __qmljs_mul(const QV4::ValueRef left, const QV4::Value double lval = __qmljs_to_number(left); double rval = __qmljs_to_number(right); - return QV4::Value::fromDouble(lval * rval).asReturnedValue(); + return QV4::Primitive::fromDouble(lval * rval).asReturnedValue(); } inline QV4::ReturnedValue __qmljs_div(const QV4::ValueRef left, const QV4::ValueRef right) @@ -419,7 +419,7 @@ inline QV4::ReturnedValue __qmljs_div(const QV4::ValueRef left, const QV4::Value double lval = __qmljs_to_number(left); double rval = __qmljs_to_number(right); - return QV4::Value::fromDouble(lval / rval).asReturnedValue(); + return QV4::Primitive::fromDouble(lval / rval).asReturnedValue(); } inline QV4::ReturnedValue __qmljs_mod(const QV4::ValueRef left, const QV4::ValueRef right) @@ -429,12 +429,12 @@ inline QV4::ReturnedValue __qmljs_mod(const QV4::ValueRef left, const QV4::Value if (QV4::Value::integerCompatible(*left, *right) && right->integerValue() != 0) { int intRes = left->integerValue() % right->integerValue(); if (intRes != 0 || left->integerValue() >= 0) - return QV4::Value::fromInt32(intRes).asReturnedValue(); + return QV4::Primitive::fromInt32(intRes).asReturnedValue(); } double lval = __qmljs_to_number(left); double rval = __qmljs_to_number(right); - return QV4::Value::fromDouble(std::fmod(lval, rval)).asReturnedValue(); + return QV4::Primitive::fromDouble(std::fmod(lval, rval)).asReturnedValue(); } inline QV4::ReturnedValue __qmljs_shl(const QV4::ValueRef left, const QV4::ValueRef right) @@ -442,11 +442,11 @@ inline QV4::ReturnedValue __qmljs_shl(const QV4::ValueRef left, const QV4::Value TRACE2(left, right); if (QV4::Value::integerCompatible(*left, *right)) - return QV4::Value::fromInt32(left->integerValue() << ((uint(right->integerValue()) & 0x1f))).asReturnedValue(); + return QV4::Primitive::fromInt32(left->integerValue() << ((uint(right->integerValue()) & 0x1f))).asReturnedValue(); int lval = left->toInt32(); unsigned rval = right->toUInt32() & 0x1f; - return QV4::Value::fromInt32(lval << rval).asReturnedValue(); + return QV4::Primitive::fromInt32(lval << rval).asReturnedValue(); } inline QV4::ReturnedValue __qmljs_shr(const QV4::ValueRef left, const QV4::ValueRef right) @@ -454,11 +454,11 @@ inline QV4::ReturnedValue __qmljs_shr(const QV4::ValueRef left, const QV4::Value TRACE2(left, right); if (QV4::Value::integerCompatible(*left, *right)) - return QV4::Value::fromInt32(left->integerValue() >> ((uint(right->integerValue()) & 0x1f))).asReturnedValue(); + return QV4::Primitive::fromInt32(left->integerValue() >> ((uint(right->integerValue()) & 0x1f))).asReturnedValue(); int lval = left->toInt32(); unsigned rval = right->toUInt32() & 0x1f; - return QV4::Value::fromInt32(lval >> rval).asReturnedValue(); + return QV4::Primitive::fromInt32(lval >> rval).asReturnedValue(); } inline QV4::ReturnedValue __qmljs_ushr(const QV4::ValueRef left, const QV4::ValueRef right) @@ -475,51 +475,51 @@ inline QV4::ReturnedValue __qmljs_ushr(const QV4::ValueRef left, const QV4::Valu } if (res > INT_MAX) - return QV4::Value::fromDouble(res).asReturnedValue(); + return QV4::Primitive::fromDouble(res).asReturnedValue(); else - return QV4::Value::fromInt32(res).asReturnedValue(); + return QV4::Primitive::fromInt32(res).asReturnedValue(); } inline QV4::ReturnedValue __qmljs_gt(const QV4::ValueRef left, const QV4::ValueRef right) { TRACE2(left, right); - return QV4::Value::fromBoolean(__qmljs_cmp_gt(left, right)).asReturnedValue(); + return QV4::Primitive::fromBoolean(__qmljs_cmp_gt(left, right)).asReturnedValue(); } inline QV4::ReturnedValue __qmljs_lt(const QV4::ValueRef left, const QV4::ValueRef right) { TRACE2(left, right); - return QV4::Value::fromBoolean(__qmljs_cmp_lt(left, right)).asReturnedValue(); + return QV4::Primitive::fromBoolean(__qmljs_cmp_lt(left, right)).asReturnedValue(); } inline QV4::ReturnedValue __qmljs_ge(const QV4::ValueRef left, const QV4::ValueRef right) { TRACE2(left, right); - return QV4::Value::fromBoolean(__qmljs_cmp_ge(left, right)).asReturnedValue(); + return QV4::Primitive::fromBoolean(__qmljs_cmp_ge(left, right)).asReturnedValue(); } inline QV4::ReturnedValue __qmljs_le(const QV4::ValueRef left, const QV4::ValueRef right) { TRACE2(left, right); - return QV4::Value::fromBoolean(__qmljs_cmp_le(left, right)).asReturnedValue(); + return QV4::Primitive::fromBoolean(__qmljs_cmp_le(left, right)).asReturnedValue(); } inline QV4::ReturnedValue __qmljs_eq(const QV4::ValueRef left, const QV4::ValueRef right) { TRACE2(left, right); - return QV4::Value::fromBoolean(__qmljs_cmp_eq(left, right)).asReturnedValue(); + return QV4::Primitive::fromBoolean(__qmljs_cmp_eq(left, right)).asReturnedValue(); } inline QV4::ReturnedValue __qmljs_ne(const QV4::ValueRef left, const QV4::ValueRef right) { TRACE2(left, right); - return QV4::Value::fromBoolean(!__qmljs_cmp_eq(left, right)).asReturnedValue(); + return QV4::Primitive::fromBoolean(!__qmljs_cmp_eq(left, right)).asReturnedValue(); } inline QV4::ReturnedValue __qmljs_se(const QV4::ValueRef left, const QV4::ValueRef right) @@ -527,7 +527,7 @@ inline QV4::ReturnedValue __qmljs_se(const QV4::ValueRef left, const QV4::ValueR TRACE2(left, right); bool r = __qmljs_strict_equal(left, right); - return QV4::Value::fromBoolean(r).asReturnedValue(); + return QV4::Primitive::fromBoolean(r).asReturnedValue(); } inline QV4::ReturnedValue __qmljs_sne(const QV4::ValueRef left, const QV4::ValueRef right) @@ -535,7 +535,7 @@ inline QV4::ReturnedValue __qmljs_sne(const QV4::ValueRef left, const QV4::Value TRACE2(left, right); bool r = ! __qmljs_strict_equal(left, right); - return QV4::Value::fromBoolean(r).asReturnedValue(); + return QV4::Primitive::fromBoolean(r).asReturnedValue(); } inline QV4::Bool __qmljs_cmp_eq(const QV4::ValueRef left, const QV4::ValueRef right) diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 30b53e7e49..4c44d37af8 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -137,7 +137,7 @@ struct ScopedValue ScopedValue(const Scope &scope, Returned<T> *t) { ptr = scope.engine->jsStackTop++; - *ptr = t->getPointer() ? Value::fromManaged(t->getPointer()) : Value::undefinedValue(); + *ptr = t->getPointer() ? Value::fromManaged(t->getPointer()) : Primitive::undefinedValue(); #ifndef QT_NO_DEBUG ++scope.size; #endif @@ -160,7 +160,7 @@ struct ScopedValue template<typename T> ScopedValue &operator=(Returned<T> *t) { - *ptr = t->getPointer() ? Value::fromManaged(t->getPointer()) : Value::undefinedValue(); + *ptr = t->getPointer() ? Value::fromManaged(t->getPointer()) : Primitive::undefinedValue(); return *this; } @@ -196,7 +196,7 @@ struct Scoped #if QT_POINTER_SIZE == 8 ptr->val = (quint64)p; #else - *ptr = p ? QV4::Value::fromManaged(p) : QV4::Value::undefinedValue(); + *ptr = p ? QV4::Value::fromManaged(p) : QV4::Primitive::undefinedValue(); #endif } @@ -327,16 +327,14 @@ struct Scoped } Value asValue() const { -#if QT_POINTER_SIZE == 8 - return ptr->val ? *ptr : QV4::Value::undefinedValue(); -#else - return *ptr; -#endif + if (ptr->m) + return *ptr; + return QV4::Primitive::undefinedValue(); } ReturnedValue asReturnedValue() const { #if QT_POINTER_SIZE == 8 - return ptr->val ? ptr->val : Value::undefinedValue().asReturnedValue(); + return ptr->val ? ptr->val : Primitive::undefinedValue().asReturnedValue(); #else return ptr->val; #endif @@ -478,7 +476,7 @@ struct Referenced { T *getPointer() const { return static_cast<T *>(ptr->managed()); } - ReturnedValue asReturnedValue() const { return ptr ? ptr->val : Value::undefinedValue().asReturnedValue(); } + ReturnedValue asReturnedValue() const { return ptr ? ptr->val : Primitive::undefinedValue().asReturnedValue(); } static Referenced null() { return Referenced(Null); } bool isNull() const { return !ptr; } @@ -654,6 +652,11 @@ inline Safe<T>::operator Returned<T> *() return Returned<T>::create(static_cast<T *>(managed())); } +inline Primitive::operator ValueRef() +{ + return ValueRef(this); +} + template<typename T> PersistentValue::PersistentValue(Returned<T> *obj) @@ -693,7 +696,7 @@ inline WeakValue &WeakValue::operator=(Returned<T> *obj) } inline ReturnedValue SimpleCallContext::argument(int i) { - return i < callData->argc ? callData->args[i].asReturnedValue() : Value::undefinedValue().asReturnedValue(); + return i < callData->argc ? callData->args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 7a19e385a1..d358c8948c 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -69,7 +69,7 @@ QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Function *f, Objec function->compilationUnit->ref(); usesArgumentsObject = function->usesArgumentsObject(); needsActivation = function->needsActivation(); - defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(1)); + defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1)); qmlContext = scope->engine->current->newQmlContext(this, qml); scope->engine->popContext(); @@ -83,7 +83,7 @@ QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Object *qml) function = 0; usesArgumentsObject = false; needsActivation = false; - defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(1)); + defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1)); qmlContext = scope->engine->current->newQmlContext(this, qml); scope->engine->popContext(); @@ -97,7 +97,7 @@ ReturnedValue QmlBindingWrapper::call(Managed *that, CallData *) Q_ASSERT(This->function); CallContext *ctx = This->qmlContext; - std::fill(ctx->locals, ctx->locals + ctx->function->varCount, Value::undefinedValue()); + std::fill(ctx->locals, ctx->locals + ctx->function->varCount, Primitive::undefinedValue()); engine->pushContext(ctx); ScopedValue result(scope, This->function->code(ctx, This->function->codeData)); engine->popContext(); @@ -252,7 +252,7 @@ ReturnedValue Script::run() ScopedObject qmlObj(valueScope, qml.value()); FunctionObject *f = new (engine->memoryManager) QmlBindingWrapper(scope, vmFunction, qmlObj.getPointer()); ScopedCallData callData(valueScope, 0); - callData->thisObject = Value::undefinedValue(); + callData->thisObject = Primitive::undefinedValue(); return f->call(callData); } } diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 6ad13efbdd..4ec5644352 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -86,7 +86,7 @@ static QV4::Value convertElementToValue(QV4::ExecutionEngine *engine, const QStr static QV4::Value convertElementToValue(QV4::ExecutionEngine *, int element) { - return QV4::Value::fromInt32(element); + return QV4::Primitive::fromInt32(element); } static QV4::Value convertElementToValue(QV4::ExecutionEngine *engine, const QUrl &element) @@ -96,12 +96,12 @@ static QV4::Value convertElementToValue(QV4::ExecutionEngine *engine, const QUrl static QV4::Value convertElementToValue(QV4::ExecutionEngine *, qreal element) { - return QV4::Value::fromDouble(element); + return QV4::Primitive::fromDouble(element); } static QV4::Value convertElementToValue(QV4::ExecutionEngine *, bool element) { - return QV4::Value::fromBoolean(element); + return QV4::Primitive::fromBoolean(element); } static QString convertElementToString(const QString &element) @@ -202,13 +202,13 @@ public: generateWarning(engine()->current, QLatin1String("Index out of range during indexed get")); if (hasProperty) *hasProperty = false; - return QV4::Value::undefinedValue(); + return QV4::Primitive::undefinedValue(); } if (m_isReference) { if (!m_object) { if (hasProperty) *hasProperty = false; - return QV4::Value::undefinedValue(); + return QV4::Primitive::undefinedValue(); } loadReference(); } @@ -220,7 +220,7 @@ public: } if (hasProperty) *hasProperty = false; - return QV4::Value::undefinedValue(); + return QV4::Primitive::undefinedValue(); } void containerPutIndexed(uint index, const QV4::ValueRef value) diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp index ef2ca8bfc8..a8dd865840 100644 --- a/src/qml/jsruntime/qv4serialize.cpp +++ b/src/qml/jsruntime/qv4serialize.cpp @@ -251,7 +251,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, QV8Engine *engi } reserve(data, sizeof(quint32) + length * sizeof(quint32)); push(data, valueheader(WorkerSequence, length)); - serialize(data, QV4::Value::fromInt32(QV4::SequencePrototype::metaTypeForSequence(o)), engine); // sequence type + serialize(data, QV4::Primitive::fromInt32(QV4::SequencePrototype::metaTypeForSequence(o)), engine); // sequence type for (uint32_t ii = 0; ii < seqLength; ++ii) serialize(data, QV4::Value::fromReturnedValue(o->getIndexed(ii)), engine); // sequence elements @@ -350,7 +350,7 @@ ReturnedValue Serialize::deserialize(const char *&data, QV8Engine *engine) case WorkerNumber: return QV4::Encode(popDouble(data)); case WorkerDate: - return QV4::Encode(v4->newDateObject(QV4::Value::fromDouble(popDouble(data)))); + return QV4::Encode(v4->newDateObject(QV4::Primitive::fromDouble(popDouble(data)))); case WorkerRegexp: { quint32 flags = headersize(header); diff --git a/src/qml/jsruntime/qv4sparsearray.cpp b/src/qml/jsruntime/qv4sparsearray.cpp index a001dc276b..a9faf634c9 100644 --- a/src/qml/jsruntime/qv4sparsearray.cpp +++ b/src/qml/jsruntime/qv4sparsearray.cpp @@ -66,7 +66,7 @@ bool ArrayElementLessThan::operator()(const Property &p1, const Property &p2) co Scope scope(o->engine()); ScopedValue result(scope); ScopedCallData callData(scope, 2); - callData->thisObject = Value::undefinedValue(); + callData->thisObject = Primitive::undefinedValue(); callData->args[0] = p1.value; callData->args[1] = p2.value; result = __qmljs_call_value(m_context, m_comparefn, callData); diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index e70bf7d626..eadb523532 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -138,14 +138,14 @@ ReturnedValue String::get(Managed *m, const StringRef name, bool *hasProperty) if (name->isEqualTo(v4->id_length)) { if (hasProperty) *hasProperty = true; - return Value::fromInt32(that->_text.length()).asReturnedValue(); + return Primitive::fromInt32(that->_text.length()).asReturnedValue(); } PropertyAttributes attrs; Property *pd = v4->stringClass->prototype->__getPropertyDescriptor__(name, &attrs); if (!pd || attrs.isGeneric()) { if (hasProperty) *hasProperty = false; - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); } if (hasProperty) *hasProperty = true; @@ -168,7 +168,7 @@ ReturnedValue String::getIndexed(Managed *m, uint index, bool *hasProperty) if (!pd || attrs.isGeneric()) { if (hasProperty) *hasProperty = false; - return Value::undefinedValue().asReturnedValue(); + return Primitive::undefinedValue().asReturnedValue(); } if (hasProperty) *hasProperty = true; diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 05a1ef4100..78b5af1313 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -83,9 +83,9 @@ StringObject::StringObject(InternalClass *ic) vtbl = &static_vtbl; type = Type_StringObject; - tmpProperty.value = Value::undefinedValue(); + tmpProperty.value = Primitive::undefinedValue(); - defineReadonlyProperty(ic->engine->id_length, Value::fromInt32(0)); + defineReadonlyProperty(ic->engine->id_length, Primitive::fromInt32(0)); } StringObject::StringObject(ExecutionEngine *engine, const Value &value) @@ -94,10 +94,10 @@ StringObject::StringObject(ExecutionEngine *engine, const Value &value) vtbl = &static_vtbl; type = Type_StringObject; - tmpProperty.value = Value::undefinedValue(); + tmpProperty.value = Primitive::undefinedValue(); assert(value.isString()); - defineReadonlyProperty(engine->id_length, Value::fromUInt32(value.stringValue()->toQString().length())); + defineReadonlyProperty(engine->id_length, Primitive::fromUInt32(value.stringValue()->toQString().length())); } Property *StringObject::getIndex(uint index) const @@ -189,7 +189,7 @@ ReturnedValue StringCtor::call(Managed *m, CallData *callData) void StringPrototype::init(ExecutionEngine *engine, const Value &ctor) { ctor.objectValue()->defineReadonlyProperty(engine->id_prototype, Value::fromObject(this)); - ctor.objectValue()->defineReadonlyProperty(engine->id_length, Value::fromInt32(1)); + ctor.objectValue()->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1)); ctor.objectValue()->defineDefaultProperty(QStringLiteral("fromCharCode"), method_fromCharCode, 1); defineDefaultProperty(QStringLiteral("constructor"), ctor); @@ -333,7 +333,7 @@ ReturnedValue StringPrototype::method_lastIndexOf(SimpleCallContext *context) ReturnedValue StringPrototype::method_localeCompare(SimpleCallContext *context) { const QString value = getThisString(context); - const QString that = (context->callData->argc ? context->callData->args[0] : Value::undefinedValue()).toQString(); + const QString that = (context->callData->argc ? context->callData->args[0] : Primitive::undefinedValue()).toQString(); return Encode(QString::localeAwareCompare(value, that)); } @@ -345,7 +345,7 @@ ReturnedValue StringPrototype::method_match(SimpleCallContext *context) Scope scope(context); ScopedString s(scope, context->callData->thisObject.toString(context)); - ScopedValue regexp(scope, context->callData->argc ? context->callData->args[0] : Value::undefinedValue()); + ScopedValue regexp(scope, context->callData->argc ? context->callData->args[0] : Primitive::undefinedValue()); Scoped<RegExpObject> rx(scope, regexp); if (!rx) { ScopedCallData callData(scope, 1); @@ -370,7 +370,7 @@ ReturnedValue StringPrototype::method_match(SimpleCallContext *context) return exec->call(callData); ScopedString lastIndex(scope, context->engine->newString(QStringLiteral("lastIndex"))); - rx->put(lastIndex, ScopedValue(scope, Value::fromInt32(0))); + rx->put(lastIndex, ScopedValue(scope, Primitive::fromInt32(0))); Scoped<ArrayObject> a(scope, context->engine->newArrayObject()); double previousLastIndex = 0; @@ -387,7 +387,7 @@ ReturnedValue StringPrototype::method_match(SimpleCallContext *context) double thisIndex = index->toInteger(); if (previousLastIndex == thisIndex) { previousLastIndex = thisIndex + 1; - rx->put(lastIndex, ScopedValue(scope, Value::fromDouble(previousLastIndex))); + rx->put(lastIndex, ScopedValue(scope, Primitive::fromDouble(previousLastIndex))); } else { previousLastIndex = thisIndex; } @@ -488,7 +488,7 @@ ReturnedValue StringPrototype::method_replace(SimpleCallContext *ctx) offset = qMax(offset + 1, matchOffsets[oldSize + 1]); } if (regExp->global) - regExp->lastIndexProperty(ctx)->value = Value::fromUInt32(0); + regExp->lastIndexProperty(ctx)->value = Primitive::fromUInt32(0); numStringMatches = nMatchOffsets / (regExp->value->captureCount() * 2); numCaptures = regExp->value->captureCount(); } else { @@ -510,14 +510,14 @@ ReturnedValue StringPrototype::method_replace(SimpleCallContext *ctx) if (!!searchCallback) { result.reserve(string.length() + 10*numStringMatches); ScopedCallData callData(scope, numCaptures + 2); - callData->thisObject = Value::undefinedValue(); + callData->thisObject = Primitive::undefinedValue(); int lastEnd = 0; for (int i = 0; i < numStringMatches; ++i) { for (int k = 0; k < numCaptures; ++k) { int idx = (i * numCaptures + k) * 2; uint start = matchOffsets[idx]; uint end = matchOffsets[idx + 1]; - Value entry = Value::undefinedValue(); + Value entry = Primitive::undefinedValue(); if (start != JSC::Yarr::offsetNoMatch && end != JSC::Yarr::offsetNoMatch) entry = Value::fromString(ctx, string.mid(start, end - start)); callData->args[k] = entry; @@ -525,7 +525,7 @@ ReturnedValue StringPrototype::method_replace(SimpleCallContext *ctx) uint matchStart = matchOffsets[i * numCaptures * 2]; Q_ASSERT(matchStart >= lastEnd); uint matchEnd = matchOffsets[i * numCaptures * 2 + 1]; - callData->args[numCaptures] = Value::fromUInt32(matchStart); + callData->args[numCaptures] = Primitive::fromUInt32(matchStart); callData->args[numCaptures + 1] = Value::fromString(ctx, string); replacement = searchCallback->call(callData); diff --git a/src/qml/jsruntime/qv4value_def_p.h b/src/qml/jsruntime/qv4value_def_p.h index ae176292da..188952bdd7 100644 --- a/src/qml/jsruntime/qv4value_def_p.h +++ b/src/qml/jsruntime/qv4value_def_p.h @@ -274,12 +274,6 @@ struct Q_QML_EXPORT Value } static Value emptyValue(); - static Value undefinedValue(); - static Value nullValue(); - static Value fromBoolean(Bool b); - static Value fromDouble(double d); - static Value fromInt32(int i); - static Value fromUInt32(uint i); static Value fromString(String *s); static Value fromObject(Object *o); static Value fromManaged(Managed *o); @@ -362,6 +356,19 @@ struct SafeValue : public Value Returned<T> *as(); }; +struct Primitive : public Value +{ + static Primitive fromBoolean(bool b); + static Primitive fromInt32(int i); + static Value undefinedValue(); + static Primitive nullValue(); + static Primitive fromDouble(double d); + static Primitive fromUInt32(uint i); + + inline operator ValueRef(); + Value asValue() const { return *this; } +}; + template <typename T> struct Safe : public SafeValue { diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 3134309d72..ba015958dc 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -97,9 +97,9 @@ inline void Value::mark() const { m->mark(); } -inline Value Value::undefinedValue() +inline Value Primitive::undefinedValue() { - Value v; + Primitive v; #if QT_POINTER_SIZE == 8 v.val = quint64(Undefined_Type) << Tag_Shift; #else @@ -109,9 +109,9 @@ inline Value Value::undefinedValue() return v; } -inline Value Value::nullValue() +inline Primitive Primitive::nullValue() { - Value v; + Primitive v; #if QT_POINTER_SIZE == 8 v.val = quint64(_Null_Type) << Tag_Shift; #else @@ -130,32 +130,32 @@ inline Value Value::emptyValue() } -inline Value Value::fromBoolean(Bool b) +inline Primitive Primitive::fromBoolean(bool b) { - Value v; + Primitive v; v.tag = _Boolean_Type; v.int_32 = (bool)b; return v; } -inline Value Value::fromDouble(double d) +inline Primitive Primitive::fromDouble(double d) { - Value v; + Primitive v; v.setDouble(d); return v; } -inline Value Value::fromInt32(int i) +inline Primitive Primitive::fromInt32(int i) { - Value v; + Primitive v; v.tag = _Integer_Type; v.int_32 = i; return v; } -inline Value Value::fromUInt32(uint i) +inline Primitive Primitive::fromUInt32(uint i) { - Value v; + Primitive v; if (i < INT_MAX) { v.tag = _Integer_Type; v.int_32 = (int)i; @@ -192,7 +192,7 @@ inline Value Value::fromObject(Object *o) inline Value Value::fromManaged(Managed *m) { if (!m) - return QV4::Value::undefinedValue(); + return QV4::Primitive::undefinedValue(); Value v; #if QT_POINTER_SIZE == 8 v.m = m; @@ -392,7 +392,7 @@ public: ~PersistentValue(); ReturnedValue value() const { - return (d ? d->value : Value::undefinedValue()).asReturnedValue(); + return (d ? d->value.asReturnedValue() : Primitive::undefinedValue().asReturnedValue()); } ExecutionEngine *engine() { @@ -433,7 +433,7 @@ public: ~WeakValue(); ReturnedValue value() const { - return (d ? d->value : Value::undefinedValue()).asReturnedValue(); + return (d ? d->value.asReturnedValue() : Primitive::undefinedValue().asReturnedValue()); } ExecutionEngine *engine() { diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 0d4be2169b..ccde91c86a 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -238,7 +238,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code, }; #undef MOTH_INSTR_ADDR *storeJumpTable = jumpTable; - return QV4::Value::undefinedValue().asReturnedValue(); + return QV4::Primitive::undefinedValue().asReturnedValue(); } #endif @@ -329,7 +329,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code, QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData); callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; - callData->thisObject = QV4::Value::undefinedValue(); + callData->thisObject = QV4::Primitive::undefinedValue(); STOREVALUE(instr.result, __qmljs_call_value(context, VALUEPTR(instr.dest), callData)); MOTH_END_INSTR(CallValue) @@ -358,7 +358,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code, QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData); callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; - callData->thisObject = QV4::Value::undefinedValue(); + callData->thisObject = QV4::Primitive::undefinedValue(); STOREVALUE(instr.result, __qmljs_call_activation_property(context, runtimeStrings[instr.name], callData)); MOTH_END_INSTR(CallActivationProperty) @@ -367,7 +367,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code, MOTH_END_INSTR(CallBuiltinThrow) MOTH_BEGIN_INSTR(EnterTry) - VALUE(instr.exceptionVar) = QV4::Value::undefinedValue(); + VALUE(instr.exceptionVar) = QV4::Primitive::undefinedValue(); try { const uchar *tryCode = ((uchar *)&instr.tryOffset) + instr.tryOffset; run(context, tryCode, stack, stackSize); @@ -474,7 +474,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code, QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData); callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; - callData->thisObject = QV4::Value::undefinedValue(); + callData->thisObject = QV4::Primitive::undefinedValue(); STOREVALUE(instr.result, __qmljs_construct_value(context, VALUEPTR(instr.func), callData)); MOTH_END_INSTR(CreateValue) @@ -483,7 +483,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code, QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData); callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; - callData->thisObject = QV4::Value::undefinedValue(); + callData->thisObject = QV4::Primitive::undefinedValue(); STOREVALUE(instr.result, __qmljs_construct_property(context, VALUEPTR(instr.base), runtimeStrings[instr.name], callData)); MOTH_END_INSTR(CreateProperty) @@ -493,7 +493,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code, QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData); callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; - callData->thisObject = QV4::Value::undefinedValue(); + callData->thisObject = QV4::Primitive::undefinedValue(); STOREVALUE(instr.result, __qmljs_construct_activation_property(context, runtimeStrings[instr.name], callData)); MOTH_END_INSTR(CreateActivationProperty) |