aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-09-11 11:07:32 +0200
committerLars Knoll <lars.knoll@qt.io>2018-09-17 07:47:09 +0000
commit1dac47c1418b44cf4a56b42bfca2b277795fd213 (patch)
tree26727943c30628340662a66d7cbe9f52d75c5b58 /src/qml/jsruntime
parentd89d5cffe79bd060a1b04a2c47a3d728bffbe195 (diff)
Cleanups in Value/Primitive
Get rid of Primitive and move the corresponding methods directly into Value. Mark many methods in Value as constexpr and turn Value into a POD type again. Keep Primitive as a pure alias to Value for source compatibility of other modules that might be using it. Change-Id: Icb47458947dd3482c8852e95782123ea4346f5ec Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4argumentsobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4arraybuffer.cpp6
-rw-r--r--src/qml/jsruntime/qv4arraydata.cpp12
-rw-r--r--src/qml/jsruntime/qv4arraydata_p.h2
-rw-r--r--src/qml/jsruntime/qv4arrayiterator.cpp8
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp102
-rw-r--r--src/qml/jsruntime/qv4atomics.cpp16
-rw-r--r--src/qml/jsruntime/qv4booleanobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4context.cpp2
-rw-r--r--src/qml/jsruntime/qv4context_p.h2
-rw-r--r--src/qml/jsruntime/qv4dataview.cpp18
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp26
-rw-r--r--src/qml/jsruntime/qv4engine.cpp10
-rw-r--r--src/qml/jsruntime/qv4errorobject.cpp30
-rw-r--r--src/qml/jsruntime/qv4estable.cpp2
-rw-r--r--src/qml/jsruntime/qv4function.cpp6
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp34
-rw-r--r--src/qml/jsruntime/qv4generatorobject.cpp20
-rw-r--r--src/qml/jsruntime/qv4globalobject.cpp8
-rw-r--r--src/qml/jsruntime/qv4include.cpp20
-rw-r--r--src/qml/jsruntime/qv4internalclass.cpp4
-rw-r--r--src/qml/jsruntime/qv4iterator.cpp2
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp16
-rw-r--r--src/qml/jsruntime/qv4mapiterator.cpp4
-rw-r--r--src/qml/jsruntime/qv4mapobject.cpp16
-rw-r--r--src/qml/jsruntime/qv4math_p.h12
-rw-r--r--src/qml/jsruntime/qv4mathobject.cpp22
-rw-r--r--src/qml/jsruntime/qv4numberobject.cpp22
-rw-r--r--src/qml/jsruntime/qv4object.cpp4
-rw-r--r--src/qml/jsruntime/qv4object_p.h4
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp32
-rw-r--r--src/qml/jsruntime/qv4property_p.h6
-rw-r--r--src/qml/jsruntime/qv4propertykey.cpp4
-rw-r--r--src/qml/jsruntime/qv4proxy.cpp20
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp4
-rw-r--r--src/qml/jsruntime/qv4reflect.cpp12
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp40
-rw-r--r--src/qml/jsruntime/qv4regexpobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp38
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h8
-rw-r--r--src/qml/jsruntime/qv4serialize.cpp4
-rw-r--r--src/qml/jsruntime/qv4setiterator.cpp4
-rw-r--r--src/qml/jsruntime/qv4setobject.cpp10
-rw-r--r--src/qml/jsruntime/qv4stackframe_p.h6
-rw-r--r--src/qml/jsruntime/qv4stringiterator.cpp4
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp44
-rw-r--r--src/qml/jsruntime/qv4symbol.cpp4
-rw-r--r--src/qml/jsruntime/qv4typedarray.cpp68
-rw-r--r--src/qml/jsruntime/qv4value_p.h147
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp18
50 files changed, 437 insertions, 474 deletions
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp
index 86b97d83a1..9f2ce1a439 100644
--- a/src/qml/jsruntime/qv4argumentsobject.cpp
+++ b/src/qml/jsruntime/qv4argumentsobject.cpp
@@ -70,7 +70,7 @@ void Heap::StrictArgumentsObject::init(QV4::CppStackFrame *frame)
args->arrayPut(0, frame->originalArguments, frame->originalArgumentsCount);
Q_ASSERT(LengthPropertyIndex == args->internalClass()->find(v4->id_length()->propertyKey()));
- setProperty(v4, LengthPropertyIndex, Primitive::fromInt32(frame->originalArgumentsCount));
+ setProperty(v4, LengthPropertyIndex, Value::fromInt32(frame->originalArgumentsCount));
}
void Heap::ArgumentsObject::init(QV4::CppStackFrame *frame)
@@ -86,7 +86,7 @@ void Heap::ArgumentsObject::init(QV4::CppStackFrame *frame)
Q_ASSERT(CalleePropertyIndex == internalClass->find(v4->id_callee()->propertyKey()));
setProperty(v4, CalleePropertyIndex, context->d()->function);
Q_ASSERT(LengthPropertyIndex == internalClass->find(v4->id_length()->propertyKey()));
- setProperty(v4, LengthPropertyIndex, Primitive::fromInt32(context->argc()));
+ setProperty(v4, LengthPropertyIndex, Value::fromInt32(context->argc()));
Q_ASSERT(SymbolIteratorPropertyIndex == internalClass->find(v4->symbol_iterator()->propertyKey()));
setProperty(v4, SymbolIteratorPropertyIndex, *v4->arrayProtoValues());
diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp
index e74503e9d3..a99ec16943 100644
--- a/src/qml/jsruntime/qv4arraybuffer.cpp
+++ b/src/qml/jsruntime/qv4arraybuffer.cpp
@@ -90,7 +90,7 @@ ReturnedValue ArrayBufferCtor::virtualCallAsConstructor(const FunctionObject *f,
ExecutionEngine *v4 = f->engine();
Scope scope(v4);
- ScopedValue l(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue l(scope, argc ? argv[0] : Value::undefinedValue());
double dl = l->toInteger();
if (v4->hasException)
return Encode::undefined();
@@ -183,7 +183,7 @@ void SharedArrayBufferPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
ctor->addSymbolSpecies();
@@ -246,7 +246,7 @@ void ArrayBufferPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
ctor->defineDefaultProperty(QStringLiteral("isView"), ArrayBufferCtor::method_isView, 1);
ctor->addSymbolSpecies();
diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp
index ce1d0503df..b11521f2d9 100644
--- a/src/qml/jsruntime/qv4arraydata.cpp
+++ b/src/qml/jsruntime/qv4arraydata.cpp
@@ -221,7 +221,7 @@ ReturnedValue SimpleArrayData::get(const Heap::ArrayData *d, uint index)
{
const Heap::SimpleArrayData *dd = static_cast<const Heap::SimpleArrayData *>(d);
if (index >= dd->values.size)
- return Primitive::emptyValue().asReturnedValue();
+ return Value::emptyValue().asReturnedValue();
return dd->data(index).asReturnedValue();
}
@@ -246,7 +246,7 @@ bool SimpleArrayData::del(Object *o, uint index)
return true;
if (!dd->attrs || dd->attrs[index].isConfigurable()) {
- dd->setData(o->engine(), index, Primitive::emptyValue());
+ dd->setData(o->engine(), index, Value::emptyValue());
if (dd->attrs)
dd->attrs[index] = Attr_Data;
return true;
@@ -328,7 +328,7 @@ bool SimpleArrayData::putArray(Object *o, uint index, const Value *values, uint
}
QV4::ExecutionEngine *e = o->engine();
for (uint i = dd->values.size; i < index; ++i)
- dd->setData(e, i, Primitive::emptyValue());
+ dd->setData(e, i, Value::emptyValue());
for (uint i = 0; i < n; ++i)
dd->setData(e, index + i, values[i]);
dd->values.size = qMax(dd->values.size, index + n);
@@ -402,7 +402,7 @@ ReturnedValue SparseArrayData::get(const Heap::ArrayData *d, uint index)
const Heap::SparseArrayData *s = static_cast<const Heap::SparseArrayData *>(d);
index = s->mappedIndex(index);
if (index == UINT_MAX)
- return Primitive::emptyValue().asReturnedValue();
+ return Value::emptyValue().asReturnedValue();
return s->values[index].asReturnedValue();
}
@@ -606,7 +606,7 @@ void ArrayData::insert(Object *o, uint index, const Value *v, bool isAccessor)
if (index >= d->values.size) {
// mark possible hole in the array
for (uint i = d->values.size; i < index; ++i)
- d->setData(o->engine(), i, Primitive::emptyValue());
+ d->setData(o->engine(), i, Value::emptyValue());
d->values.size = index + 1;
}
d->setData(o->engine(), index, *v);
@@ -799,7 +799,7 @@ void ArrayData::sort(ExecutionEngine *engine, Object *thisObject, const Value &c
break;
Q_ASSERT(!d->attrs || !d->attrs[len].isAccessor());
d->setData(engine, i, d->data(len));
- d->setData(engine, len, Primitive::emptyValue());
+ d->setData(engine, len, Value::emptyValue());
}
}
diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h
index ac5b430356..0a034f3106 100644
--- a/src/qml/jsruntime/qv4arraydata_p.h
+++ b/src/qml/jsruntime/qv4arraydata_p.h
@@ -116,7 +116,7 @@ DECLARE_HEAP_OBJECT(ArrayData, Base) {
inline PropertyAttributes attributes(uint i) const;
bool isEmpty(uint i) const {
- return get(i) == Primitive::emptyValue().asReturnedValue();
+ return get(i) == Value::emptyValue().asReturnedValue();
}
inline uint length() const {
diff --git a/src/qml/jsruntime/qv4arrayiterator.cpp b/src/qml/jsruntime/qv4arrayiterator.cpp
index 650f58463e..199b1a728a 100644
--- a/src/qml/jsruntime/qv4arrayiterator.cpp
+++ b/src/qml/jsruntime/qv4arrayiterator.cpp
@@ -65,7 +65,7 @@ ReturnedValue ArrayIteratorPrototype::method_next(const FunctionObject *b, const
ScopedObject a(scope, thisObject->d()->iteratedObject);
if (!a) {
- QV4::Value undefined = Primitive::undefinedValue();
+ QV4::Value undefined = Value::undefinedValue();
return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
}
@@ -77,13 +77,13 @@ ReturnedValue ArrayIteratorPrototype::method_next(const FunctionObject *b, const
if (index >= len) {
thisObject->d()->iteratedObject.set(scope.engine, nullptr);
- QV4::Value undefined = Primitive::undefinedValue();
+ QV4::Value undefined = Value::undefinedValue();
return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
}
thisObject->d()->nextIndex = index + 1;
if (itemKind == KeyIteratorKind) {
- return IteratorPrototype::createIterResultObject(scope.engine, Primitive::fromInt32(index), false);
+ return IteratorPrototype::createIterResultObject(scope.engine, Value::fromInt32(index), false);
}
ReturnedValue elementValue = a->get(index);
@@ -96,7 +96,7 @@ ReturnedValue ArrayIteratorPrototype::method_next(const FunctionObject *b, const
ScopedArrayObject resultArray(scope, scope.engine->newArrayObject());
resultArray->arrayReserve(2);
- resultArray->arrayPut(0, Primitive::fromInt32(index));
+ resultArray->arrayPut(0, Value::fromInt32(index));
resultArray->arrayPut(1, Value::fromReturnedValue(elementValue));
resultArray->setArrayLengthUnchecked(2);
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index 042d296276..1ee1a7a4f7 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -94,7 +94,7 @@ void ArrayPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
ctor->defineDefaultProperty(QStringLiteral("isArray"), method_isArray, 1);
ctor->defineDefaultProperty(QStringLiteral("of"), method_of, 0);
@@ -108,26 +108,26 @@ void ArrayPrototype::init(ExecutionEngine *engine, Object *ctor)
defineDefaultProperty(engine->id_toLocaleString(), method_toLocaleString, 0);
defineDefaultProperty(QStringLiteral("concat"), method_concat, 1);
name = engine->newIdentifier(QStringLiteral("copyWithin"));
- unscopables->put(name, Primitive::fromBoolean(true));
+ unscopables->put(name, Value::fromBoolean(true));
defineDefaultProperty(name, method_copyWithin, 2);
name = engine->newIdentifier(QStringLiteral("entries"));
- unscopables->put(name, Primitive::fromBoolean(true));
+ unscopables->put(name, Value::fromBoolean(true));
defineDefaultProperty(name, method_entries, 0);
name = engine->newIdentifier(QStringLiteral("fill"));
- unscopables->put(name, Primitive::fromBoolean(true));
+ unscopables->put(name, Value::fromBoolean(true));
defineDefaultProperty(name, method_fill, 1);
name = engine->newIdentifier(QStringLiteral("find"));
- unscopables->put(name, Primitive::fromBoolean(true));
+ unscopables->put(name, Value::fromBoolean(true));
defineDefaultProperty(name, method_find, 1);
name = engine->newIdentifier(QStringLiteral("findIndex"));
- unscopables->put(name, Primitive::fromBoolean(true));
+ unscopables->put(name, Value::fromBoolean(true));
defineDefaultProperty(name, method_findIndex, 1);
name = engine->newIdentifier(QStringLiteral("includes"));
- unscopables->put(name, Primitive::fromBoolean(true));
+ unscopables->put(name, Value::fromBoolean(true));
defineDefaultProperty(name, method_includes, 1);
defineDefaultProperty(QStringLiteral("join"), method_join, 1);
name = engine->newIdentifier(QStringLiteral("keys"));
- unscopables->put(name, Primitive::fromBoolean(true));
+ unscopables->put(name, Value::fromBoolean(true));
defineDefaultProperty(name, method_keys, 0);
defineDefaultProperty(QStringLiteral("pop"), method_pop, 0);
defineDefaultProperty(QStringLiteral("push"), method_push, 1);
@@ -149,7 +149,7 @@ void ArrayPrototype::init(ExecutionEngine *engine, Object *ctor)
ScopedString valuesString(scope, engine->newIdentifier(QStringLiteral("values")));
ScopedObject values(scope, FunctionObject::createBuiltinFunction(engine, valuesString, method_values, 0));
engine->jsObjects[ExecutionEngine::ArrayProtoValues] = values;
- unscopables->put(valuesString, Primitive::fromBoolean(true));
+ unscopables->put(valuesString, Value::fromBoolean(true));
defineDefaultProperty(valuesString, values);
defineDefaultProperty(engine->symbol_iterator(), values);
@@ -165,13 +165,13 @@ ReturnedValue ArrayPrototype::method_isArray(const FunctionObject *, const Value
static ScopedObject createObjectFromCtorOrArray(Scope &scope, ScopedFunctionObject ctor, bool useLen, int len)
{
- ScopedObject a(scope, Primitive::undefinedValue());
+ ScopedObject a(scope, Value::undefinedValue());
if (ctor && ctor->isConstructor()) {
// this isn't completely kosher. for instance:
// Array.from.call(Object, []).constructor == Object
// is expected by the tests, but naturally, we get Number.
- ScopedValue argument(scope, useLen ? QV4::Encode(len) : Primitive::undefinedValue());
+ ScopedValue argument(scope, useLen ? QV4::Encode(len) : Value::undefinedValue());
a = ctor->callAsConstructor(argument, useLen ? 1 : 0);
} else {
a = scope.engine->newArrayObject(len);
@@ -198,7 +198,7 @@ ReturnedValue ArrayPrototype::method_from(const FunctionObject *builtin, const V
}
}
- ScopedFunctionObject mapfn(scope, Primitive::undefinedValue());
+ ScopedFunctionObject mapfn(scope, Value::undefinedValue());
Value *mapArguments = nullptr;
if (argc > 1) {
mapfn = ScopedFunctionObject(scope, argv[1]);
@@ -242,7 +242,7 @@ ReturnedValue ArrayPrototype::method_from(const FunctionObject *builtin, const V
if (ArrayObject *ao = a->as<ArrayObject>()) {
ao->setArrayLengthUnchecked(k);
} else {
- a->set(scope.engine->id_length(), Primitive::fromDouble(k), QV4::Object::DoThrowOnRejection);
+ a->set(scope.engine->id_length(), Value::fromDouble(k), QV4::Object::DoThrowOnRejection);
CHECK_EXCEPTION();
}
return a.asReturnedValue();
@@ -250,10 +250,10 @@ ReturnedValue ArrayPrototype::method_from(const FunctionObject *builtin, const V
if (mapfn) {
mapArguments[0] = *nextValue;
- mapArguments[1] = Primitive::fromDouble(k);
+ mapArguments[1] = Value::fromDouble(k);
mappedValue = mapfn->call(thisArg, mapArguments, 2);
if (scope.engine->hasException)
- return Runtime::method_iteratorClose(scope.engine, iterator, Primitive::fromBoolean(false));
+ return Runtime::method_iteratorClose(scope.engine, iterator, Value::fromBoolean(false));
} else {
mappedValue = *nextValue;
}
@@ -285,7 +285,7 @@ ReturnedValue ArrayPrototype::method_from(const FunctionObject *builtin, const V
CHECK_EXCEPTION();
qint64 k = 0;
- ScopedValue mappedValue(scope, Primitive::undefinedValue());
+ ScopedValue mappedValue(scope, Value::undefinedValue());
ScopedValue kValue(scope);
while (k < len) {
kValue = arrayLike->get(k);
@@ -293,7 +293,7 @@ ReturnedValue ArrayPrototype::method_from(const FunctionObject *builtin, const V
if (mapfn) {
mapArguments[0] = kValue;
- mapArguments[1] = Primitive::fromDouble(k);
+ mapArguments[1] = Value::fromDouble(k);
mappedValue = mapfn->call(thisArg, mapArguments, 2);
CHECK_EXCEPTION();
} else {
@@ -312,7 +312,7 @@ ReturnedValue ArrayPrototype::method_from(const FunctionObject *builtin, const V
if (ArrayObject *ao = a->as<ArrayObject>()) {
ao->setArrayLengthUnchecked(k);
} else {
- a->set(scope.engine->id_length(), Primitive::fromDouble(k), QV4::Object::DoThrowOnRejection);
+ a->set(scope.engine->id_length(), Value::fromDouble(k), QV4::Object::DoThrowOnRejection);
CHECK_EXCEPTION();
}
return a.asReturnedValue();
@@ -340,7 +340,7 @@ ReturnedValue ArrayPrototype::method_of(const FunctionObject *builtin, const Val
// ArrayObject updates its own length, and will throw if we try touch it.
if (!a->as<ArrayObject>()) {
- a->set(scope.engine->id_length(), Primitive::fromDouble(argc), QV4::Object::DoThrowOnRejection);
+ a->set(scope.engine->id_length(), Value::fromDouble(argc), QV4::Object::DoThrowOnRejection);
CHECK_EXCEPTION();
}
@@ -540,13 +540,13 @@ ReturnedValue ArrayPrototype::method_find(const FunctionObject *b, const Value *
ScopedValue result(scope);
Value *arguments = scope.alloc(3);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
for (uint k = 0; k < len; ++k) {
arguments[0] = instance->get(k);
CHECK_EXCEPTION();
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
result = callback->call(that, arguments, 3);
@@ -574,13 +574,13 @@ ReturnedValue ArrayPrototype::method_findIndex(const FunctionObject *b, const Va
ScopedValue result(scope);
Value *arguments = scope.alloc(3);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
for (uint k = 0; k < len; ++k) {
arguments[0] = instance->get(k);
CHECK_EXCEPTION();
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
result = callback->call(that, arguments, 3);
@@ -600,7 +600,7 @@ ReturnedValue ArrayPrototype::method_join(const FunctionObject *b, const Value *
if (!instance)
return Encode(scope.engine->newString());
- ScopedValue arg(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue arg(scope, argc ? argv[0] : Value::undefinedValue());
QString r4;
if (arg->isUndefined())
@@ -641,7 +641,7 @@ ReturnedValue ArrayPrototype::method_join(const FunctionObject *b, const Value *
for (quint32 k = 1; k < r2; ++k) {
R += r4;
- name = Primitive::fromDouble(k).toString(scope.engine);
+ name = Value::fromDouble(k).toString(scope.engine);
r12 = instance->get(name);
CHECK_EXCEPTION();
@@ -664,7 +664,7 @@ ReturnedValue ArrayPrototype::method_pop(const FunctionObject *b, const Value *t
if (!len) {
if (!instance->isArrayObject())
- instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromInt32(0)));
+ instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromInt32(0)));
RETURN_UNDEFINED();
}
@@ -677,7 +677,7 @@ ReturnedValue ArrayPrototype::method_pop(const FunctionObject *b, const Value *t
if (instance->isArrayObject())
instance->setArrayLength(len - 1);
else {
- if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromDouble(len - 1))))
+ if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromDouble(len - 1))))
return scope.engine->throwTypeError();
}
return result->asReturnedValue();
@@ -700,13 +700,13 @@ ReturnedValue ArrayPrototype::method_push(const FunctionObject *b, const Value *
double l = len;
ScopedString s(scope);
for (int i = 0, ei = argc; i < ei; ++i) {
- s = Primitive::fromDouble(l + i).toString(scope.engine);
+ s = Value::fromDouble(l + i).toString(scope.engine);
if (!instance->put(s, argv[i]))
return scope.engine->throwTypeError();
}
double newLen = l + argc;
if (!instance->isArrayObject()) {
- if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromDouble(newLen))))
+ if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromDouble(newLen))))
return scope.engine->throwTypeError();
} else {
ScopedString str(scope, scope.engine->newString(QStringLiteral("Array.prototype.push: Overflow")));
@@ -730,7 +730,7 @@ ReturnedValue ArrayPrototype::method_push(const FunctionObject *b, const Value *
if (instance->isArrayObject())
instance->setArrayLengthUnchecked(len);
else {
- if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromDouble(len))))
+ if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromDouble(len))))
return scope.engine->throwTypeError();
}
@@ -789,7 +789,7 @@ ReturnedValue ArrayPrototype::method_shift(const FunctionObject *b, const Value
if (!len) {
if (!instance->isArrayObject())
- if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromInt32(0))))
+ if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromInt32(0))))
return scope.engine->throwTypeError();
RETURN_UNDEFINED();
}
@@ -822,7 +822,7 @@ ReturnedValue ArrayPrototype::method_shift(const FunctionObject *b, const Value
if (instance->isArrayObject())
instance->setArrayLengthUnchecked(len - 1);
else {
- bool ok = instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromDouble(len - 1)));
+ bool ok = instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromDouble(len - 1)));
if (!ok)
return scope.engine->throwTypeError();
}
@@ -839,7 +839,7 @@ ReturnedValue ArrayPrototype::method_slice(const FunctionObject *b, const Value
ScopedArrayObject result(scope, scope.engine->newArrayObject());
uint len = o->getLength();
- double s = (argc ? argv[0] : Primitive::undefinedValue()).toInteger();
+ double s = (argc ? argv[0] : Value::undefinedValue()).toInteger();
uint start;
if (s < 0)
start = (uint)qMax(len + s, 0.);
@@ -880,7 +880,7 @@ ReturnedValue ArrayPrototype::method_sort(const FunctionObject *b, const Value *
uint len = instance->getLength();
- ScopedValue comparefn(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue comparefn(scope, argc ? argv[0] : Value::undefinedValue());
ArrayData::sort(scope.engine, instance, comparefn, len);
return thisObject->asReturnedValue();
}
@@ -894,7 +894,7 @@ ReturnedValue ArrayPrototype::method_splice(const FunctionObject *b, const Value
qint64 len = instance->getLength();
- double rs = (argc ? argv[0] : Primitive::undefinedValue()).toInteger();
+ double rs = (argc ? argv[0] : Value::undefinedValue()).toInteger();
qint64 start;
if (rs < 0)
start = static_cast<qint64>(qMax(0., len + rs));
@@ -966,7 +966,7 @@ ReturnedValue ArrayPrototype::method_splice(const FunctionObject *b, const Value
for (uint i = 0; i < itemCount; ++i)
instance->put(start + i, argv[i + 2]);
- if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromDouble(len - deleteCount + itemCount))))
+ if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromDouble(len - deleteCount + itemCount))))
return scope.engine->throwTypeError();
return newArray->asReturnedValue();
@@ -1011,7 +1011,7 @@ ReturnedValue ArrayPrototype::method_unshift(const FunctionObject *b, const Valu
if (instance->isArrayObject())
instance->setArrayLengthUnchecked(newLen);
else {
- if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromDouble(newLen))))
+ if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromDouble(newLen))))
return scope.engine->throwTypeError();
}
@@ -1067,7 +1067,7 @@ ReturnedValue ArrayPrototype::method_indexOf(const FunctionObject *b, const Valu
if (!len)
return Encode(-1);
- ScopedValue searchValue(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue searchValue(scope, argc ? argv[0] : Value::undefinedValue());
uint fromIndex = 0;
if (argc >= 2) {
@@ -1151,7 +1151,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(const FunctionObject *b, const
if (argc >= 1)
searchValue = argv[0];
else
- searchValue = Primitive::undefinedValue();
+ searchValue = Value::undefinedValue();
if (argc >= 2) {
double f = argv[1].toInteger();
@@ -1191,7 +1191,7 @@ ReturnedValue ArrayPrototype::method_every(const FunctionObject *b, const Value
THROW_TYPE_ERROR();
const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
ScopedValue r(scope);
Value *arguments = scope.alloc(3);
@@ -1202,7 +1202,7 @@ ReturnedValue ArrayPrototype::method_every(const FunctionObject *b, const Value
if (!exists)
continue;
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
r = callback->call(that, arguments, 3);
ok = r->toBoolean();
@@ -1259,7 +1259,7 @@ ReturnedValue ArrayPrototype::method_some(const FunctionObject *b, const Value *
THROW_TYPE_ERROR();
const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
ScopedValue result(scope);
Value *arguments = scope.alloc(3);
@@ -1269,7 +1269,7 @@ ReturnedValue ArrayPrototype::method_some(const FunctionObject *b, const Value *
if (!exists)
continue;
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
result = callback->call(that, arguments, 3);
if (result->toBoolean())
@@ -1291,7 +1291,7 @@ ReturnedValue ArrayPrototype::method_forEach(const FunctionObject *b, const Valu
THROW_TYPE_ERROR();
const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
Value *arguments = scope.alloc(3);
for (uint k = 0; k < len; ++k) {
@@ -1300,7 +1300,7 @@ ReturnedValue ArrayPrototype::method_forEach(const FunctionObject *b, const Valu
if (!exists)
continue;
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
callback->call(that, arguments, 3);
}
@@ -1329,7 +1329,7 @@ ReturnedValue ArrayPrototype::method_map(const FunctionObject *b, const Value *t
ScopedValue v(scope);
ScopedValue mapped(scope);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
Value *arguments = scope.alloc(3);
for (uint k = 0; k < len; ++k) {
@@ -1338,7 +1338,7 @@ ReturnedValue ArrayPrototype::method_map(const FunctionObject *b, const Value *t
if (!exists)
continue;
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
mapped = callback->call(that, arguments, 3);
a->arraySet(k, mapped);
@@ -1363,7 +1363,7 @@ ReturnedValue ArrayPrototype::method_filter(const FunctionObject *b, const Value
a->arrayReserve(len);
ScopedValue selected(scope);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
Value *arguments = scope.alloc(3);
uint to = 0;
@@ -1373,7 +1373,7 @@ ReturnedValue ArrayPrototype::method_filter(const FunctionObject *b, const Value
if (!exists)
continue;
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
selected = callback->call(that, arguments, 3);
if (selected->toBoolean()) {
@@ -1423,7 +1423,7 @@ ReturnedValue ArrayPrototype::method_reduce(const FunctionObject *b, const Value
if (kPresent) {
arguments[0] = acc;
arguments[1] = v;
- arguments[2] = Primitive::fromDouble(k);
+ arguments[2] = Value::fromDouble(k);
arguments[3] = instance;
acc = callback->call(nullptr, arguments, 4);
}
@@ -1476,7 +1476,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(const FunctionObject *b, const
if (kPresent) {
arguments[0] = acc;
arguments[1] = v;
- arguments[2] = Primitive::fromDouble(k - 1);
+ arguments[2] = Value::fromDouble(k - 1);
arguments[3] = instance;
acc = callback->call(nullptr, arguments, 4);
}
diff --git a/src/qml/jsruntime/qv4atomics.cpp b/src/qml/jsruntime/qv4atomics.cpp
index b29e46db78..4299aef859 100644
--- a/src/qml/jsruntime/qv4atomics.cpp
+++ b/src/qml/jsruntime/qv4atomics.cpp
@@ -114,11 +114,11 @@ ReturnedValue atomicReadModifyWrite(const FunctionObject *f, const Value *argv,
if (!buffer)
return Encode::undefined();
const TypedArray &a = static_cast<const TypedArray &>(argv[0]);
- int index = validateAtomicAccess(scope, a, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ int index = validateAtomicAccess(scope, a, argc > 1 ? argv[1] : Value::undefinedValue());
if (index < 0)
return Encode::undefined();
- Value v = Primitive::fromReturnedValue((argc > 2 ? argv[2] : Primitive::undefinedValue()).convertedToNumber());
+ Value v = Value::fromReturnedValue((argc > 2 ? argv[2] : Value::undefinedValue()).convertedToNumber());
if (scope.hasException())
return Encode::undefined();
@@ -148,14 +148,14 @@ ReturnedValue Atomics::method_compareExchange(const FunctionObject *f, const Val
if (!buffer)
return Encode::undefined();
const TypedArray &a = static_cast<const TypedArray &>(argv[0]);
- int index = validateAtomicAccess(scope, a, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ int index = validateAtomicAccess(scope, a, argc > 1 ? argv[1] : Value::undefinedValue());
if (index < 0)
return Encode::undefined();
- Value expected = Primitive::fromReturnedValue((argc > 2 ? argv[2] : Primitive::undefinedValue()).convertedToNumber());
+ Value expected = Value::fromReturnedValue((argc > 2 ? argv[2] : Value::undefinedValue()).convertedToNumber());
if (scope.hasException())
return Encode::undefined();
- Value v = Primitive::fromReturnedValue((argc > 3 ? argv[3] : Primitive::undefinedValue()).convertedToNumber());
+ Value v = Value::fromReturnedValue((argc > 3 ? argv[3] : Value::undefinedValue()).convertedToNumber());
if (scope.hasException())
return Encode::undefined();
@@ -196,7 +196,7 @@ ReturnedValue Atomics::method_load(const FunctionObject *f, const Value *, const
if (!buffer)
return Encode::undefined();
const TypedArray &a = static_cast<const TypedArray &>(argv[0]);
- int index = validateAtomicAccess(scope, a, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ int index = validateAtomicAccess(scope, a, argc > 1 ? argv[1] : Value::undefinedValue());
if (index < 0)
return Encode::undefined();
@@ -221,11 +221,11 @@ ReturnedValue Atomics::method_store(const FunctionObject *f, const Value *, cons
if (!buffer)
return Encode::undefined();
const TypedArray &a = static_cast<const TypedArray &>(argv[0]);
- int index = validateAtomicAccess(scope, a, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ int index = validateAtomicAccess(scope, a, argc > 1 ? argv[1] : Value::undefinedValue());
if (index < 0)
return Encode::undefined();
- Value v = Primitive::fromReturnedValue((argc > 2 ? argv[2] : Primitive::undefinedValue()).convertedToNumber());
+ Value v = Value::fromReturnedValue((argc > 2 ? argv[2] : Value::undefinedValue()).convertedToNumber());
if (scope.hasException())
return Encode::undefined();
diff --git a/src/qml/jsruntime/qv4booleanobject.cpp b/src/qml/jsruntime/qv4booleanobject.cpp
index f00abad871..075ee1657e 100644
--- a/src/qml/jsruntime/qv4booleanobject.cpp
+++ b/src/qml/jsruntime/qv4booleanobject.cpp
@@ -66,7 +66,7 @@ void BooleanPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(engine->id_toString(), method_toString);
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index d22179173c..6e3e7f9b4f 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -115,7 +115,7 @@ Heap::CallContext *ExecutionContext::newCallContext(CppStackFrame *frame)
c->locals.size = nLocals;
c->locals.alloc = localsAndFormals;
// memory allocated from the JS heap is 0 initialized, so check if empty is 0
- Q_ASSERT(Primitive::undefinedValue().asReturnedValue() == 0);
+ Q_ASSERT(Value::undefinedValue().asReturnedValue() == 0);
c->setupLocalTemporalDeadZone(compiledFunction);
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index 5de11d80cb..5cd2f9ddf0 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -122,7 +122,7 @@ DECLARE_HEAP_OBJECT(CallContext, ExecutionContext) {
template <typename BlockOrFunction>
void setupLocalTemporalDeadZone(BlockOrFunction *bof) {
for (uint i = bof->nLocals - bof->sizeOfLocalTemporalDeadZone; i < bof->nLocals; ++i)
- locals.values[i] = Primitive::emptyValue();
+ locals.values[i] = Value::emptyValue();
}
};
Q_STATIC_ASSERT(std::is_trivial< CallContext >::value);
diff --git a/src/qml/jsruntime/qv4dataview.cpp b/src/qml/jsruntime/qv4dataview.cpp
index d52b9488ac..5ab8cf2dcb 100644
--- a/src/qml/jsruntime/qv4dataview.cpp
+++ b/src/qml/jsruntime/qv4dataview.cpp
@@ -75,11 +75,11 @@ static uint toIndex(ExecutionEngine *e, const Value &v)
ReturnedValue DataViewCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
Scope scope(f->engine());
- Scoped<SharedArrayBuffer> buffer(scope, argc ? argv[0] : Primitive::undefinedValue());
+ Scoped<SharedArrayBuffer> buffer(scope, argc ? argv[0] : Value::undefinedValue());
if (!newTarget || !buffer)
return scope.engine->throwTypeError();
- uint offset = ::toIndex(scope.engine, argc > 1 ? argv[1]: Primitive::undefinedValue());
+ uint offset = ::toIndex(scope.engine, argc > 1 ? argv[1]: Value::undefinedValue());
if (scope.hasException())
return Encode::undefined();
if (buffer->isDetachedBuffer())
@@ -111,7 +111,7 @@ void DataViewPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
defineDefaultProperty(engine->id_constructor(), (o = ctor));
defineAccessorProperty(QStringLiteral("buffer"), method_get_buffer, nullptr);
@@ -188,7 +188,7 @@ ReturnedValue DataViewPrototype::method_getChar(const FunctionObject *b, const V
const DataView *v = thisObject->as<DataView>();
if (!v)
return e->throwTypeError();
- uint idx = ::toIndex(e, argc ? argv[0] : Primitive::undefinedValue());
+ uint idx = ::toIndex(e, argc ? argv[0] : Value::undefinedValue());
if (e->hasException)
return Encode::undefined();
if (v->d()->buffer->isDetachedBuffer())
@@ -209,7 +209,7 @@ ReturnedValue DataViewPrototype::method_get(const FunctionObject *b, const Value
const DataView *v = thisObject->as<DataView>();
if (!v)
return e->throwTypeError();
- uint idx = ::toIndex(e, argc ? argv[0] : Primitive::undefinedValue());
+ uint idx = ::toIndex(e, argc ? argv[0] : Value::undefinedValue());
if (e->hasException)
return Encode::undefined();
if (v->d()->buffer->isDetachedBuffer())
@@ -234,7 +234,7 @@ ReturnedValue DataViewPrototype::method_getFloat(const FunctionObject *b, const
const DataView *v = thisObject->as<DataView>();
if (!v)
return e->throwTypeError();
- uint idx = ::toIndex(e, argc ? argv[0] : Primitive::undefinedValue());
+ uint idx = ::toIndex(e, argc ? argv[0] : Value::undefinedValue());
if (e->hasException)
return Encode::undefined();
if (v->d()->buffer->isDetachedBuffer())
@@ -275,7 +275,7 @@ ReturnedValue DataViewPrototype::method_setChar(const FunctionObject *b, const V
const DataView *v = thisObject->as<DataView>();
if (!v)
return e->throwTypeError();
- uint idx = ::toIndex(e, argc ? argv[0] : Primitive::undefinedValue());
+ uint idx = ::toIndex(e, argc ? argv[0] : Value::undefinedValue());
if (e->hasException)
return Encode::undefined();
@@ -300,7 +300,7 @@ ReturnedValue DataViewPrototype::method_set(const FunctionObject *b, const Value
const DataView *v = thisObject->as<DataView>();
if (!v)
return e->throwTypeError();
- uint idx = ::toIndex(e, argc ? argv[0] : Primitive::undefinedValue());
+ uint idx = ::toIndex(e, argc ? argv[0] : Value::undefinedValue());
if (e->hasException)
return Encode::undefined();
@@ -330,7 +330,7 @@ ReturnedValue DataViewPrototype::method_setFloat(const FunctionObject *b, const
const DataView *v = thisObject->as<DataView>();
if (!v)
return e->throwTypeError();
- uint idx = ::toIndex(e, argc ? argv[0] : Primitive::undefinedValue());
+ uint idx = ::toIndex(e, argc ? argv[0] : Value::undefinedValue());
if (e->hasException)
return Encode::undefined();
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index 93ca4f5442..df3bb37e9c 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -222,7 +222,7 @@ static inline double MonthFromTime(double t)
static inline double DateFromTime(double t)
{
- int m = (int) Primitive::toInteger(MonthFromTime(t));
+ int m = (int) QV4::Value::toInteger(MonthFromTime(t));
double d = DayWithinYear(t);
double l = InLeapYear(t);
@@ -255,10 +255,10 @@ static inline double MakeTime(double hour, double min, double sec, double ms)
{
if (!qIsFinite(hour) || !qIsFinite(min) || !qIsFinite(sec) || !qIsFinite(ms))
return qQNaN();
- hour = Primitive::toInteger(hour);
- min = Primitive::toInteger(min);
- sec = Primitive::toInteger(sec);
- ms = Primitive::toInteger(ms);
+ hour = QV4::Value::toInteger(hour);
+ min = QV4::Value::toInteger(min);
+ sec = QV4::Value::toInteger(sec);
+ ms = QV4::Value::toInteger(ms);
return ((hour * MinutesPerHour + min) * SecondsPerMinute + sec) * msPerSecond + ms;
}
@@ -286,9 +286,9 @@ static double MakeDay(double year, double month, double day)
{
if (!qIsFinite(year) || !qIsFinite(month) || !qIsFinite(day))
return qQNaN();
- year = Primitive::toInteger(year);
- month = Primitive::toInteger(month);
- day = Primitive::toInteger(day);
+ year = QV4::Value::toInteger(year);
+ month = QV4::Value::toInteger(month);
+ day = QV4::Value::toInteger(day);
year += ::floor(month / 12.0);
@@ -384,7 +384,7 @@ static inline double TimeClip(double t)
return qt_qnan();
// +0 looks weird, but is correct. See ES6 20.3.1.15. We must not return -0.
- return Primitive::toInteger(t) + 0;
+ return QV4::Value::toInteger(t) + 0;
}
static inline double ParseString(const QString &s, double localTZA)
@@ -792,7 +792,7 @@ ReturnedValue DateCtor::virtualCallAsConstructor(const FunctionObject *that, con
t = TimeClip(UTC(t, e->localTZA));
}
- return Encode(e->newDateObject(Primitive::fromDouble(t)));
+ return Encode(e->newDateObject(Value::fromDouble(t)));
}
ReturnedValue DateCtor::virtualCall(const FunctionObject *m, const Value *, const Value *, int)
@@ -807,7 +807,7 @@ void DatePrototype::init(ExecutionEngine *engine, Object *ctor)
Scope scope(engine);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(7));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(7));
engine->localTZA = getLocalTZA();
ctor->defineDefaultProperty(QStringLiteral("parse"), method_parse, 1);
@@ -918,7 +918,7 @@ ReturnedValue DatePrototype::method_UTC(const FunctionObject *f, const Value *,
double ms = numArgs >= 7 ? argv[6].toNumber() : 0;
if (e->hasException)
return Encode::undefined();
- double iyear = Primitive::toInteger(year);
+ double iyear = QV4::Value::toInteger(year);
if (!qIsNaN(year) && iyear >= 0 && iyear <= 99)
year = 1900 + iyear;
double t = MakeDate(MakeDay(year, month, day),
@@ -1406,7 +1406,7 @@ ReturnedValue DatePrototype::method_setYear(const FunctionObject *b, const Value
if (std::isnan(year)) {
r = qt_qnan();
} else {
- if ((Primitive::toInteger(year) >= 0) && (Primitive::toInteger(year) <= 99))
+ if ((QV4::Value::toInteger(year) >= 0) && (QV4::Value::toInteger(year) <= 99))
year += 1900;
r = MakeDay(year, MonthFromTime(t), DateFromTime(t));
r = UTC(MakeDate(r, TimeWithinDay(t)), v4->localTZA);
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 8747676685..672196dd3f 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -566,9 +566,9 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine)
globalObject->defineDefaultProperty(QStringLiteral("Reflect"), (o = memoryManager->allocate<Reflect>()));
globalObject->defineDefaultProperty(QStringLiteral("Proxy"), (o = memoryManager->allocate<Proxy>(rootContext())));
- 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));
+ 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));
jsObjects[Eval_Function] = memoryManager->allocate<EvalFunction>(global);
@@ -601,7 +601,7 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine)
globalObject->defineDefaultProperty(QStringLiteral("unescape"), GlobalFunctions::method_unescape, 1);
ScopedFunctionObject t(scope, memoryManager->allocate<FunctionObject>(rootContext(), nullptr, ::throwTypeError));
- t->defineReadonlyProperty(id_length(), Primitive::fromInt32(0));
+ t->defineReadonlyProperty(id_length(), Value::fromInt32(0));
t->setInternalClass(t->internalClass()->frozen());
jsObjects[ThrowerObject] = t;
@@ -1044,7 +1044,7 @@ ReturnedValue ExecutionEngine::catchException(StackTrace *trace)
exceptionStackTrace.clear();
hasException = false;
ReturnedValue res = exceptionValue->asReturnedValue();
- *exceptionValue = Primitive::emptyValue();
+ *exceptionValue = Value::emptyValue();
return res;
}
diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp
index f8812b019d..eb246478c5 100644
--- a/src/qml/jsruntime/qv4errorobject.cpp
+++ b/src/qml/jsruntime/qv4errorobject.cpp
@@ -74,9 +74,9 @@ void Heap::ErrorObject::init()
return;
setProperty(scope.engine, QV4::ErrorObject::Index_Stack, scope.engine->getStackFunction()->d());
- setProperty(scope.engine, QV4::ErrorObject::Index_Stack + QV4::Object::SetterOffset, Primitive::undefinedValue());
- setProperty(scope.engine, QV4::ErrorObject::Index_FileName, Primitive::undefinedValue());
- setProperty(scope.engine, QV4::ErrorObject::Index_LineNumber, Primitive::undefinedValue());
+ setProperty(scope.engine, QV4::ErrorObject::Index_Stack + QV4::Object::SetterOffset, Value::undefinedValue());
+ setProperty(scope.engine, QV4::ErrorObject::Index_FileName, Value::undefinedValue());
+ setProperty(scope.engine, QV4::ErrorObject::Index_LineNumber, Value::undefinedValue());
}
void Heap::ErrorObject::init(const Value &message, ErrorType t)
@@ -88,12 +88,12 @@ void Heap::ErrorObject::init(const Value &message, ErrorType t)
Scoped<QV4::ErrorObject> e(scope, this);
setProperty(scope.engine, QV4::ErrorObject::Index_Stack, scope.engine->getStackFunction()->d());
- setProperty(scope.engine, QV4::ErrorObject::Index_Stack + QV4::Object::SetterOffset, Primitive::undefinedValue());
+ setProperty(scope.engine, QV4::ErrorObject::Index_Stack + QV4::Object::SetterOffset, Value::undefinedValue());
e->d()->stackTrace = new StackTrace(scope.engine->stackTrace());
if (!e->d()->stackTrace->isEmpty()) {
setProperty(scope.engine, QV4::ErrorObject::Index_FileName, scope.engine->newString(e->d()->stackTrace->at(0).source));
- setProperty(scope.engine, QV4::ErrorObject::Index_LineNumber, Primitive::fromInt32(e->d()->stackTrace->at(0).line));
+ setProperty(scope.engine, QV4::ErrorObject::Index_LineNumber, Value::fromInt32(e->d()->stackTrace->at(0).line));
}
if (!message.isUndefined())
@@ -110,7 +110,7 @@ void Heap::ErrorObject::init(const Value &message, const QString &fileName, int
Scoped<QV4::ErrorObject> e(scope, this);
setProperty(scope.engine, QV4::ErrorObject::Index_Stack, scope.engine->getStackFunction()->d());
- setProperty(scope.engine, QV4::ErrorObject::Index_Stack + QV4::Object::SetterOffset, Primitive::undefinedValue());
+ setProperty(scope.engine, QV4::ErrorObject::Index_Stack + QV4::Object::SetterOffset, Value::undefinedValue());
e->d()->stackTrace = new StackTrace(scope.engine->stackTrace());
StackFrame frame;
@@ -121,7 +121,7 @@ void Heap::ErrorObject::init(const Value &message, const QString &fileName, int
Q_ASSERT(!e->d()->stackTrace->isEmpty());
setProperty(scope.engine, QV4::ErrorObject::Index_FileName, scope.engine->newString(e->d()->stackTrace->at(0).source));
- setProperty(scope.engine, QV4::ErrorObject::Index_LineNumber, Primitive::fromInt32(e->d()->stackTrace->at(0).line));
+ setProperty(scope.engine, QV4::ErrorObject::Index_LineNumber, Value::fromInt32(e->d()->stackTrace->at(0).line));
if (!message.isUndefined())
setProperty(scope.engine, QV4::ErrorObject::Index_Message, message);
@@ -231,7 +231,7 @@ void Heap::ErrorCtor::init(QV4::ExecutionContext *scope, const QString &name)
ReturnedValue ErrorCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
- Value v = argc ? *argv : Primitive::undefinedValue();
+ Value v = argc ? *argv : Value::undefinedValue();
return ErrorObject::create<ErrorObject>(f->engine(), v, newTarget)->asReturnedValue();
}
@@ -247,7 +247,7 @@ void Heap::EvalErrorCtor::init(QV4::ExecutionContext *scope)
ReturnedValue EvalErrorCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
- Value v = argc ? *argv : Primitive::undefinedValue();
+ Value v = argc ? *argv : Value::undefinedValue();
return ErrorObject::create<EvalErrorObject>(f->engine(), v, newTarget)->asReturnedValue();
}
@@ -258,7 +258,7 @@ void Heap::RangeErrorCtor::init(QV4::ExecutionContext *scope)
ReturnedValue RangeErrorCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
- Value v = argc ? *argv : Primitive::undefinedValue();
+ Value v = argc ? *argv : Value::undefinedValue();
return ErrorObject::create<RangeErrorObject>(f->engine(), v, newTarget)->asReturnedValue();
}
@@ -269,7 +269,7 @@ void Heap::ReferenceErrorCtor::init(QV4::ExecutionContext *scope)
ReturnedValue ReferenceErrorCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
- Value v = argc ? *argv : Primitive::undefinedValue();
+ Value v = argc ? *argv : Value::undefinedValue();
return ErrorObject::create<ReferenceErrorObject>(f->engine(), v, newTarget)->asReturnedValue();
}
@@ -280,7 +280,7 @@ void Heap::SyntaxErrorCtor::init(QV4::ExecutionContext *scope)
ReturnedValue SyntaxErrorCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
- Value v = argc ? *argv : Primitive::undefinedValue();
+ Value v = argc ? *argv : Value::undefinedValue();
return ErrorObject::create<SyntaxErrorObject>(f->engine(), v, newTarget)->asReturnedValue();
}
@@ -291,7 +291,7 @@ void Heap::TypeErrorCtor::init(QV4::ExecutionContext *scope)
ReturnedValue TypeErrorCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
- Value v = argc ? *argv : Primitive::undefinedValue();
+ Value v = argc ? *argv : Value::undefinedValue();
return ErrorObject::create<TypeErrorObject>(f->engine(), v, newTarget)->asReturnedValue();
}
@@ -302,7 +302,7 @@ void Heap::URIErrorCtor::init(QV4::ExecutionContext *scope)
ReturnedValue URIErrorCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
- Value v = argc ? *argv : Primitive::undefinedValue();
+ Value v = argc ? *argv : Value::undefinedValue();
return ErrorObject::create<URIErrorObject>(f->engine(), v, newTarget)->asReturnedValue();
}
@@ -312,7 +312,7 @@ void ErrorPrototype::init(ExecutionEngine *engine, Object *ctor, Object *obj, He
ScopedString s(scope);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_prototype(), (o = obj));
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
obj->setProperty(Index_Constructor, ctor->d());
obj->setProperty(Index_Message, engine->id_empty()->d());
obj->setProperty(Index_Name, engine->newString(QString::fromLatin1(ErrorObject::className(t))));
diff --git a/src/qml/jsruntime/qv4estable.cpp b/src/qml/jsruntime/qv4estable.cpp
index aa39971dc6..99f6bf6aa0 100644
--- a/src/qml/jsruntime/qv4estable.cpp
+++ b/src/qml/jsruntime/qv4estable.cpp
@@ -107,7 +107,7 @@ void ESTable::set(const Value &key, const Value &value)
Value nk = key;
if (nk.isDouble()) {
if (nk.doubleValue() == 0 && std::signbit(nk.doubleValue()))
- nk = Primitive::fromDouble(+0);
+ nk = Value::fromDouble(+0);
}
m_keys[m_size] = nk;
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index 5e3860a660..941c37de5b 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -58,9 +58,9 @@ ReturnedValue Function::call(const Value *thisObject, const Value *argv, int arg
ExecutionEngine *engine = context->engine();
CppStackFrame frame;
frame.init(engine, this, argv, argc);
- frame.setupJSFrame(engine->jsStackTop, Primitive::undefinedValue(), context->d(),
- thisObject ? *thisObject : Primitive::undefinedValue(),
- Primitive::undefinedValue());
+ frame.setupJSFrame(engine->jsStackTop, Value::undefinedValue(), context->d(),
+ thisObject ? *thisObject : Value::undefinedValue(),
+ Value::undefinedValue());
frame.push();
engine->jsStackTop += frame.requiredJSStackFrameSize();
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 7dd9c90511..a2a5cdd474 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -200,7 +200,7 @@ Heap::FunctionObject *FunctionObject::createBuiltinFunction(ExecutionEngine *eng
name = engine->newString(QChar::fromLatin1('[') + nameOrSymbol->toQString().midRef(1) + QChar::fromLatin1(']'));
ScopedFunctionObject function(scope, engine->memoryManager->allocate<FunctionObject>(engine->rootContext(), name, code));
- function->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(argumentCount));
+ function->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(argumentCount));
return function->d();
}
@@ -305,11 +305,11 @@ void FunctionPrototype::init(ExecutionEngine *engine, Object *ctor)
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
defineReadonlyConfigurableProperty(engine->id_name(), *engine->id_empty());
- defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(0));
+ defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(0));
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(engine->id_toString(), method_toString, 0);
defineDefaultProperty(QStringLiteral("apply"), method_apply, 2);
@@ -364,7 +364,7 @@ ReturnedValue FunctionPrototype::method_apply(const QV4::FunctionObject *b, cons
int l = qMin(len, (uint)a->d()->context->argc());
memcpy(arguments, a->d()->context->args(), l*sizeof(Value));
for (quint32 i = l; i < len; ++i)
- arguments[i] = Primitive::undefinedValue();
+ arguments[i] = Value::undefinedValue();
} else if (arr->arrayType() == Heap::ArrayData::Simple && !arr->protoHasArray()) {
auto sad = static_cast<Heap::SimpleArrayData *>(arr->arrayData());
uint alen = sad ? sad->values.size : 0;
@@ -373,7 +373,7 @@ ReturnedValue FunctionPrototype::method_apply(const QV4::FunctionObject *b, cons
for (uint i = 0; i < alen; ++i)
arguments[i] = sad->data(i);
for (quint32 i = alen; i < len; ++i)
- arguments[i] = Primitive::undefinedValue();
+ arguments[i] = Value::undefinedValue();
} else {
// need to init the arguments array, as the get() calls below can have side effects
memset(arguments, 0, len*sizeof(Value));
@@ -407,7 +407,7 @@ ReturnedValue FunctionPrototype::method_bind(const FunctionObject *b, const Valu
if (!target || target->isBinding())
return scope.engine->throwTypeError();
- ScopedValue boundThis(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue boundThis(scope, argc ? argv[0] : Value::undefinedValue());
Scoped<MemberData> boundArgs(scope, (Heap::MemberData *)nullptr);
int nArgs = (argc - 1 >= 0) ? argc - 1 : 0;
@@ -474,7 +474,7 @@ ReturnedValue ScriptFunction::virtualCallAsConstructor(const FunctionObject *fo,
frame.init(v4, f->function(), argv, argc);
frame.setupJSFrame(v4->jsStackTop, *f, f->scope(),
thisObject,
- newTarget ? *newTarget : Primitive::undefinedValue());
+ newTarget ? *newTarget : Value::undefinedValue());
frame.push();
v4->jsStackTop += frame.requiredJSStackFrameSize();
@@ -496,8 +496,8 @@ ReturnedValue ScriptFunction::virtualCall(const FunctionObject *fo, const Value
CppStackFrame frame;
frame.init(engine, fo->function(), argv, argc);
frame.setupJSFrame(engine->jsStackTop, *fo, fo->scope(),
- thisObject ? *thisObject : Primitive::undefinedValue(),
- Primitive::undefinedValue());
+ thisObject ? *thisObject : Value::undefinedValue(),
+ Value::undefinedValue());
frame.push();
engine->jsStackTop += frame.requiredJSStackFrameSize();
@@ -527,7 +527,7 @@ void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function
f->createDefaultPrototypeProperty(Heap::FunctionObject::Index_ProtoConstructor);
Q_ASSERT(internalClass && internalClass->find(s.engine->id_length()->propertyKey()) == Index_Length);
- setProperty(s.engine, Index_Length, Primitive::fromInt32(int(function->compiledFunction->length)));
+ setProperty(s.engine, Index_Length, Value::fromInt32(int(function->compiledFunction->length)));
}
Heap::InternalClass *ScriptFunction::classForConstructor() const
@@ -559,8 +559,8 @@ ReturnedValue ConstructorFunction::virtualCallAsConstructor(const FunctionObject
CppStackFrame frame;
frame.init(v4, f->function(), argv, argc);
frame.setupJSFrame(v4->jsStackTop, *f, f->scope(),
- Primitive::emptyValue(),
- newTarget ? *newTarget : Primitive::undefinedValue());
+ Value::emptyValue(),
+ newTarget ? *newTarget : Value::undefinedValue());
frame.push();
v4->jsStackTop += frame.requiredJSStackFrameSize();
@@ -576,7 +576,7 @@ ReturnedValue ConstructorFunction::virtualCallAsConstructor(const FunctionObject
return result;
else if (!Value::fromReturnedValue(result).isUndefined())
return v4->throwTypeError();
- else if (Primitive::fromReturnedValue(thisObject).isEmpty()) {
+ else if (Value::fromReturnedValue(thisObject).isEmpty()) {
Scope scope(v4);
ScopedString s(scope, v4->newString(QStringLiteral("this")));
return v4->throwReferenceError(s);
@@ -613,8 +613,8 @@ ReturnedValue DefaultClassConstructorFunction::virtualCallAsConstructor(const Fu
CppStackFrame frame;
frame.init(v4, nullptr, argv, argc);
frame.setupJSFrame(v4->jsStackTop, *f, f->scope(),
- Primitive::undefinedValue(),
- newTarget ? *newTarget : Primitive::undefinedValue(), argc, argc);
+ Value::undefinedValue(),
+ newTarget ? *newTarget : Value::undefinedValue(), argc, argc);
frame.push();
v4->jsStackTop += frame.requiredJSStackFrameSize(argc);
@@ -631,7 +631,7 @@ ReturnedValue DefaultClassConstructorFunction::virtualCallAsConstructor(const Fu
return result;
else if (!Value::fromReturnedValue(result).isUndefined())
return v4->throwTypeError();
- else if (Primitive::fromReturnedValue(thisObject).isEmpty()) {
+ else if (Value::fromReturnedValue(thisObject).isEmpty()) {
Scope scope(v4);
ScopedString s(scope, v4->newString(QStringLiteral("this")));
return v4->throwReferenceError(s);
@@ -669,7 +669,7 @@ void Heap::BoundFunction::init(QV4::ExecutionContext *scope, QV4::FunctionObject
len -= boundArgs->size();
if (len < 0)
len = 0;
- f->defineReadonlyConfigurableProperty(s.engine->id_length(), Primitive::fromInt32(len));
+ f->defineReadonlyConfigurableProperty(s.engine->id_length(), Value::fromInt32(len));
ScopedProperty pd(s);
pd->value = s.engine->thrower();
diff --git a/src/qml/jsruntime/qv4generatorobject.cpp b/src/qml/jsruntime/qv4generatorobject.cpp
index dd3d0328b0..da87127e08 100644
--- a/src/qml/jsruntime/qv4generatorobject.cpp
+++ b/src/qml/jsruntime/qv4generatorobject.cpp
@@ -108,8 +108,8 @@ ReturnedValue GeneratorFunction::virtualCall(const FunctionObject *f, const Valu
memcpy(gp->stack.values, argv, argc*sizeof(Value));
gp->cppFrame.init(engine, function, gp->stack.values, argc);
gp->cppFrame.setupJSFrame(&gp->stack.values[argc], *gf, gf->scope(),
- thisObject ? *thisObject : Primitive::undefinedValue(),
- Primitive::undefinedValue());
+ thisObject ? *thisObject : Value::undefinedValue(),
+ Value::undefinedValue());
gp->cppFrame.push();
@@ -134,7 +134,7 @@ void GeneratorPrototype::init(ExecutionEngine *engine, Object *ctor)
ScopedObject ctorProto(scope, engine->newObject(engine->newInternalClass(Object::staticVTable(), engine->functionPrototype())));
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), ctorProto);
ctorProto->defineDefaultProperty(QStringLiteral("constructor"), (v = ctor), Attr_ReadOnly_ButConfigurable);
@@ -158,9 +158,9 @@ ReturnedValue GeneratorPrototype::method_next(const FunctionObject *f, const Val
Heap::GeneratorObject *gp = g->d();
if (gp->state == GeneratorState::Completed)
- return IteratorPrototype::createIterResultObject(engine, Primitive::undefinedValue(), true);
+ return IteratorPrototype::createIterResultObject(engine, Value::undefinedValue(), true);
- return g->resume(engine, argc ? argv[0] : Primitive::undefinedValue());
+ return g->resume(engine, argc ? argv[0] : Value::undefinedValue());
}
ReturnedValue GeneratorPrototype::method_return(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
@@ -176,13 +176,13 @@ ReturnedValue GeneratorPrototype::method_return(const FunctionObject *f, const V
gp->state = GeneratorState::Completed;
if (gp->state == GeneratorState::Completed)
- return IteratorPrototype::createIterResultObject(engine, argc ? argv[0] : Primitive::undefinedValue(), true);
+ return IteratorPrototype::createIterResultObject(engine, argc ? argv[0] : Value::undefinedValue(), true);
// the bytecode interpreter interprets an exception with empty value as
// a yield called with return()
- engine->throwError(Primitive::emptyValue());
+ engine->throwError(Value::emptyValue());
- return g->resume(engine, argc ? argv[0]: Primitive::undefinedValue());
+ return g->resume(engine, argc ? argv[0]: Value::undefinedValue());
}
ReturnedValue GeneratorPrototype::method_throw(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
@@ -194,14 +194,14 @@ ReturnedValue GeneratorPrototype::method_throw(const FunctionObject *f, const Va
Heap::GeneratorObject *gp = g->d();
- engine->throwError(argc ? argv[0]: Primitive::undefinedValue());
+ engine->throwError(argc ? argv[0]: Value::undefinedValue());
if (gp->state == GeneratorState::SuspendedStart || gp->state == GeneratorState::Completed) {
gp->state = GeneratorState::Completed;
return Encode::undefined();
}
- return g->resume(engine, Primitive::undefinedValue());
+ return g->resume(engine, Value::undefinedValue());
}
ReturnedValue GeneratorObject::resume(ExecutionEngine *engine, const Value &arg) const
diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp
index 1f747b62d7..becdc3bc55 100644
--- a/src/qml/jsruntime/qv4globalobject.cpp
+++ b/src/qml/jsruntime/qv4globalobject.cpp
@@ -335,7 +335,7 @@ void Heap::EvalFunction::init(QV4::ExecutionContext *scope)
Scope s(scope);
Heap::FunctionObject::init(scope, s.engine->id_eval());
ScopedFunctionObject f(s, this);
- f->defineReadonlyConfigurableProperty(s.engine->id_length(), Primitive::fromInt32(1));
+ f->defineReadonlyConfigurableProperty(s.engine->id_length(), Value::fromInt32(1));
}
ReturnedValue EvalFunction::evalCall(const Value *, const Value *argv, int argc, bool directCall) const
@@ -412,8 +412,8 @@ static inline int toInt(const QChar &qc, int R)
ReturnedValue GlobalFunctions::method_parseInt(const FunctionObject *b, const Value *, const Value *argv, int argc)
{
Scope scope(b);
- ScopedValue inputString(scope, argc ? argv[0] : Primitive::undefinedValue());
- ScopedValue radix(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue inputString(scope, argc ? argv[0] : Value::undefinedValue());
+ ScopedValue radix(scope, argc > 1 ? argv[1] : Value::undefinedValue());
int R = radix->isUndefined() ? 0 : radix->toInt32();
// [15.1.2.2] step by step:
@@ -494,7 +494,7 @@ ReturnedValue GlobalFunctions::method_parseFloat(const FunctionObject *b, const
{
Scope scope(b);
// [15.1.2.3] step by step:
- ScopedString inputString(scope, argc ? argv[0] : Primitive::undefinedValue(), ScopedString::Convert);
+ ScopedString inputString(scope, argc ? argv[0] : Value::undefinedValue(), ScopedString::Convert);
CHECK_EXCEPTION();
QString trimmed = inputString->toQString().trimmed(); // 2
diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp
index e3e16fa070..e456879d9c 100644
--- a/src/qml/jsruntime/qv4include.cpp
+++ b/src/qml/jsruntime/qv4include.cpp
@@ -101,11 +101,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(QStringLiteral("OK"))), (v = QV4::Primitive::fromInt32(Ok)));
- o->put((s = v4->newString(QStringLiteral("LOADING"))), (v = QV4::Primitive::fromInt32(Loading)));
- o->put((s = v4->newString(QStringLiteral("NETWORK_ERROR"))), (v = QV4::Primitive::fromInt32(NetworkError)));
- o->put((s = v4->newString(QStringLiteral("EXCEPTION"))), (v = QV4::Primitive::fromInt32(Exception)));
- o->put((s = v4->newString(QStringLiteral("status"))), (v = QV4::Primitive::fromInt32(status)));
+ o->put((s = v4->newString(QStringLiteral("OK"))), (v = QV4::Value::fromInt32(Ok)));
+ o->put((s = v4->newString(QStringLiteral("LOADING"))), (v = QV4::Value::fromInt32(Loading)));
+ o->put((s = v4->newString(QStringLiteral("NETWORK_ERROR"))), (v = QV4::Value::fromInt32(NetworkError)));
+ o->put((s = v4->newString(QStringLiteral("EXCEPTION"))), (v = QV4::Value::fromInt32(Exception)));
+ o->put((s = v4->newString(QStringLiteral("status"))), (v = QV4::Value::fromInt32(status)));
if (!statusText.isEmpty())
o->put((s = v4->newString(QStringLiteral("statusText"))), (v = v4->newString(statusText)));
@@ -173,20 +173,20 @@ void QV4Include::finished()
script.run();
if (scope.engine->hasException) {
QV4::ScopedValue ex(scope, scope.engine->catchException());
- resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Exception)));
+ resultObj->put(status, QV4::ScopedValue(scope, QV4::Value::fromInt32(Exception)));
QV4::ScopedString exception(scope, v4->newString(QStringLiteral("exception")));
resultObj->put(exception, ex);
} else {
- resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Ok)));
+ resultObj->put(status, QV4::ScopedValue(scope, QV4::Value::fromInt32(Ok)));
}
} else {
- resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(NetworkError)));
+ resultObj->put(status, QV4::ScopedValue(scope, QV4::Value::fromInt32(NetworkError)));
}
#else
QV4::Scope scope(v4);
QV4::ScopedObject resultObj(scope, m_resultObject.value());
QV4::ScopedString status(scope, v4->newString(QStringLiteral("status")));
- resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(NetworkError)));
+ resultObj->put(status, QV4::ScopedValue(scope, QV4::Value::fromInt32(NetworkError)));
#endif // qml_network
QV4::ScopedValue cb(scope, m_callbackFunction.value());
@@ -210,7 +210,7 @@ QV4::ReturnedValue QV4Include::method_include(const QV4::FunctionObject *b, cons
if ((!context || !context->isJSContext) && scope.engine->qmlEngine())
RETURN_RESULT(scope.engine->throwError(QString::fromUtf8("Qt.include(): Can only be called from JavaScript files")));
- QV4::ScopedValue callbackFunction(scope, QV4::Primitive::undefinedValue());
+ QV4::ScopedValue callbackFunction(scope, QV4::Value::undefinedValue());
if (argc >= 2 && argv[1].as<QV4::FunctionObject>())
callbackFunction = argv[1];
diff --git a/src/qml/jsruntime/qv4internalclass.cpp b/src/qml/jsruntime/qv4internalclass.cpp
index b22d3073b9..b2b1c29e10 100644
--- a/src/qml/jsruntime/qv4internalclass.cpp
+++ b/src/qml/jsruntime/qv4internalclass.cpp
@@ -294,9 +294,9 @@ static void removeFromPropertyData(QV4::Object *object, int idx, bool accessor =
int size = o->internalClass->size;
for (int i = idx; i < size; ++i)
o->setProperty(v4, i, *o->propertyData(i + (accessor ? 2 : 1)));
- o->setProperty(v4, size, Primitive::undefinedValue());
+ o->setProperty(v4, size, Value::undefinedValue());
if (accessor)
- o->setProperty(v4, size + 1, Primitive::undefinedValue());
+ o->setProperty(v4, size + 1, Value::undefinedValue());
}
void InternalClass::changeMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, uint *index)
diff --git a/src/qml/jsruntime/qv4iterator.cpp b/src/qml/jsruntime/qv4iterator.cpp
index df8000a8f7..a543565b37 100644
--- a/src/qml/jsruntime/qv4iterator.cpp
+++ b/src/qml/jsruntime/qv4iterator.cpp
@@ -58,7 +58,7 @@ ReturnedValue IteratorPrototype::createIterResultObject(ExecutionEngine *engine,
Scope scope(engine);
ScopedObject obj(scope, engine->newObject());
obj->set(ScopedString(scope, engine->newString(QStringLiteral("value"))), value, Object::DoNotThrow);
- obj->set(ScopedString(scope, engine->newString(QStringLiteral("done"))), Primitive::fromBoolean(done), Object::DoNotThrow);
+ obj->set(ScopedString(scope, engine->newString(QStringLiteral("done"))), Value::fromBoolean(done), Object::DoNotThrow);
return obj->asReturnedValue();
}
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index 2e2314cafe..0c5436a0d6 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -340,7 +340,7 @@ bool JsonParser::parseValue(Value *val)
if (*json++ == 'u' &&
*json++ == 'l' &&
*json++ == 'l') {
- *val = Primitive::nullValue();
+ *val = Value::nullValue();
DEBUG << "value: null";
END;
return true;
@@ -355,7 +355,7 @@ bool JsonParser::parseValue(Value *val)
if (*json++ == 'r' &&
*json++ == 'u' &&
*json++ == 'e') {
- *val = Primitive::fromBoolean(true);
+ *val = Value::fromBoolean(true);
DEBUG << "value: true";
END;
return true;
@@ -371,7 +371,7 @@ bool JsonParser::parseValue(Value *val)
*json++ == 'l' &&
*json++ == 's' &&
*json++ == 'e') {
- *val = Primitive::fromBoolean(false);
+ *val = Value::fromBoolean(false);
DEBUG << "value: false";
END;
return true;
@@ -479,7 +479,7 @@ bool JsonParser::parseNumber(Value *val)
bool ok;
int n = number.toInt(&ok);
if (ok && n < (1<<25) && n > -(1<<25)) {
- *val = Primitive::fromInt32(n);
+ *val = Value::fromInt32(n);
END;
return true;
}
@@ -494,7 +494,7 @@ bool JsonParser::parseNumber(Value *val)
return false;
}
- * val = Primitive::fromDouble(d);
+ * val = Value::fromDouble(d);
END;
return true;
@@ -912,7 +912,7 @@ ReturnedValue JsonObject::method_stringify(const FunctionObject *b, const Value
Scope scope(b);
Stringify stringify(scope.engine);
- ScopedObject o(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedObject o(scope, argc > 1 ? argv[1] : Value::undefinedValue());
if (o) {
stringify.replacerFunction = o->as<FunctionObject>();
if (o->isArrayObject()) {
@@ -937,7 +937,7 @@ ReturnedValue JsonObject::method_stringify(const FunctionObject *b, const Value
}
}
- ScopedValue s(scope, argc > 2 ? argv[2] : Primitive::undefinedValue());
+ ScopedValue s(scope, argc > 2 ? argv[2] : Value::undefinedValue());
if (NumberObject *n = s->as<NumberObject>())
s = Encode(n->value());
else if (StringObject *so = s->as<StringObject>())
@@ -950,7 +950,7 @@ ReturnedValue JsonObject::method_stringify(const FunctionObject *b, const Value
}
- ScopedValue arg0(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue arg0(scope, argc ? argv[0] : Value::undefinedValue());
QString result = stringify.Str(QString(), arg0);
if (result.isEmpty() || scope.engine->hasException)
RETURN_UNDEFINED();
diff --git a/src/qml/jsruntime/qv4mapiterator.cpp b/src/qml/jsruntime/qv4mapiterator.cpp
index 7be7416e4a..cd5fbb8e63 100644
--- a/src/qml/jsruntime/qv4mapiterator.cpp
+++ b/src/qml/jsruntime/qv4mapiterator.cpp
@@ -68,7 +68,7 @@ ReturnedValue MapIteratorPrototype::method_next(const FunctionObject *b, const V
IteratorKind itemKind = thisObject->d()->iterationKind;
if (!s) {
- QV4::Value undefined = Primitive::undefinedValue();
+ QV4::Value undefined = Value::undefinedValue();
return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
}
@@ -100,7 +100,7 @@ ReturnedValue MapIteratorPrototype::method_next(const FunctionObject *b, const V
}
thisObject->d()->iteratedMap.set(scope.engine, nullptr);
- QV4::Value undefined = Primitive::undefinedValue();
+ QV4::Value undefined = Value::undefinedValue();
return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
}
diff --git a/src/qml/jsruntime/qv4mapobject.cpp b/src/qml/jsruntime/qv4mapobject.cpp
index c598814fb6..7d53b36fcd 100644
--- a/src/qml/jsruntime/qv4mapobject.cpp
+++ b/src/qml/jsruntime/qv4mapobject.cpp
@@ -137,7 +137,7 @@ void WeakMapPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(0));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(0));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
defineDefaultProperty(engine->id_constructor(), (o = ctor));
@@ -155,7 +155,7 @@ void MapPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(0));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(0));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
ctor->addSymbolSpecies();
defineDefaultProperty(engine->id_constructor(), (o = ctor));
@@ -249,7 +249,7 @@ ReturnedValue WeakMapPrototype::method_set(const FunctionObject *b, const Value
(!argc || !argv[0].isObject()))
return scope.engine->throwTypeError();
- that->d()->esTable->set(argv[0], argc > 1 ? argv[1] : Primitive::undefinedValue());
+ that->d()->esTable->set(argv[0], argc > 1 ? argv[1] : Value::undefinedValue());
return that.asReturnedValue();
}
@@ -272,7 +272,7 @@ ReturnedValue MapPrototype::method_delete(const FunctionObject *b, const Value *
if (!that || that->d()->isWeakMap)
return scope.engine->throwTypeError();
- return Encode(that->d()->esTable->remove(argc ? argv[0] : Primitive::undefinedValue()));
+ return Encode(that->d()->esTable->remove(argc ? argv[0] : Value::undefinedValue()));
}
ReturnedValue MapPrototype::method_entries(const FunctionObject *b, const Value *thisObject, const Value *, int)
@@ -298,7 +298,7 @@ ReturnedValue MapPrototype::method_forEach(const FunctionObject *b, const Value
if (!callbackfn)
return scope.engine->throwTypeError();
- ScopedValue thisArg(scope, Primitive::undefinedValue());
+ ScopedValue thisArg(scope, Value::undefinedValue());
if (argc > 1)
thisArg = ScopedValue(scope, argv[1]);
@@ -320,7 +320,7 @@ ReturnedValue MapPrototype::method_get(const FunctionObject *b, const Value *thi
if (!that || that->d()->isWeakMap)
return scope.engine->throwTypeError();
- return that->d()->esTable->get(argc ? argv[0] : Primitive::undefinedValue());
+ return that->d()->esTable->get(argc ? argv[0] : Value::undefinedValue());
}
ReturnedValue MapPrototype::method_has(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
@@ -330,7 +330,7 @@ ReturnedValue MapPrototype::method_has(const FunctionObject *b, const Value *thi
if (!that || that->d()->isWeakMap)
return scope.engine->throwTypeError();
- return Encode(that->d()->esTable->has(argc ? argv[0] : Primitive::undefinedValue()));
+ return Encode(that->d()->esTable->has(argc ? argv[0] : Value::undefinedValue()));
}
ReturnedValue MapPrototype::method_keys(const FunctionObject *b, const Value *thisObject, const Value *, int)
@@ -352,7 +352,7 @@ ReturnedValue MapPrototype::method_set(const FunctionObject *b, const Value *thi
if (!that || that->d()->isWeakMap)
return scope.engine->throwTypeError();
- that->d()->esTable->set(argc ? argv[0] : Primitive::undefinedValue(), argc > 1 ? argv[1] : Primitive::undefinedValue());
+ that->d()->esTable->set(argc ? argv[0] : Value::undefinedValue(), argc > 1 ? argv[1] : Value::undefinedValue());
return that.asReturnedValue();
}
diff --git a/src/qml/jsruntime/qv4math_p.h b/src/qml/jsruntime/qv4math_p.h
index 67c963622f..90246c4229 100644
--- a/src/qml/jsruntime/qv4math_p.h
+++ b/src/qml/jsruntime/qv4math_p.h
@@ -70,24 +70,24 @@ static inline QMLJS_READONLY ReturnedValue add_int32(int a, int b)
{
int result;
if (Q_UNLIKELY(add_overflow(a, b, &result)))
- return Primitive::fromDouble(static_cast<double>(a) + b).asReturnedValue();
- return Primitive::fromInt32(result).asReturnedValue();
+ return Value::fromDouble(static_cast<double>(a) + b).asReturnedValue();
+ return Value::fromInt32(result).asReturnedValue();
}
static inline QMLJS_READONLY ReturnedValue sub_int32(int a, int b)
{
int result;
if (Q_UNLIKELY(sub_overflow(a, b, &result)))
- return Primitive::fromDouble(static_cast<double>(a) - b).asReturnedValue();
- return Primitive::fromInt32(result).asReturnedValue();
+ return Value::fromDouble(static_cast<double>(a) - b).asReturnedValue();
+ return Value::fromInt32(result).asReturnedValue();
}
static inline QMLJS_READONLY ReturnedValue mul_int32(int a, int b)
{
int result;
if (Q_UNLIKELY(mul_overflow(a, b, &result)))
- return Primitive::fromDouble(static_cast<double>(a) * b).asReturnedValue();
- return Primitive::fromInt32(result).asReturnedValue();
+ return Value::fromDouble(static_cast<double>(a) * b).asReturnedValue();
+ return Value::fromInt32(result).asReturnedValue();
}
}
diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp
index 2943df2984..07440047d4 100644
--- a/src/qml/jsruntime/qv4mathobject.cpp
+++ b/src/qml/jsruntime/qv4mathobject.cpp
@@ -60,14 +60,14 @@ void Heap::MathObject::init()
Scope scope(internalClass->engine);
ScopedObject m(scope, this);
- m->defineReadonlyProperty(QStringLiteral("E"), Primitive::fromDouble(M_E));
- m->defineReadonlyProperty(QStringLiteral("LN2"), Primitive::fromDouble(M_LN2));
- m->defineReadonlyProperty(QStringLiteral("LN10"), Primitive::fromDouble(M_LN10));
- m->defineReadonlyProperty(QStringLiteral("LOG2E"), Primitive::fromDouble(M_LOG2E));
- m->defineReadonlyProperty(QStringLiteral("LOG10E"), Primitive::fromDouble(M_LOG10E));
- m->defineReadonlyProperty(QStringLiteral("PI"), Primitive::fromDouble(M_PI));
- m->defineReadonlyProperty(QStringLiteral("SQRT1_2"), Primitive::fromDouble(M_SQRT1_2));
- m->defineReadonlyProperty(QStringLiteral("SQRT2"), Primitive::fromDouble(M_SQRT2));
+ m->defineReadonlyProperty(QStringLiteral("E"), Value::fromDouble(M_E));
+ m->defineReadonlyProperty(QStringLiteral("LN2"), Value::fromDouble(M_LN2));
+ m->defineReadonlyProperty(QStringLiteral("LN10"), Value::fromDouble(M_LN10));
+ m->defineReadonlyProperty(QStringLiteral("LOG2E"), Value::fromDouble(M_LOG2E));
+ m->defineReadonlyProperty(QStringLiteral("LOG10E"), Value::fromDouble(M_LOG10E));
+ m->defineReadonlyProperty(QStringLiteral("PI"), Value::fromDouble(M_PI));
+ m->defineReadonlyProperty(QStringLiteral("SQRT1_2"), Value::fromDouble(M_SQRT1_2));
+ m->defineReadonlyProperty(QStringLiteral("SQRT2"), Value::fromDouble(M_SQRT2));
m->defineDefaultProperty(QStringLiteral("abs"), QV4::MathObject::method_abs, 1);
m->defineDefaultProperty(QStringLiteral("acos"), QV4::MathObject::method_acos, 1);
@@ -293,7 +293,7 @@ ReturnedValue MathObject::method_expm1(const FunctionObject *, const Value *, co
ReturnedValue MathObject::method_floor(const FunctionObject *, const Value *, const Value *argv, int argc)
{
double v = argc ? argv[0].toNumber() : qt_qnan();
- Value result = Primitive::fromDouble(std::floor(v));
+ Value result = Value::fromDouble(std::floor(v));
result.isInt32();
RETURN_RESULT(result);
}
@@ -329,12 +329,12 @@ ReturnedValue MathObject::method_hypot(const FunctionObject *, const Value *, co
if (bad)
RETURN_RESULT(Encode(qt_qnan()));
// Should actually check for {und,ov}erflow, but too fiddly !
- RETURN_RESULT(Primitive::fromDouble(sqrt(v)));
+ RETURN_RESULT(Value::fromDouble(sqrt(v)));
#else
for (int i = 1; i < argc; i++)
v = std::hypot(v, argv[i].toNumber());
#endif
- RETURN_RESULT(Primitive::fromDouble(v));
+ RETURN_RESULT(Value::fromDouble(v));
}
ReturnedValue MathObject::method_imul(const FunctionObject *, const Value *, const Value *argv, int argc)
diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp
index c444ce1929..11ec53ced5 100644
--- a/src/qml/jsruntime/qv4numberobject.cpp
+++ b/src/qml/jsruntime/qv4numberobject.cpp
@@ -95,19 +95,19 @@ void NumberPrototype::init(ExecutionEngine *engine, Object *ctor)
Scope scope(engine);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
- ctor->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(qt_qnan()));
- ctor->defineReadonlyProperty(QStringLiteral("NEGATIVE_INFINITY"), Primitive::fromDouble(-qInf()));
- ctor->defineReadonlyProperty(QStringLiteral("POSITIVE_INFINITY"), Primitive::fromDouble(qInf()));
- ctor->defineReadonlyProperty(QStringLiteral("MAX_VALUE"), Primitive::fromDouble(1.7976931348623158e+308));
- ctor->defineReadonlyProperty(QStringLiteral("EPSILON"), Primitive::fromDouble(std::numeric_limits<double>::epsilon()));
- ctor->defineReadonlyProperty(QStringLiteral("MAX_SAFE_INTEGER"), Primitive::fromDouble(9007199254740991));
- ctor->defineReadonlyProperty(QStringLiteral("MIN_SAFE_INTEGER"), Primitive::fromDouble(-9007199254740991));
+ ctor->defineReadonlyProperty(QStringLiteral("NaN"), Value::fromDouble(qt_qnan()));
+ ctor->defineReadonlyProperty(QStringLiteral("NEGATIVE_INFINITY"), Value::fromDouble(-qInf()));
+ ctor->defineReadonlyProperty(QStringLiteral("POSITIVE_INFINITY"), Value::fromDouble(qInf()));
+ ctor->defineReadonlyProperty(QStringLiteral("MAX_VALUE"), Value::fromDouble(1.7976931348623158e+308));
+ ctor->defineReadonlyProperty(QStringLiteral("EPSILON"), Value::fromDouble(std::numeric_limits<double>::epsilon()));
+ ctor->defineReadonlyProperty(QStringLiteral("MAX_SAFE_INTEGER"), Value::fromDouble(9007199254740991));
+ ctor->defineReadonlyProperty(QStringLiteral("MIN_SAFE_INTEGER"), Value::fromDouble(-9007199254740991));
QT_WARNING_PUSH
QT_WARNING_DISABLE_INTEL(239)
- ctor->defineReadonlyProperty(QStringLiteral("MIN_VALUE"), Primitive::fromDouble(5e-324));
+ ctor->defineReadonlyProperty(QStringLiteral("MIN_VALUE"), Value::fromDouble(5e-324));
QT_WARNING_POP
ctor->defineDefaultProperty(QStringLiteral("isFinite"), method_isFinite, 1);
@@ -229,7 +229,7 @@ ReturnedValue NumberPrototype::method_toString(const FunctionObject *b, const Va
num = -num;
}
double frac = num - std::floor(num);
- num = Primitive::toInteger(num);
+ num = Value::toInteger(num);
do {
char c = (char)std::fmod(num, radix);
c = (c < 10) ? (c + '0') : (c - 10 + 'a');
@@ -252,7 +252,7 @@ ReturnedValue NumberPrototype::method_toString(const FunctionObject *b, const Va
}
}
- return Encode(Primitive::fromDouble(num).toString(v4));
+ return Encode(Value::fromDouble(num).toString(v4));
}
ReturnedValue NumberPrototype::method_toLocaleString(const FunctionObject *b, const Value *thisObject, const Value *, int)
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 4c36d24c1a..7ea91c441d 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -456,7 +456,7 @@ ReturnedValue Object::internalGet(PropertyKey id, const Value *receiver, bool *h
}
if (o) {
- const Value v = Primitive::fromHeapObject(o);
+ const Value v = Value::fromHeapObject(o);
const Object &obj = static_cast<const Object &>(v);
return obj.get(id, receiver, hasProperty);
}
@@ -658,7 +658,7 @@ bool Object::internalDefineOwnProperty(ExecutionEngine *engine, uint index, Stri
// need to convert the array and the slot
setArrayAttributes(index, cattrs);
}
- current->value = Primitive::undefinedValue();
+ current->value = Value::undefinedValue();
}
} else if (cattrs.isData() && attrs.isData()) { // clause 10
if (!cattrs.isConfigurable() && !cattrs.isWritable()) {
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index 991c0591a5..aca4f99750 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -440,7 +440,7 @@ struct ArrayObject : Object {
private:
void commonInit()
- { setProperty(internalClass->engine, LengthPropertyIndex, Primitive::fromInt32(0)); }
+ { setProperty(internalClass->engine, LengthPropertyIndex, Value::fromInt32(0)); }
};
}
@@ -481,7 +481,7 @@ protected:
inline void Object::setArrayLengthUnchecked(uint l)
{
if (isArrayObject())
- setProperty(Heap::ArrayObject::LengthPropertyIndex, Primitive::fromUInt32(l));
+ setProperty(Heap::ArrayObject::LengthPropertyIndex, Value::fromUInt32(l));
}
inline void Object::push_back(const Value &v)
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index a4f960a3b6..6b4c3ba71a 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -95,7 +95,7 @@ void ObjectPrototype::init(ExecutionEngine *v4, Object *ctor)
ScopedObject o(scope, this);
ctor->defineReadonlyProperty(v4->id_prototype(), o);
- ctor->defineReadonlyConfigurableProperty(v4->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(v4->id_length(), Value::fromInt32(1));
ctor->defineDefaultProperty(QStringLiteral("getPrototypeOf"), method_getPrototypeOf, 1);
ctor->defineDefaultProperty(QStringLiteral("getOwnPropertyDescriptor"), method_getOwnPropertyDescriptor, 2);
ctor->defineDefaultProperty(QStringLiteral("getOwnPropertyDescriptors"), method_getOwnPropertyDescriptors, 1);
@@ -166,7 +166,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptor(const FunctionObj
if (ArgumentsObject::isNonStrictArgumentsObject(O))
static_cast<ArgumentsObject *>(O.getPointer())->fullyCreate();
- ScopedValue v(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue v(scope, argc > 1 ? argv[1] : Value::undefinedValue());
ScopedPropertyKey name(scope, v->toPropertyKey(scope.engine));
if (scope.engine->hasException)
return QV4::Encode::undefined();
@@ -321,11 +321,11 @@ ReturnedValue ObjectPrototype::method_defineProperty(const FunctionObject *b, co
return scope.engine->throwTypeError();
ScopedObject O(scope, argv[0]);
- ScopedPropertyKey name(scope, (argc > 1 ? argv[1] : Primitive::undefinedValue()).toPropertyKey(scope.engine));
+ ScopedPropertyKey name(scope, (argc > 1 ? argv[1] : Value::undefinedValue()).toPropertyKey(scope.engine));
if (scope.engine->hasException)
return QV4::Encode::undefined();
- ScopedValue attributes(scope, argc > 2 ? argv[2] : Primitive::undefinedValue());
+ ScopedValue attributes(scope, argc > 2 ? argv[2] : Value::undefinedValue());
ScopedProperty pd(scope);
PropertyAttributes attrs;
toPropertyDescriptor(scope.engine, attributes, pd, &attrs);
@@ -415,7 +415,7 @@ ReturnedValue ObjectPrototype::method_entries(const FunctionObject *f, const Val
ReturnedValue ObjectPrototype::method_seal(const FunctionObject *b, const Value *, const Value *argv, int argc)
{
- const Value a = argc ? argv[0] : Primitive::undefinedValue();
+ const Value a = argc ? argv[0] : Value::undefinedValue();
if (!a.isObject())
// 19.1.2.17, 1
return a.asReturnedValue();
@@ -437,7 +437,7 @@ ReturnedValue ObjectPrototype::method_seal(const FunctionObject *b, const Value
ReturnedValue ObjectPrototype::method_freeze(const FunctionObject *b, const Value *, const Value *argv, int argc)
{
- const Value a = argc ? argv[0] : Primitive::undefinedValue();
+ const Value a = argc ? argv[0] : Value::undefinedValue();
if (!a.isObject())
// 19.1.2.5, 1
return a.asReturnedValue();
@@ -677,7 +677,7 @@ ReturnedValue ObjectPrototype::method_valueOf(const FunctionObject *b, const Val
ReturnedValue ObjectPrototype::method_hasOwnProperty(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
Scope scope(b);
- ScopedPropertyKey P(scope, (argc ? argv[0] : Primitive::undefinedValue()).toPropertyKey(scope.engine));
+ ScopedPropertyKey P(scope, (argc ? argv[0] : Value::undefinedValue()).toPropertyKey(scope.engine));
if (scope.engine->hasException)
return QV4::Encode::undefined();
ScopedObject O(scope, thisObject->toObject(scope.engine));
@@ -709,7 +709,7 @@ ReturnedValue ObjectPrototype::method_isPrototypeOf(const FunctionObject *b, con
ReturnedValue ObjectPrototype::method_propertyIsEnumerable(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
Scope scope(b);
- ScopedPropertyKey p(scope, (argc ? argv[0] : Primitive::undefinedValue()).toPropertyKey(scope.engine));
+ ScopedPropertyKey p(scope, (argc ? argv[0] : Value::undefinedValue()).toPropertyKey(scope.engine));
if (scope.engine->hasException)
return QV4::Encode::undefined();
@@ -743,7 +743,7 @@ ReturnedValue ObjectPrototype::method_defineGetter(const FunctionObject *b, cons
ScopedProperty pd(scope);
pd->value = f;
- pd->set = Primitive::emptyValue();
+ pd->set = Value::emptyValue();
bool ok = o->defineOwnProperty(prop->toPropertyKey(), pd, Attr_Accessor);
if (!ok)
THROW_TYPE_ERROR();
@@ -772,7 +772,7 @@ ReturnedValue ObjectPrototype::method_defineSetter(const FunctionObject *b, cons
}
ScopedProperty pd(scope);
- pd->value = Primitive::emptyValue();
+ pd->value = Value::emptyValue();
pd->set = f;
bool ok = o->defineOwnProperty(prop->toPropertyKey(), pd, Attr_Accessor);
if (!ok)
@@ -815,8 +815,8 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionEngine *engine, const Value
}
attrs->clear();
- desc->value = Primitive::emptyValue();
- desc->set = Primitive::emptyValue();
+ desc->value = Value::emptyValue();
+ desc->set = Value::emptyValue();
ScopedValue tmp(scope);
if (o->hasProperty(engine->id_enumerable()->toPropertyKey()))
@@ -867,7 +867,7 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionEngine *engine, const Value
}
if (attrs->isGeneric())
- desc->value = Primitive::emptyValue();
+ desc->value = Value::emptyValue();
}
@@ -886,7 +886,7 @@ ReturnedValue ObjectPrototype::fromPropertyDescriptor(ExecutionEngine *engine, c
if (attrs.isData()) {
s = engine->newString(QStringLiteral("value"));
o->put(s, desc->value);
- v = Primitive::fromBoolean(attrs.isWritable());
+ v = Value::fromBoolean(attrs.isWritable());
s = engine->newString(QStringLiteral("writable"));
o->put(s, v);
} else {
@@ -897,10 +897,10 @@ ReturnedValue ObjectPrototype::fromPropertyDescriptor(ExecutionEngine *engine, c
s = engine->newString(QStringLiteral("set"));
o->put(s, v);
}
- v = Primitive::fromBoolean(attrs.isEnumerable());
+ v = Value::fromBoolean(attrs.isEnumerable());
s = engine->newString(QStringLiteral("enumerable"));
o->put(s, v);
- v = Primitive::fromBoolean(attrs.isConfigurable());
+ v = Value::fromBoolean(attrs.isConfigurable());
s = engine->newString(QStringLiteral("configurable"));
o->put(s, v);
diff --git a/src/qml/jsruntime/qv4property_p.h b/src/qml/jsruntime/qv4property_p.h
index 4e38bac470..555f323737 100644
--- a/src/qml/jsruntime/qv4property_p.h
+++ b/src/qml/jsruntime/qv4property_p.h
@@ -66,14 +66,14 @@ struct Property {
// Section 8.10
inline void fullyPopulated(PropertyAttributes *attrs) {
if (!attrs->hasType()) {
- value = Primitive::undefinedValue();
+ value = Value::undefinedValue();
}
if (attrs->type() == PropertyAttributes::Accessor) {
attrs->clearWritable();
if (value.isEmpty())
- value = Primitive::undefinedValue();
+ value = Value::undefinedValue();
if (set.isEmpty())
- set = Primitive::undefinedValue();
+ set = Value::undefinedValue();
}
attrs->resolve();
}
diff --git a/src/qml/jsruntime/qv4propertykey.cpp b/src/qml/jsruntime/qv4propertykey.cpp
index 361ade17c2..064d030b83 100644
--- a/src/qml/jsruntime/qv4propertykey.cpp
+++ b/src/qml/jsruntime/qv4propertykey.cpp
@@ -47,7 +47,7 @@
QV4::Heap::StringOrSymbol *QV4::PropertyKey::toStringOrSymbol(QV4::ExecutionEngine *e)
{
if (isArrayIndex())
- return Primitive::fromUInt32(asArrayIndex()).toString(e);
+ return Value::fromUInt32(asArrayIndex()).toString(e);
return static_cast<Heap::StringOrSymbol *>(asStringOrSymbol());
}
@@ -73,7 +73,7 @@ bool QV4::PropertyKey::isCanonicalNumericIndexString() const
double d = str->toNumber();
if (d == 0. && std::signbit(d))
return true;
- ScopedString converted(scope, Primitive::fromDouble(d).toString(scope.engine));
+ ScopedString converted(scope, Value::fromDouble(d).toString(scope.engine));
if (converted->equals(str))
return true;
return false;
diff --git a/src/qml/jsruntime/qv4proxy.cpp b/src/qml/jsruntime/qv4proxy.cpp
index 71c238135c..cc1fe4f105 100644
--- a/src/qml/jsruntime/qv4proxy.cpp
+++ b/src/qml/jsruntime/qv4proxy.cpp
@@ -208,7 +208,7 @@ bool ProxyObject::virtualHasProperty(const Managed *m, PropertyKey id)
JSCallData cdata(scope, 2, nullptr, handler);
cdata.args[0] = target;
- cdata.args[1] = id.isArrayIndex() ? Primitive::fromUInt32(id.asArrayIndex()).toString(scope.engine) : id.asStringOrSymbol();
+ cdata.args[1] = id.isArrayIndex() ? Value::fromUInt32(id.asArrayIndex()).toString(scope.engine) : id.asStringOrSymbol();
ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
bool result = trapResult->toBoolean();
@@ -248,7 +248,7 @@ PropertyAttributes ProxyObject::virtualGetOwnProperty(Managed *m, PropertyKey id
JSCallData cdata(scope, 2, nullptr, handler);
cdata.args[0] = target;
- cdata.args[1] = id.isArrayIndex() ? Primitive::fromUInt32(id.asArrayIndex()).toString(scope.engine) : id.asStringOrSymbol();
+ cdata.args[1] = id.isArrayIndex() ? Value::fromUInt32(id.asArrayIndex()).toString(scope.engine) : id.asStringOrSymbol();
ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
if (!trapResult->isObject() && !trapResult->isUndefined()) {
@@ -319,7 +319,7 @@ bool ProxyObject::virtualDefineOwnProperty(Managed *m, PropertyKey id, const Pro
JSCallData cdata(scope, 3, nullptr, handler);
cdata.args[0] = target;
- cdata.args[1] = id.isArrayIndex() ? Primitive::fromUInt32(id.asArrayIndex()).toString(scope.engine) : id.asStringOrSymbol();
+ cdata.args[1] = id.isArrayIndex() ? Value::fromUInt32(id.asArrayIndex()).toString(scope.engine) : id.asStringOrSymbol();
cdata.args[2] = ObjectPrototype::fromPropertyDescriptor(scope.engine, p, attrs);
ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
@@ -540,7 +540,7 @@ static bool removeAllOccurrences(ArrayObject *target, ReturnedValue val) {
ReturnedValue v = target->get(i);
if (v == val) {
found = true;
- target->put(i, Primitive::undefinedValue());
+ target->put(i, Value::undefinedValue());
}
}
return found;
@@ -589,7 +589,7 @@ OwnPropertyKeyIterator *ProxyObject::virtualOwnPropertyKeys(const Object *m, Val
scope.engine->throwTypeError();
return nullptr;
}
- Value keyAsValue = Primitive::fromReturnedValue(key->toPropertyKey().id());
+ Value keyAsValue = Value::fromReturnedValue(key->toPropertyKey().id());
trapKeys->push_back(keyAsValue);
}
@@ -602,7 +602,7 @@ OwnPropertyKeyIterator *ProxyObject::virtualOwnPropertyKeys(const Object *m, Val
k = it.next(nullptr, &attrs);
if (!k->isValid())
break;
- Value keyAsValue = Primitive::fromReturnedValue(k->id());
+ Value keyAsValue = Value::fromReturnedValue(k->id());
if (attrs.isConfigurable())
targetConfigurableKeys->push_back(keyAsValue);
else
@@ -674,7 +674,7 @@ ReturnedValue ProxyFunctionObject::virtualCallAsConstructor(const FunctionObject
Value *arguments = scope.alloc(3);
arguments[0] = target;
arguments[1] = scope.engine->newArrayObject(argv, argc);
- arguments[2] = newTarget ? *newTarget : Primitive::undefinedValue();
+ arguments[2] = newTarget ? *newTarget : Value::undefinedValue();
ScopedObject result(scope, trapFunction->call(handler, arguments, 3));
if (!result)
@@ -706,7 +706,7 @@ ReturnedValue ProxyFunctionObject::virtualCall(const FunctionObject *f, const Va
ScopedFunctionObject trapFunction(scope, trap);
Value *arguments = scope.alloc(3);
arguments[0] = target;
- arguments[1] = thisObject ? *thisObject : Primitive::undefinedValue();
+ arguments[1] = thisObject ? *thisObject : Value::undefinedValue();
arguments[2] = scope.engine->newArrayObject(argv, argc);
return trapFunction->call(handler, arguments, 3);
}
@@ -720,7 +720,7 @@ void Heap::Proxy::init(QV4::ExecutionContext *ctx)
Scope scope(ctx);
Scoped<QV4::Proxy> ctor(scope, this);
ctor->defineDefaultProperty(QStringLiteral("revocable"), QV4::Proxy::method_revocable, 2);
- ctor->defineReadonlyConfigurableProperty(scope.engine->id_length(), Primitive::fromInt32(2));
+ ctor->defineReadonlyConfigurableProperty(scope.engine->id_length(), Value::fromInt32(2));
}
ReturnedValue Proxy::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *)
@@ -759,7 +759,7 @@ ReturnedValue Proxy::method_revocable(const FunctionObject *f, const Value *, co
ScopedString revoke(scope, scope.engine->newString(QStringLiteral("revoke")));
ScopedFunctionObject revoker(scope, scope.engine->memoryManager->allocate<FunctionObject>(scope.engine->rootContext(), nullptr, method_revoke));
- revoker->defineReadonlyConfigurableProperty(scope.engine->id_length(), Primitive::fromInt32(0));
+ revoker->defineReadonlyConfigurableProperty(scope.engine->id_length(), Value::fromInt32(0));
revoker->defineDefaultProperty(scope.engine->symbol_revokableProxy(), proxy);
ScopedObject o(scope, scope.engine->newObject());
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index 5800b08ef4..52be2079cb 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -2003,7 +2003,7 @@ ReturnedValue QObjectMethod::callInternal(const Value *thisObject, const Value *
CallData *callData = cData.callData();
if (method.isV4Function()) {
- QV4::ScopedValue rv(scope, QV4::Primitive::undefinedValue());
+ QV4::ScopedValue rv(scope, QV4::Value::undefinedValue());
QQmlV4Function func(callData, rv, v4);
QQmlV4Function *funcptr = &func;
@@ -2074,7 +2074,7 @@ void QMetaObjectWrapper::init(ExecutionEngine *) {
for (int k = 0; k < Enum.keyCount(); k++) {
const char* key = Enum.key(k);
const int value = Enum.value(k);
- defineReadonlyProperty(QLatin1String(key), Primitive::fromInt32(value));
+ defineReadonlyProperty(QLatin1String(key), Value::fromInt32(value));
}
}
}
diff --git a/src/qml/jsruntime/qv4reflect.cpp b/src/qml/jsruntime/qv4reflect.cpp
index 1b08d38eef..15dcb602eb 100644
--- a/src/qml/jsruntime/qv4reflect.cpp
+++ b/src/qml/jsruntime/qv4reflect.cpp
@@ -126,11 +126,11 @@ ReturnedValue Reflect::method_defineProperty(const FunctionObject *f, const Valu
return scope.engine->throwTypeError();
ScopedObject O(scope, argv[0]);
- ScopedPropertyKey name(scope, (argc > 1 ? argv[1] : Primitive::undefinedValue()).toPropertyKey(scope.engine));
+ ScopedPropertyKey name(scope, (argc > 1 ? argv[1] : Value::undefinedValue()).toPropertyKey(scope.engine));
if (scope.engine->hasException)
return QV4::Encode::undefined();
- ScopedValue attributes(scope, argc > 2 ? argv[2] : Primitive::undefinedValue());
+ ScopedValue attributes(scope, argc > 2 ? argv[2] : Value::undefinedValue());
ScopedProperty pd(scope);
PropertyAttributes attrs;
ObjectPrototype::toPropertyDescriptor(scope.engine, attributes, pd, &attrs);
@@ -148,7 +148,7 @@ ReturnedValue Reflect::method_deleteProperty(const FunctionObject *f, const Valu
if (!argc || !argv[0].isObject())
return e->throwTypeError();
- bool result = Runtime::method_deleteProperty(e, argv[0], argc > 1 ? argv[1] : Primitive::undefinedValue());
+ bool result = Runtime::method_deleteProperty(e, argv[0], argc > 1 ? argv[1] : Value::undefinedValue());
return Encode(result);
}
@@ -159,7 +159,7 @@ ReturnedValue Reflect::method_get(const FunctionObject *f, const Value *, const
return scope.engine->throwTypeError();
ScopedObject o(scope, static_cast<const Object *>(argv));
- Value undef = Primitive::undefinedValue();
+ Value undef = Value::undefinedValue();
const Value *index = argc > 1 ? &argv[1] : &undef;
ScopedPropertyKey name(scope, index->toPropertyKey(scope.engine));
if (scope.hasException())
@@ -194,7 +194,7 @@ ReturnedValue Reflect::method_has(const FunctionObject *f, const Value *, const
return scope.engine->throwTypeError();
ScopedObject o(scope, static_cast<const Object *>(argv));
- Value undef = Primitive::undefinedValue();
+ Value undef = Value::undefinedValue();
const Value *index = argc > 1 ? &argv[1] : &undef;
ScopedPropertyKey name(scope, index->toPropertyKey(scope.engine));
@@ -261,7 +261,7 @@ ReturnedValue Reflect::method_set(const FunctionObject *f, const Value *, const
return scope.engine->throwTypeError();
ScopedObject o(scope, static_cast<const Object *>(argv));
- Value undef = Primitive::undefinedValue();
+ Value undef = Value::undefinedValue();
const Value *index = argc > 1 ? &argv[1] : &undef;
const Value &val = argc > 2 ? argv[2] : undef;
ScopedValue receiver(scope, argc >3 ? argv[3] : argv[0]);
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index dd16110c28..634fbcbd97 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -136,7 +136,7 @@ void Heap::RegExpObject::init(const QRegExp &re)
void RegExpObject::initProperties()
{
- setProperty(Index_LastIndex, Primitive::fromInt32(0));
+ setProperty(Index_LastIndex, Value::fromInt32(0));
Q_ASSERT(value());
}
@@ -207,7 +207,7 @@ ReturnedValue RegExpObject::builtinExec(ExecutionEngine *engine, const String *s
array->arrayPut(i, v);
}
array->setArrayLengthUnchecked(len);
- array->setProperty(Index_ArrayIndex, Primitive::fromInt32(result));
+ array->setProperty(Index_ArrayIndex, Value::fromInt32(result));
array->setProperty(Index_ArrayInput, *str);
RegExpCtor::Data *dd = regExpCtor->d();
@@ -232,7 +232,7 @@ void Heap::RegExpCtor::init(QV4::ExecutionContext *scope)
void Heap::RegExpCtor::clearLastMatch()
{
- lastMatch.set(internalClass->engine, Primitive::nullValue());
+ lastMatch.set(internalClass->engine, Value::nullValue());
lastInput.set(internalClass->engine, internalClass->engine->id_empty()->d());
lastMatchStart = 0;
lastMatchEnd = 0;
@@ -244,7 +244,7 @@ static bool isRegExp(ExecutionEngine *e, const Value *arg)
if (!o)
return false;
- Value isRegExp = Primitive::fromReturnedValue(o->get(e->symbol_match()));
+ Value isRegExp = Value::fromReturnedValue(o->get(e->symbol_match()));
if (!isRegExp.isUndefined())
return isRegExp.toBoolean();
const RegExpObject *re = o->as<RegExpObject>();
@@ -294,8 +294,8 @@ ReturnedValue RegExpCtor::virtualCallAsConstructor(const FunctionObject *fo, con
}
}
- ScopedValue p(scope, argc ? argv[0] : Primitive::undefinedValue());
- ScopedValue f(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue p(scope, argc ? argv[0] : Value::undefinedValue());
+ ScopedValue f(scope, argc > 1 ? argv[1] : Value::undefinedValue());
Scoped<RegExpObject> re(scope, p);
QString pattern;
uint flags = CompiledData::RegExp::RegExp_NoFlags;
@@ -347,7 +347,7 @@ void RegExpPrototype::init(ExecutionEngine *engine, Object *constructor)
ScopedObject ctor(scope, constructor);
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(2));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(2));
ctor->addSymbolSpecies();
// Properties deprecated in the spec but required by "the web" :(
@@ -398,7 +398,7 @@ ReturnedValue RegExpPrototype::execFirstMatch(const FunctionObject *b, const Val
Scoped<RegExpObject> r(scope, thisObject->as<RegExpObject>());
Q_ASSERT(r && r->global());
- ScopedString str(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedString str(scope, argc ? argv[0] : Value::undefinedValue());
Q_ASSERT(str);
QString s = str->toQString();
@@ -461,7 +461,7 @@ ReturnedValue RegExpPrototype::method_exec(const FunctionObject *b, const Value
if (!r)
return scope.engine->throwTypeError();
- ScopedValue arg(scope, argc ? argv[0]: Primitive::undefinedValue());
+ ScopedValue arg(scope, argc ? argv[0]: Value::undefinedValue());
ScopedString str(scope, arg->toString(scope.engine));
if (scope.hasException())
RETURN_UNDEFINED();
@@ -552,7 +552,7 @@ static void advanceLastIndexOnEmptyMatch(ExecutionEngine *e, bool unicode, Objec
if (matchString->d()->length() == 0) {
ScopedValue v(scope, rx->get(scope.engine->id_lastIndex()));
int lastIndex = advanceStringIndex(v->toLength(), str, unicode);
- if (!rx->put(scope.engine->id_lastIndex(), Primitive::fromInt32(lastIndex)))
+ if (!rx->put(scope.engine->id_lastIndex(), Value::fromInt32(lastIndex)))
scope.engine->throwTypeError();
}
}
@@ -563,7 +563,7 @@ ReturnedValue RegExpPrototype::method_match(const FunctionObject *f, const Value
ScopedObject rx(scope, thisObject);
if (!rx)
return scope.engine->throwTypeError();
- ScopedString s(scope, (argc ? argv[0] : Primitive::undefinedValue()).toString(scope.engine));
+ ScopedString s(scope, (argc ? argv[0] : Value::undefinedValue()).toString(scope.engine));
if (scope.hasException())
return Encode::undefined();
bool global = ScopedValue(scope, rx->get(scope.engine->id_global()))->toBoolean();
@@ -573,7 +573,7 @@ ReturnedValue RegExpPrototype::method_match(const FunctionObject *f, const Value
bool unicode = ScopedValue(scope, rx->get(scope.engine->id_unicode()))->toBoolean();
- rx->put(scope.engine->id_lastIndex(), Primitive::fromInt32(0));
+ rx->put(scope.engine->id_lastIndex(), Value::fromInt32(0));
ScopedArrayObject a(scope, scope.engine->newArrayObject());
uint n = 0;
@@ -622,24 +622,24 @@ ReturnedValue RegExpPrototype::method_replace(const FunctionObject *f, const Val
if (!rx)
return scope.engine->throwTypeError();
- ScopedString s(scope, (argc ? argv[0] : Primitive::undefinedValue()).toString(scope.engine));
+ ScopedString s(scope, (argc ? argv[0] : Value::undefinedValue()).toString(scope.engine));
if (scope.hasException())
return Encode::undefined();
int lengthS = s->toQString().length();
ScopedString replaceValue(scope);
- ScopedFunctionObject replaceFunction(scope, (argc > 1 ? argv[1] : Primitive::undefinedValue()));
+ ScopedFunctionObject replaceFunction(scope, (argc > 1 ? argv[1] : Value::undefinedValue()));
bool functionalReplace = !!replaceFunction;
if (!functionalReplace)
- replaceValue = (argc > 1 ? argv[1] : Primitive::undefinedValue()).toString(scope.engine);
+ replaceValue = (argc > 1 ? argv[1] : Value::undefinedValue()).toString(scope.engine);
ScopedValue v(scope);
bool global = (v = rx->get(scope.engine->id_global()))->toBoolean();
bool unicode = false;
if (global) {
unicode = (v = rx->get(scope.engine->id_unicode()))->toBoolean();
- if (!rx->put(scope.engine->id_lastIndex(), Primitive::fromInt32(0)))
+ if (!rx->put(scope.engine->id_lastIndex(), Value::fromInt32(0)))
return scope.engine->throwTypeError();
}
@@ -724,13 +724,13 @@ ReturnedValue RegExpPrototype::method_search(const FunctionObject *f, const Valu
if (!rx)
return scope.engine->throwTypeError();
- ScopedString s(scope, (argc ? argv[0] : Primitive::undefinedValue()).toString(scope.engine));
+ ScopedString s(scope, (argc ? argv[0] : Value::undefinedValue()).toString(scope.engine));
if (scope.hasException())
return Encode::undefined();
ScopedValue previousLastIndex(scope, rx->get(scope.engine->id_lastIndex()));
if (previousLastIndex->toNumber() != 0) {
- if (!rx->put(scope.engine->id_lastIndex(), Primitive::fromInt32(0)))
+ if (!rx->put(scope.engine->id_lastIndex(), Value::fromInt32(0)))
return scope.engine->throwTypeError();
}
@@ -772,7 +772,7 @@ ReturnedValue RegExpPrototype::method_split(const FunctionObject *f, const Value
if (!rx)
return scope.engine->throwTypeError();
- ScopedString s(scope, (argc ? argv[0] : Primitive::undefinedValue()).toString(scope.engine));
+ ScopedString s(scope, (argc ? argv[0] : Value::undefinedValue()).toString(scope.engine));
if (scope.hasException())
return Encode::undefined();
@@ -818,7 +818,7 @@ ReturnedValue RegExpPrototype::method_split(const FunctionObject *f, const Value
ScopedObject zz(scope);
ScopedString t(scope);
while (q < size) {
- Value qq = Primitive::fromInt32(q);
+ Value qq = Value::fromInt32(q);
if (!splitter->put(scope.engine->id_lastIndex(), qq))
return scope.engine->throwTypeError();
z = exec(scope.engine, splitter, s);
diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h
index ffac04e1f7..5dfb9d9730 100644
--- a/src/qml/jsruntime/qv4regexpobject_p.h
+++ b/src/qml/jsruntime/qv4regexpobject_p.h
@@ -134,7 +134,7 @@ struct RegExpObject: Object {
engine()->throwTypeError();
return;
}
- return setProperty(Index_LastIndex, Primitive::fromInt32(index));
+ return setProperty(Index_LastIndex, Value::fromInt32(index));
}
QRegExp toQRegExp() const;
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 6ada8b64f1..8f529cea76 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -287,7 +287,7 @@ void RuntimeHelpers::numberToString(QString *result, double num, int radix)
}
double frac = num - ::floor(num);
- num = Primitive::toInteger(num);
+ num = Value::toInteger(num);
do {
char c = (char)::fmod(num, radix);
@@ -538,7 +538,7 @@ Heap::String *RuntimeHelpers::convertToString(ExecutionEngine *engine, Value val
engine->throwTypeError(QLatin1String("Cannot convert a symbol to a string."));
return nullptr;
}
- value = Primitive::fromReturnedValue(RuntimeHelpers::toPrimitive(value, hint));
+ value = Value::fromReturnedValue(RuntimeHelpers::toPrimitive(value, hint));
Q_ASSERT(value.isPrimitive());
if (value.isString())
return static_cast<const String &>(value).d();
@@ -1044,7 +1044,7 @@ void Runtime::method_storeSuperProperty(ExecutionEngine *engine, const Value &pr
ReturnedValue Runtime::method_loadSuperConstructor(ExecutionEngine *engine, const Value &t)
{
- if (engine->currentStackFrame->thisObject() != Primitive::emptyValue().asReturnedValue()) {
+ if (engine->currentStackFrame->thisObject() != Value::emptyValue().asReturnedValue()) {
return engine->throwReferenceError(QStringLiteral("super() already called."), QString(), 0, 0); // ### fix line number
}
const FunctionObject *f = t.as<FunctionObject>();
@@ -1077,9 +1077,9 @@ uint RuntimeHelpers::equalHelper(const Value &x, const Value &y)
double dx = RuntimeHelpers::toNumber(x);
return dx == y.asDouble();
} else if (x.isBoolean()) {
- return Runtime::method_compareEqual(Primitive::fromDouble((double) x.booleanValue()), y);
+ return Runtime::method_compareEqual(Value::fromDouble((double) x.booleanValue()), y);
} else if (y.isBoolean()) {
- return Runtime::method_compareEqual(x, Primitive::fromDouble((double) y.booleanValue()));
+ return Runtime::method_compareEqual(x, Value::fromDouble((double) y.booleanValue()));
} else {
#ifdef V4_BOOTSTRAP
Q_UNIMPLEMENTED();
@@ -1291,7 +1291,7 @@ ReturnedValue Runtime::method_callGlobalLookup(ExecutionEngine *engine, uint ind
if (!function.isFunctionObject())
return engine->throwTypeError();
- Value thisObject = Primitive::undefinedValue();
+ Value thisObject = Value::undefinedValue();
return static_cast<FunctionObject &>(function).call(&thisObject, argv, argc);
}
@@ -1415,7 +1415,7 @@ ReturnedValue Runtime::method_callValue(ExecutionEngine *engine, const Value &fu
{
if (!func.isFunctionObject())
return engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow()));
- Value undef = Primitive::undefinedValue();
+ Value undef = Value::undefinedValue();
return static_cast<const FunctionObject &>(func).call(&undef, argv, argc);
}
@@ -1705,9 +1705,9 @@ ReturnedValue Runtime::method_objectLiteral(ExecutionEngine *engine, int classId
Q_ASSERT(arg == ObjectLiteralArgument::Value || value->isFunctionObject());
if (arg == ObjectLiteralArgument::Value || arg == ObjectLiteralArgument::Getter) {
pd->value = value;
- pd->set = Primitive::emptyValue();
+ pd->set = Value::emptyValue();
} else {
- pd->value = Primitive::emptyValue();
+ pd->value = Value::emptyValue();
pd->set = value;
}
bool ok = o->defineOwnProperty(name, pd, (arg == ObjectLiteralArgument::Value ? Attr_Data : Attr_Accessor));
@@ -1752,7 +1752,7 @@ ReturnedValue Runtime::method_createClass(ExecutionEngine *engine, int classInde
QV4::Function *f = cls->constructorFunction != UINT_MAX ? unit->runtimeFunctions[cls->constructorFunction] : nullptr;
constructor = FunctionObject::createConstructorFunction(current, f, proto, !superClass.isEmpty())->asReturnedValue();
constructor->setPrototypeUnchecked(constructorParent);
- Value argCount = Primitive::fromInt32(f ? f->nFormals : 0);
+ Value argCount = Value::fromInt32(f ? f->nFormals : 0);
constructor->defineReadonlyConfigurableProperty(scope.engine->id_length(), argCount);
constructor->defineReadonlyConfigurableProperty(engine->id_prototype(), proto);
proto->defineDefaultProperty(engine->id_constructor(), constructor);
@@ -1801,17 +1801,17 @@ ReturnedValue Runtime::method_createClass(ExecutionEngine *engine, int classInde
switch (methods[i].type) {
case CompiledData::Method::Getter:
property->setGetter(function);
- property->set = Primitive::emptyValue();
+ property->set = Value::emptyValue();
attributes = Attr_Accessor|Attr_NotEnumerable;
break;
case CompiledData::Method::Setter:
- property->value = Primitive::emptyValue();
+ property->value = Value::emptyValue();
property->setSetter(function);
attributes = Attr_Accessor|Attr_NotEnumerable;
break;
default: // Regular
property->value = function;
- property->set = Primitive::emptyValue();
+ property->set = Value::emptyValue();
attributes = Attr_Data|Attr_NotEnumerable;
break;
}
@@ -1928,7 +1928,7 @@ ReturnedValue Runtime::method_add(ExecutionEngine *engine, const Value &left, co
if (Q_LIKELY(left.integerCompatible() && right.integerCompatible()))
return add_int32(left.integerValue(), right.integerValue());
if (left.isNumber() && right.isNumber())
- return Primitive::fromDouble(left.asDouble() + right.asDouble()).asReturnedValue();
+ return Value::fromDouble(left.asDouble() + right.asDouble()).asReturnedValue();
return RuntimeHelpers::addHelper(engine, left, right);
}
@@ -1943,7 +1943,7 @@ ReturnedValue Runtime::method_sub(const Value &left, const Value &right)
double lval = left.isNumber() ? left.asDouble() : left.toNumberImpl();
double rval = right.isNumber() ? right.asDouble() : right.toNumberImpl();
- return Primitive::fromDouble(lval - rval).asReturnedValue();
+ return Value::fromDouble(lval - rval).asReturnedValue();
}
ReturnedValue Runtime::method_mul(const Value &left, const Value &right)
@@ -1956,7 +1956,7 @@ ReturnedValue Runtime::method_mul(const Value &left, const Value &right)
double lval = left.isNumber() ? left.asDouble() : left.toNumberImpl();
double rval = right.isNumber() ? right.asDouble() : right.toNumberImpl();
- return Primitive::fromDouble(lval * rval).asReturnedValue();
+ return Value::fromDouble(lval * rval).asReturnedValue();
}
ReturnedValue Runtime::method_div(const Value &left, const Value &right)
@@ -1976,7 +1976,7 @@ ReturnedValue Runtime::method_div(const Value &left, const Value &right)
double lval = left.toNumber();
double rval = right.toNumber();
- return Primitive::fromDouble(lval / rval).asReturnedValue();
+ return Value::fromDouble(lval / rval).asReturnedValue();
}
ReturnedValue Runtime::method_mod(const Value &left, const Value &right)
@@ -1997,7 +1997,7 @@ ReturnedValue Runtime::method_mod(const Value &left, const Value &right)
#ifdef fmod
# undef fmod
#endif
- return Primitive::fromDouble(std::fmod(lval, rval)).asReturnedValue();
+ return Value::fromDouble(std::fmod(lval, rval)).asReturnedValue();
}
ReturnedValue Runtime::method_shl(const Value &left, const Value &right)
@@ -2151,7 +2151,7 @@ Bool Runtime::method_compareEqual(const Value &left, const Value &right)
return false;
case QV4::Value::QT_Bool:
case QV4::Value::QT_Int:
- rhs = Primitive::fromDouble(rhs.int_32());
+ rhs = Value::fromDouble(rhs.int_32());
// fall through
default: // double
#ifndef V4_BOOTSTRAP
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h
index 8ac2213492..c28a3ffa2d 100644
--- a/src/qml/jsruntime/qv4scopedvalue_p.h
+++ b/src/qml/jsruntime/qv4scopedvalue_p.h
@@ -131,11 +131,11 @@ struct Scope {
switch (mode) {
case Undefined:
for (int i = 0; i < nValues; ++i)
- ptr[i] = Primitive::undefinedValue();
+ ptr[i] = Value::undefinedValue();
break;
case Empty:
for (int i = 0; i < nValues; ++i)
- ptr[i] = Primitive::emptyValue();
+ ptr[i] = Value::emptyValue();
break;
case Uninitialized:
break;
@@ -148,10 +148,10 @@ struct Scope {
Value *ptr = engine->jsAlloca(1);
switch (mode) {
case Undefined:
- *ptr = Primitive::undefinedValue();
+ *ptr = Value::undefinedValue();
break;
case Empty:
- *ptr = Primitive::emptyValue();
+ *ptr = Value::emptyValue();
break;
case Uninitialized:
break;
diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp
index e151966306..50871a4d87 100644
--- a/src/qml/jsruntime/qv4serialize.cpp
+++ b/src/qml/jsruntime/qv4serialize.cpp
@@ -262,7 +262,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine
}
reserve(data, sizeof(quint32) + length * sizeof(quint32));
push(data, valueheader(WorkerSequence, length));
- serialize(data, QV4::Primitive::fromInt32(QV4::SequencePrototype::metaTypeForSequence(o)), engine); // sequence type
+ serialize(data, QV4::Value::fromInt32(QV4::SequencePrototype::metaTypeForSequence(o)), engine); // sequence type
ScopedValue val(scope);
for (uint ii = 0; ii < seqLength; ++ii)
serialize(data, (val = o->get(ii)), engine); // sequence elements
@@ -358,7 +358,7 @@ ReturnedValue Serialize::deserialize(const char *&data, ExecutionEngine *engine)
case WorkerNumber:
return QV4::Encode(popDouble(data));
case WorkerDate:
- return QV4::Encode(engine->newDateObject(QV4::Primitive::fromDouble(popDouble(data))));
+ return QV4::Encode(engine->newDateObject(QV4::Value::fromDouble(popDouble(data))));
case WorkerRegexp:
{
quint32 flags = headersize(header);
diff --git a/src/qml/jsruntime/qv4setiterator.cpp b/src/qml/jsruntime/qv4setiterator.cpp
index 4681a49bd6..d32e2079a0 100644
--- a/src/qml/jsruntime/qv4setiterator.cpp
+++ b/src/qml/jsruntime/qv4setiterator.cpp
@@ -68,7 +68,7 @@ ReturnedValue SetIteratorPrototype::method_next(const FunctionObject *b, const V
IteratorKind itemKind = thisObject->d()->iterationKind;
if (!s) {
- QV4::Value undefined = Primitive::undefinedValue();
+ QV4::Value undefined = Value::undefinedValue();
return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
}
@@ -92,7 +92,7 @@ ReturnedValue SetIteratorPrototype::method_next(const FunctionObject *b, const V
}
thisObject->d()->iteratedSet.set(scope.engine, nullptr);
- QV4::Value undefined = Primitive::undefinedValue();
+ QV4::Value undefined = Value::undefinedValue();
return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
}
diff --git a/src/qml/jsruntime/qv4setobject.cpp b/src/qml/jsruntime/qv4setobject.cpp
index 65824926b9..3c9b5031d1 100644
--- a/src/qml/jsruntime/qv4setobject.cpp
+++ b/src/qml/jsruntime/qv4setobject.cpp
@@ -118,7 +118,7 @@ void WeakSetPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(0));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(0));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
defineDefaultProperty(engine->id_constructor(), (o = ctor));
@@ -138,7 +138,7 @@ ReturnedValue WeakSetPrototype::method_add(const FunctionObject *b, const Value
(!argc || !argv[0].isObject()))
return scope.engine->throwTypeError();
- that->d()->esTable->set(argv[0], Primitive::undefinedValue());
+ that->d()->esTable->set(argv[0], Value::undefinedValue());
return that.asReturnedValue();
}
@@ -170,7 +170,7 @@ void SetPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(0));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(0));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
ctor->addSymbolSpecies();
defineDefaultProperty(engine->id_constructor(), (o = ctor));
@@ -226,7 +226,7 @@ ReturnedValue SetPrototype::method_add(const FunctionObject *b, const Value *thi
if (!that || that->d()->isWeakSet)
return scope.engine->throwTypeError();
- that->d()->esTable->set(argv[0], Primitive::undefinedValue());
+ that->d()->esTable->set(argv[0], Value::undefinedValue());
return that.asReturnedValue();
}
@@ -274,7 +274,7 @@ ReturnedValue SetPrototype::method_forEach(const FunctionObject *b, const Value
if (!callbackfn)
return scope.engine->throwTypeError();
- ScopedValue thisArg(scope, Primitive::undefinedValue());
+ ScopedValue thisArg(scope, Value::undefinedValue());
if (argc > 1)
thisArg = ScopedValue(scope, argv[1]);
diff --git a/src/qml/jsruntime/qv4stackframe_p.h b/src/qml/jsruntime/qv4stackframe_p.h
index 6f21058e91..dd68c29a88 100644
--- a/src/qml/jsruntime/qv4stackframe_p.h
+++ b/src/qml/jsruntime/qv4stackframe_p.h
@@ -92,7 +92,7 @@ struct CallData
}
inline ReturnedValue argument(int i) const {
- return i < argc() ? args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue();
+ return i < argc() ? args[i].asReturnedValue() : Value::undefinedValue().asReturnedValue();
}
Value args[1];
@@ -160,7 +160,7 @@ struct Q_QML_EXPORT CppStackFrame {
return requiredJSStackFrameSize(v4Function);
}
void setupJSFrame(Value *stackSpace, const Value &function, const Heap::ExecutionContext *scope,
- const Value &thisObject, const Value &newTarget = Primitive::undefinedValue()) {
+ const Value &thisObject, const Value &newTarget = Value::undefinedValue()) {
setupJSFrame(stackSpace, function, scope, thisObject, newTarget,
v4Function->nFormals, v4Function->compiledFunction->nRegisters);
}
@@ -189,7 +189,7 @@ struct Q_QML_EXPORT CppStackFrame {
const Value * tdzEnd = stackSpace + firstDeadZoneRegister + registerDeadZoneSize;
for (Value *v = stackSpace + firstDeadZoneRegister; v < tdzEnd; ++v)
- *v = Primitive::emptyValue().asReturnedValue();
+ *v = Value::emptyValue().asReturnedValue();
}
}
#endif
diff --git a/src/qml/jsruntime/qv4stringiterator.cpp b/src/qml/jsruntime/qv4stringiterator.cpp
index 810ed333e4..62db83ff26 100644
--- a/src/qml/jsruntime/qv4stringiterator.cpp
+++ b/src/qml/jsruntime/qv4stringiterator.cpp
@@ -64,7 +64,7 @@ ReturnedValue StringIteratorPrototype::method_next(const FunctionObject *b, cons
ScopedString s(scope, thisObject->d()->iteratedString);
if (!s) {
- QV4::Value undefined = Primitive::undefinedValue();
+ QV4::Value undefined = Value::undefinedValue();
return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
}
@@ -75,7 +75,7 @@ ReturnedValue StringIteratorPrototype::method_next(const FunctionObject *b, cons
if (index >= len) {
thisObject->d()->iteratedString.set(scope.engine, nullptr);
- QV4::Value undefined = Primitive::undefinedValue();
+ QV4::Value undefined = Value::undefinedValue();
return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
}
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index f6156be0cd..55438465ad 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -74,14 +74,14 @@ void Heap::StringObject::init()
Object::init();
Q_ASSERT(vtable() == QV4::StringObject::staticVTable());
string.set(internalClass->engine, internalClass->engine->id_empty()->d());
- setProperty(internalClass->engine, LengthPropertyIndex, Primitive::fromInt32(0));
+ setProperty(internalClass->engine, LengthPropertyIndex, Value::fromInt32(0));
}
void Heap::StringObject::init(const QV4::String *str)
{
Object::init();
string.set(internalClass->engine, str->d());
- setProperty(internalClass->engine, LengthPropertyIndex, Primitive::fromInt32(length()));
+ setProperty(internalClass->engine, LengthPropertyIndex, Value::fromInt32(length()));
}
Heap::String *Heap::StringObject::getIndex(uint index) const
@@ -283,10 +283,10 @@ void StringPrototype::init(ExecutionEngine *engine, Object *ctor)
Heap::InternalClass *ic = scope.engine->classes[ExecutionEngine::Class_StringObject]->changePrototype(scope.engine->objectPrototype()->d());
d()->internalClass.set(scope.engine, ic);
d()->string.set(scope.engine, scope.engine->id_empty()->d());
- setProperty(scope.engine, Heap::StringObject::LengthPropertyIndex, Primitive::fromInt32(0));
+ setProperty(scope.engine, Heap::StringObject::LengthPropertyIndex, Value::fromInt32(0));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
ctor->defineDefaultProperty(QStringLiteral("fromCharCode"), StringCtor::method_fromCharCode, 1);
ctor->defineDefaultProperty(QStringLiteral("fromCodePoint"), StringCtor::method_fromCodePoint, 1);
ctor->defineDefaultProperty(QStringLiteral("raw"), StringCtor::method_raw, 1);
@@ -446,7 +446,7 @@ ReturnedValue StringPrototype::method_endsWith(const FunctionObject *b, const Va
if (argc && argv[0].as<RegExpObject>())
return v4->throwTypeError();
- QString searchString = (argc ? argv[0] : Primitive::undefinedValue()).toQString();
+ QString searchString = (argc ? argv[0] : Value::undefinedValue()).toQString();
if (v4->hasException)
return Encode::undefined();
@@ -468,7 +468,7 @@ ReturnedValue StringPrototype::method_indexOf(const FunctionObject *b, const Val
if (v4->hasException)
return QV4::Encode::undefined();
- QString searchString = (argc ? argv[0] : Primitive::undefinedValue()).toQString();
+ QString searchString = (argc ? argv[0] : Value::undefinedValue()).toQString();
if (v4->hasException)
return Encode::undefined();
@@ -492,7 +492,7 @@ ReturnedValue StringPrototype::method_includes(const FunctionObject *b, const Va
if (argc && argv[0].as<RegExpObject>())
return v4->throwTypeError();
- QString searchString = (argc ? argv[0] : Primitive::undefinedValue()).toQString();
+ QString searchString = (argc ? argv[0] : Value::undefinedValue()).toQString();
if (v4->hasException)
return Encode::undefined();
@@ -518,7 +518,7 @@ ReturnedValue StringPrototype::method_lastIndexOf(const FunctionObject *b, const
if (v4->hasException)
return QV4::Encode::undefined();
- QString searchString = (argc ? argv[0] : Primitive::undefinedValue()).toQString();
+ QString searchString = (argc ? argv[0] : Value::undefinedValue()).toQString();
if (v4->hasException)
return Encode::undefined();
@@ -544,7 +544,7 @@ ReturnedValue StringPrototype::method_localeCompare(const FunctionObject *b, con
if (v4->hasException)
return QV4::Encode::undefined();
- const QString that = (argc ? argv[0] : Primitive::undefinedValue()).toQString();
+ const QString that = (argc ? argv[0] : Value::undefinedValue()).toQString();
return Encode(QString::localeAwareCompare(value, that));
}
@@ -572,7 +572,7 @@ ReturnedValue StringPrototype::method_match(const FunctionObject *b, const Value
if (v4->hasException)
return Encode::undefined();
- Scoped<RegExpObject> that(scope, argc ? argv[0] : Primitive::undefinedValue());
+ Scoped<RegExpObject> that(scope, argc ? argv[0] : Value::undefinedValue());
if (!that) {
// convert args[0] to a regexp
that = RegExpCtor::virtualCallAsConstructor(b, argv, argc, b);
@@ -703,7 +703,7 @@ ReturnedValue StringPrototype::method_repeat(const FunctionObject *b, const Valu
if (v4->hasException)
return QV4::Encode::undefined();
- double repeats = (argc ? argv[0] : Primitive::undefinedValue()).toInteger();
+ double repeats = (argc ? argv[0] : Value::undefinedValue()).toInteger();
if (repeats < 0 || qIsInf(repeats))
return v4->throwRangeError(QLatin1String("Invalid count value"));
@@ -773,7 +773,7 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
uint *matchOffsets = _matchOffsets;
Scope scope(b);
- ScopedValue searchValue(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue searchValue(scope, argc ? argv[0] : Value::undefinedValue());
Scoped<RegExpObject> regExp(scope, searchValue);
if (regExp) {
uint offset = 0;
@@ -820,7 +820,7 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
QString result;
ScopedValue replacement(scope);
- ScopedValue replaceValue(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue replaceValue(scope, argc > 1 ? argv[1] : Value::undefinedValue());
ScopedFunctionObject searchCallback(scope, replaceValue);
if (!!searchCallback) {
result.reserve(string.length() + 10*numStringMatches);
@@ -832,7 +832,7 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
int idx = (i * numCaptures + k) * 2;
uint start = matchOffsets[idx];
uint end = matchOffsets[idx + 1];
- entry = Primitive::undefinedValue();
+ entry = Value::undefinedValue();
if (start != JSC::Yarr::offsetNoMatch && end != JSC::Yarr::offsetNoMatch)
entry = scope.engine->newString(string.mid(start, end - start));
arguments[k] = entry;
@@ -840,10 +840,10 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
uint matchStart = matchOffsets[i * numCaptures * 2];
Q_ASSERT(matchStart >= static_cast<uint>(lastEnd));
uint matchEnd = matchOffsets[i * numCaptures * 2 + 1];
- arguments[numCaptures] = Primitive::fromUInt32(matchStart);
+ arguments[numCaptures] = Value::fromUInt32(matchStart);
arguments[numCaptures + 1] = scope.engine->newString(string);
- Value that = Primitive::undefinedValue();
+ Value that = Value::undefinedValue();
replacement = searchCallback->call(&that, arguments, numCaptures + 2);
result += string.midRef(lastEnd, matchStart - lastEnd);
result += replacement->toQString();
@@ -882,7 +882,7 @@ ReturnedValue StringPrototype::method_search(const FunctionObject *b, const Valu
if (scope.engine->hasException)
return QV4::Encode::undefined();
- Scoped<RegExpObject> regExp(scope, argc ? argv[0] : Primitive::undefinedValue());
+ Scoped<RegExpObject> regExp(scope, argc ? argv[0] : Value::undefinedValue());
if (!regExp) {
regExp = scope.engine->regExpCtor()->callAsConstructor(argv, 1);
if (scope.engine->hasException)
@@ -939,8 +939,8 @@ ReturnedValue StringPrototype::method_split(const FunctionObject *b, const Value
return QV4::Encode::undefined();
Scope scope(v4);
- ScopedValue separatorValue(scope, argc ? argv[0] : Primitive::undefinedValue());
- ScopedValue limitValue(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue separatorValue(scope, argc ? argv[0] : Value::undefinedValue());
+ ScopedValue limitValue(scope, argc > 1 ? argv[1] : Value::undefinedValue());
ScopedArrayObject array(scope, scope.engine->newArrayObject());
@@ -1023,7 +1023,7 @@ ReturnedValue StringPrototype::method_startsWith(const FunctionObject *b, const
if (argc && argv[0].as<RegExpObject>())
return v4->throwTypeError();
- QString searchString = (argc ? argv[0] : Primitive::undefinedValue()).toQString();
+ QString searchString = (argc ? argv[0] : Value::undefinedValue()).toQString();
if (v4->hasException)
return Encode::undefined();
@@ -1059,8 +1059,8 @@ ReturnedValue StringPrototype::method_substr(const FunctionObject *b, const Valu
length = qMin(qMax(length, 0.0), count - start);
- qint32 x = Primitive::toInt32(start);
- qint32 y = Primitive::toInt32(length);
+ qint32 x = Value::toInt32(start);
+ qint32 y = Value::toInt32(length);
return Encode(v4->newString(value.mid(x, y)));
}
diff --git a/src/qml/jsruntime/qv4symbol.cpp b/src/qml/jsruntime/qv4symbol.cpp
index d5ae094e1f..004a9938e2 100644
--- a/src/qml/jsruntime/qv4symbol.cpp
+++ b/src/qml/jsruntime/qv4symbol.cpp
@@ -88,7 +88,7 @@ ReturnedValue SymbolCtor::virtualCallAsConstructor(const FunctionObject *f, cons
ReturnedValue SymbolCtor::method_for(const FunctionObject *f, const Value *, const Value *argv, int argc)
{
Scope scope(f);
- ScopedValue k(scope, argc ? argv[0]: Primitive::undefinedValue());
+ ScopedValue k(scope, argc ? argv[0]: Value::undefinedValue());
ScopedString key(scope, k->toString(scope.engine));
if (scope.hasException())
return Encode::undefined();
@@ -114,7 +114,7 @@ void SymbolPrototype::init(ExecutionEngine *engine, Object *ctor)
Scope scope(engine);
ScopedValue v(scope);
ctor->defineReadonlyProperty(engine->id_prototype(), (v = this));
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(0));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(0));
ctor->defineDefaultProperty(QStringLiteral("for"), SymbolCtor::method_for, 1);
ctor->defineDefaultProperty(QStringLiteral("keyFor"), SymbolCtor::method_keyFor, 1);
diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp
index a4d32ec06b..9d052456ef 100644
--- a/src/qml/jsruntime/qv4typedarray.cpp
+++ b/src/qml/jsruntime/qv4typedarray.cpp
@@ -318,7 +318,7 @@ ReturnedValue TypedArrayCtor::virtualCallAsConstructor(const FunctionObject *f,
updateProto(scope, array);
return array.asReturnedValue();
}
- Scoped<TypedArray> typedArray(scope, argc ? argv[0] : Primitive::undefinedValue());
+ Scoped<TypedArray> typedArray(scope, argc ? argv[0] : Value::undefinedValue());
if (!!typedArray) {
// ECMA 6 22.2.1.2
Scoped<ArrayBuffer> buffer(scope, typedArray->d()->buffer);
@@ -350,7 +350,7 @@ ReturnedValue TypedArrayCtor::virtualCallAsConstructor(const FunctionObject *f,
TypedArrayOperations::Read read = typedArray->d()->type->read;
TypedArrayOperations::Write write =array->d()->type->write;
for (uint i = 0; i < l; ++i) {
- Primitive val;
+ Value val;
val.setRawValue(read(src + i*srcElementSize));
write(dest + i*destElementSize, val);
}
@@ -359,7 +359,7 @@ ReturnedValue TypedArrayCtor::virtualCallAsConstructor(const FunctionObject *f,
updateProto(scope, array);
return array.asReturnedValue();
}
- Scoped<ArrayBuffer> buffer(scope, argc ? argv[0] : Primitive::undefinedValue());
+ Scoped<ArrayBuffer> buffer(scope, argc ? argv[0] : Value::undefinedValue());
if (!!buffer) {
// ECMA 6 22.2.1.4
@@ -401,7 +401,7 @@ ReturnedValue TypedArrayCtor::virtualCallAsConstructor(const FunctionObject *f,
// ECMA 6 22.2.1.3
- ScopedObject o(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedObject o(scope, argc ? argv[0] : Value::undefinedValue());
uint l = (uint) qBound(0., ScopedValue(scope, o->get(scope.engine->id_length()))->toInteger(), (double)UINT_MAX);
if (scope.engine->hasException)
return scope.engine->throwTypeError();
@@ -538,7 +538,7 @@ bool TypedArray::virtualPut(Managed *m, PropertyKey id, const Value &value, Valu
uint byteOffset = a->d()->byteOffset + index * bytesPerElement;
Q_ASSERT(byteOffset + bytesPerElement <= (uint)a->d()->buffer->byteLength());
- Value v = Primitive::fromReturnedValue(value.convertedToNumber());
+ Value v = Value::fromReturnedValue(value.convertedToNumber());
if (scope.hasException() || a->d()->buffer->isDetachedBuffer())
return scope.engine->throwTypeError();
a->d()->type->write(a->d()->buffer->data->data() + byteOffset, v);
@@ -565,7 +565,7 @@ bool TypedArray::virtualDefineOwnProperty(Managed *m, PropertyKey id, const Prop
if (!p->value.isEmpty()) {
ExecutionEngine *engine = a->engine();
- Value v = Primitive::fromReturnedValue(p->value.convertedToNumber());
+ Value v = Value::fromReturnedValue(p->value.convertedToNumber());
if (engine->hasException || a->d()->buffer->isDetachedBuffer())
return engine->throwTypeError();
uint bytesPerElement = a->d()->type->bytesPerElement;
@@ -613,14 +613,14 @@ void TypedArrayPrototype::init(ExecutionEngine *engine, TypedArrayCtor *ctor)
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(3));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(3));
ctor->defineReadonlyProperty(engine->id_prototype(), *this);
- ctor->defineReadonlyProperty(QStringLiteral("BYTES_PER_ELEMENT"), Primitive::fromInt32(operations[static_cast<int>(ctor->d()->type)].bytesPerElement));
+ ctor->defineReadonlyProperty(QStringLiteral("BYTES_PER_ELEMENT"), Value::fromInt32(operations[static_cast<int>(ctor->d()->type)].bytesPerElement));
ctor->setPrototypeOf(engine->intrinsicTypedArrayCtor());
setPrototypeOf(engine->intrinsicTypedArrayPrototype());
defineDefaultProperty(engine->id_constructor(), (o = ctor));
- defineReadonlyProperty(QStringLiteral("BYTES_PER_ELEMENT"), Primitive::fromInt32(operations[static_cast<int>(ctor->d()->type)].bytesPerElement));
+ defineReadonlyProperty(QStringLiteral("BYTES_PER_ELEMENT"), Value::fromInt32(operations[static_cast<int>(ctor->d()->type)].bytesPerElement));
}
ReturnedValue IntrinsicTypedArrayPrototype::method_get_buffer(const FunctionObject *b, const Value *thisObject, const Value *, int)
@@ -747,7 +747,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_every(const FunctionObject *b
THROW_TYPE_ERROR();
const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
ScopedValue r(scope);
Value *arguments = scope.alloc(3);
@@ -762,7 +762,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_every(const FunctionObject *b
arguments[0] = v->d()->type->read(data + byteOffset + k * bytesPerElement);
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = v;
r = callback->call(that, arguments, 3);
ok = r->toBoolean();
@@ -800,7 +800,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_fill(const FunctionObject *b,
}
double val = argc ? argv[0].toNumber() : std::numeric_limits<double>::quiet_NaN();
- Value value = Primitive::fromDouble(val);
+ Value value = Value::fromDouble(val);
if (scope.hasException() || v->d()->buffer->isDetachedBuffer())
return scope.engine->throwTypeError();
@@ -848,7 +848,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_filter(const FunctionObject *
const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
ScopedValue selected(scope);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
Value *arguments = scope.alloc(3);
Value *list = arguments;
@@ -861,7 +861,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_filter(const FunctionObject *
if (!exists)
continue;
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
selected = callback->call(that, arguments, 3);
if (selected->toBoolean()) {
@@ -897,7 +897,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_find(const FunctionObject *b,
ScopedValue result(scope);
Value *arguments = scope.alloc(3);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
for (uint k = 0; k < len; ++k) {
if (v->d()->buffer->isDetachedBuffer())
@@ -905,7 +905,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_find(const FunctionObject *b,
arguments[0] = v->get(k);
CHECK_EXCEPTION();
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = v;
result = callback->call(that, arguments, 3);
@@ -933,7 +933,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_findIndex(const FunctionObjec
ScopedValue result(scope);
Value *arguments = scope.alloc(3);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
for (uint k = 0; k < len; ++k) {
if (v->d()->buffer->isDetachedBuffer())
@@ -941,7 +941,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_findIndex(const FunctionObjec
arguments[0] = v->get(k);
CHECK_EXCEPTION();
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = v;
result = callback->call(that, arguments, 3);
@@ -966,7 +966,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_forEach(const FunctionObject
THROW_TYPE_ERROR();
const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
Value *arguments = scope.alloc(3);
for (uint k = 0; k < len; ++k) {
@@ -977,7 +977,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_forEach(const FunctionObject
if (!exists)
continue;
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = v;
callback->call(that, arguments, 3);
}
@@ -1034,7 +1034,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_indexOf(const FunctionObject
if (!len)
return Encode(-1);
- ScopedValue searchValue(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue searchValue(scope, argc ? argv[0] : Value::undefinedValue());
uint fromIndex = 0;
if (argc >= 2) {
@@ -1079,7 +1079,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_join(const FunctionObject *b,
uint len = v->length();
- ScopedValue arg(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue arg(scope, argc ? argv[0] : Value::undefinedValue());
QString r4;
if (arg->isUndefined())
@@ -1106,7 +1106,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_join(const FunctionObject *b,
for (quint32 k = 1; k < r2; ++k) {
R += r4;
- name = Primitive::fromDouble(k).toString(scope.engine);
+ name = Value::fromDouble(k).toString(scope.engine);
r12 = v->get(name);
CHECK_EXCEPTION();
@@ -1147,7 +1147,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_lastIndexOf(const FunctionObj
if (argc >= 1)
searchValue = argv[0];
else
- searchValue = Primitive::undefinedValue();
+ searchValue = Value::undefinedValue();
if (argc >= 2) {
double f = argv[1].toInteger();
@@ -1192,7 +1192,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_map(const FunctionObject *b,
ScopedValue v(scope);
ScopedValue mapped(scope);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
Value *arguments = scope.alloc(3);
for (uint k = 0; k < len; ++k) {
@@ -1200,7 +1200,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_map(const FunctionObject *b,
return scope.engine->throwTypeError();
arguments[0] = instance->get(k);
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
mapped = callback->call(that, arguments, 3);
a->put(k, mapped);
@@ -1249,7 +1249,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_reduce(const FunctionObject *
if (kPresent) {
arguments[0] = acc;
arguments[1] = v;
- arguments[2] = Primitive::fromDouble(k);
+ arguments[2] = Value::fromDouble(k);
arguments[3] = instance;
acc = callback->call(nullptr, arguments, 4);
}
@@ -1304,7 +1304,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_reduceRight(const FunctionObj
if (kPresent) {
arguments[0] = acc;
arguments[1] = v;
- arguments[2] = Primitive::fromDouble(k - 1);
+ arguments[2] = Value::fromDouble(k - 1);
arguments[3] = instance;
acc = callback->call(nullptr, arguments, 4);
}
@@ -1353,7 +1353,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_some(const FunctionObject *b,
THROW_TYPE_ERROR();
const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
ScopedValue result(scope);
Value *arguments = scope.alloc(3);
@@ -1365,7 +1365,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_some(const FunctionObject *b,
if (!exists)
continue;
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
result = callback->call(that, arguments, 3);
if (result->toBoolean())
@@ -1472,7 +1472,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_set(const FunctionObject *b,
TypedArrayOperations::Read read = srcTypedArray->d()->type->read;
TypedArrayOperations::Write write = a->d()->type->write;
for (uint i = 0; i < l; ++i) {
- Primitive val;
+ Value val;
val.setRawValue(read(src + i*srcElementSize));
write(dest + i*elementSize, val);
}
@@ -1492,7 +1492,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_slice(const FunctionObject *b
uint len = instance->length();
- double s = (argc ? argv[0] : Primitive::undefinedValue()).toInteger();
+ double s = (argc ? argv[0] : Value::undefinedValue()).toInteger();
uint start;
if (s < 0)
start = (uint)qMax(len + s, 0.);
@@ -1633,7 +1633,7 @@ ReturnedValue IntrinsicTypedArrayCtor::method_of(const FunctionObject *f, const
if (!C || !C->isConstructor())
return scope.engine->throwTypeError();
- Value lenValue = Primitive::fromInt32(len);
+ Value lenValue = Value::fromInt32(len);
ScopedObject newObj(scope, C->callAsConstructor(&lenValue, 1));
if (scope.hasException())
return Encode::undefined();
@@ -1654,7 +1654,7 @@ void IntrinsicTypedArrayPrototype::init(ExecutionEngine *engine, IntrinsicTypedA
{
Scope scope(engine);
ctor->defineReadonlyProperty(engine->id_prototype(), *this);
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(0));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(0));
ScopedString s(scope, engine->newString(QStringLiteral("TypedArray")));
ctor->defineReadonlyConfigurableProperty(engine->id_name(), s);
s = scope.engine->newString(QStringLiteral("of"));
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index 305b8c6bab..7c895e3637 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -70,7 +70,6 @@ namespace Heap {
struct Q_QML_PRIVATE_EXPORT Value
{
-private:
/*
We use 8 bytes for a value and a different variant of NaN boxing. A Double
NaN (actually -qNaN) is indicated by a number that has the top 13 bits set, and for a
@@ -126,10 +125,9 @@ private:
quint64 _val;
-public:
- QML_NEARLY_ALWAYS_INLINE quint64 &rawValueRef() { return _val; }
- QML_NEARLY_ALWAYS_INLINE quint64 rawValue() const { return _val; }
- QML_NEARLY_ALWAYS_INLINE void setRawValue(quint64 raw) { _val = raw; }
+ QML_NEARLY_ALWAYS_INLINE Q_DECL_RELAXED_CONSTEXPR quint64 &rawValueRef() { return _val; }
+ QML_NEARLY_ALWAYS_INLINE Q_DECL_RELAXED_CONSTEXPR quint64 rawValue() const { return _val; }
+ QML_NEARLY_ALWAYS_INLINE Q_DECL_RELAXED_CONSTEXPR void setRawValue(quint64 raw) { _val = raw; }
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
static inline int valueOffset() { return 0; }
@@ -138,10 +136,11 @@ public:
static inline int valueOffset() { return 4; }
static inline int tagOffset() { return 0; }
#endif
- QML_NEARLY_ALWAYS_INLINE void setTagValue(quint32 tag, quint32 value) { _val = quint64(tag) << 32 | value; }
- QML_NEARLY_ALWAYS_INLINE quint32 value() const { return _val & quint64(~quint32(0)); }
- QML_NEARLY_ALWAYS_INLINE quint32 tag() const { return _val >> 32; }
- QML_NEARLY_ALWAYS_INLINE void setTag(quint32 tag) { setTagValue(tag, value()); }
+ static inline constexpr quint64 tagValue(quint32 tag, quint32 value) { return quint64(tag) << 32 | value; }
+ QML_NEARLY_ALWAYS_INLINE Q_DECL_RELAXED_CONSTEXPR void setTagValue(quint32 tag, quint32 value) { _val = quint64(tag) << 32 | value; }
+ QML_NEARLY_ALWAYS_INLINE constexpr quint32 value() const { return _val & quint64(~quint32(0)); }
+ QML_NEARLY_ALWAYS_INLINE constexpr quint32 tag() const { return _val >> 32; }
+ QML_NEARLY_ALWAYS_INLINE Q_DECL_RELAXED_CONSTEXPR void setTag(quint32 tag) { setTagValue(tag, value()); }
#if QT_POINTER_SIZE == 8
QML_NEARLY_ALWAYS_INLINE Heap::Base *m() const
@@ -173,17 +172,17 @@ public:
# error "unsupported pointer size"
#endif
- QML_NEARLY_ALWAYS_INLINE int int_32() const
+ QML_NEARLY_ALWAYS_INLINE constexpr int int_32() const
{
return int(value());
}
- QML_NEARLY_ALWAYS_INLINE void setInt_32(int i)
+ QML_NEARLY_ALWAYS_INLINE Q_DECL_RELAXED_CONSTEXPR void setInt_32(int i)
{
setTagValue(quint32(ValueTypeInternal::Integer), quint32(i));
}
QML_NEARLY_ALWAYS_INLINE uint uint_32() const { return value(); }
- QML_NEARLY_ALWAYS_INLINE void setEmpty()
+ QML_NEARLY_ALWAYS_INLINE Q_DECL_RELAXED_CONSTEXPR void setEmpty()
{
setTagValue(quint32(ValueTypeInternal::Empty), 0);
}
@@ -474,7 +473,7 @@ public:
#endif
ReturnedValue *data_ptr() { return &_val; }
- ReturnedValue asReturnedValue() const { return _val; }
+ constexpr ReturnedValue asReturnedValue() const { return _val; }
static Value fromReturnedValue(ReturnedValue val) { Value v; v._val = val; return v; }
// As per ES specs
@@ -483,6 +482,18 @@ public:
inline void mark(MarkStack *markStack);
+ inline static constexpr Value emptyValue() { return { tagValue(quint32(ValueTypeInternal::Empty), 0) }; }
+ static inline constexpr Value fromBoolean(bool b) { return { tagValue(quint32(ValueTypeInternal::Boolean), b) }; }
+ static inline constexpr Value fromInt32(int i) { return { tagValue(quint32(ValueTypeInternal::Integer), quint32(i)) }; }
+ inline static constexpr Value undefinedValue() { return { 0 }; }
+ static inline constexpr Value nullValue() { return { tagValue(quint32(ValueTypeInternal::Null), 0) }; }
+ static inline Value fromDouble(double d);
+ static inline Value fromUInt32(uint i);
+
+ static double toInteger(double d);
+ static int toInt32(double d);
+ static unsigned int toUInt32(double d);
+
Value &operator =(const ScopedValue &v);
Value &operator=(ReturnedValue v) { _val = v; return *this; }
Value &operator=(Managed *m) {
@@ -570,71 +581,16 @@ ReturnedValue Heap::Base::asReturnedValue() const
return Value::fromHeapObject(const_cast<Heap::Base *>(this)).asReturnedValue();
}
-
-
-struct Q_QML_PRIVATE_EXPORT Primitive : public Value
-{
- inline static Primitive emptyValue();
- static inline Primitive fromBoolean(bool b);
- static inline Primitive fromInt32(int i);
- inline static Primitive undefinedValue();
- static inline Primitive nullValue();
- static inline Primitive fromDouble(double d);
- static inline Primitive fromUInt32(uint i);
-
- using Value::toInt32;
- using Value::toUInt32;
-
- static double toInteger(double d);
- static int toInt32(double d);
- static unsigned int toUInt32(double d);
-};
-
-inline Primitive Primitive::undefinedValue()
-{
- Primitive v;
- v.setM(nullptr);
- return v;
-}
-
-inline Primitive Primitive::emptyValue()
-{
- Primitive v;
- v.setEmpty();
- return v;
-}
-
-inline Primitive Primitive::nullValue()
-{
- Primitive v;
- v.setTagValue(quint32(ValueTypeInternal::Null), 0);
- return v;
-}
-
-inline Primitive Primitive::fromBoolean(bool b)
+inline Value Value::fromDouble(double d)
{
- Primitive v;
- v.setTagValue(quint32(ValueTypeInternal::Boolean), b);
- return v;
-}
-
-inline Primitive Primitive::fromDouble(double d)
-{
- Primitive v;
+ Value v;
v.setDouble(d);
return v;
}
-inline Primitive Primitive::fromInt32(int i)
+inline Value Value::fromUInt32(uint i)
{
- Primitive v;
- v.setInt_32(i);
- return v;
-}
-
-inline Primitive Primitive::fromUInt32(uint i)
-{
- Primitive v;
+ Value v;
if (i < INT_MAX) {
v.setTagValue(quint32(ValueTypeInternal::Integer), i);
} else {
@@ -690,7 +646,7 @@ struct Double {
}
};
-inline double Primitive::toInteger(double d)
+inline double Value::toInteger(double d)
{
if (std::isnan(d))
return +0;
@@ -699,41 +655,48 @@ inline double Primitive::toInteger(double d)
return d >= 0 ? std::floor(d) : std::ceil(d);
}
-inline int Primitive::toInt32(double value)
+inline int Value::toInt32(double value)
{
return Double::toInt32(value);
}
-inline unsigned int Primitive::toUInt32(double d)
+inline unsigned int Value::toUInt32(double d)
{
return static_cast<uint>(toInt32(d));
}
+// For source compat with older code in other modules
+using Primitive = Value;
+
struct Encode {
static constexpr ReturnedValue undefined() {
- return 0;
+ return Value::undefinedValue().asReturnedValue();
}
- static ReturnedValue null() {
- return Primitive::nullValue().rawValue();
+ static constexpr ReturnedValue null() {
+ return Value::nullValue().asReturnedValue();
}
- explicit Encode(bool b) {
- val = Primitive::fromBoolean(b).rawValue();
+ explicit constexpr Encode(bool b)
+ : val(Value::fromBoolean(b).asReturnedValue())
+ {
}
explicit Encode(double d) {
- val = Primitive::fromDouble(d).rawValue();
+ val = Value::fromDouble(d).asReturnedValue();
}
- explicit Encode(int i) {
- val = Primitive::fromInt32(i).rawValue();
+ explicit constexpr Encode(int i)
+ : val(Value::fromInt32(i).asReturnedValue())
+ {
}
explicit Encode(uint i) {
- val = Primitive::fromUInt32(i).rawValue();
+ val = Value::fromUInt32(i).asReturnedValue();
}
- explicit Encode(ReturnedValue v) {
- val = v;
+ explicit constexpr Encode(ReturnedValue v)
+ : val(v)
+ {
}
- Encode(Value v) {
- val = v.rawValue();
+ constexpr Encode(Value v)
+ : val(v.asReturnedValue())
+ {
}
explicit Encode(Heap::Base *o) {
@@ -752,7 +715,7 @@ struct Encode {
return Encode(d);
}
- operator ReturnedValue() const {
+ constexpr operator ReturnedValue() const {
return val;
}
quint64 val;
@@ -783,7 +746,7 @@ inline qint64 Value::toLength() const
{
if (Q_LIKELY(integerCompatible()))
return int_32() < 0 ? 0 : int_32();
- double i = Primitive::toInteger(isDouble() ? doubleValue() : toNumberImpl());
+ double i = Value::toInteger(isDouble() ? doubleValue() : toNumberImpl());
if (i <= 0)
return 0;
if (i > (static_cast<qint64>(1) << 53) - 1)
@@ -797,7 +760,7 @@ inline qint64 Value::toIndex() const
if (Q_LIKELY(integerCompatible())) {
idx = int_32();
} else {
- idx = static_cast<qint64>(Primitive::toInteger(isDouble() ? doubleValue() : toNumberImpl()));
+ idx = static_cast<qint64>(Value::toInteger(isDouble() ? doubleValue() : toNumberImpl()));
}
if (idx > (static_cast<qint64>(1) << 53) - 1)
idx = -1;
@@ -809,7 +772,7 @@ inline double Value::toInteger() const
if (integerCompatible())
return int_32();
- return Primitive::toInteger(isDouble() ? doubleValue() : toNumberImpl());
+ return Value::toInteger(isDouble() ? doubleValue() : toNumberImpl());
}
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index 07eb054350..f81c8438ce 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -377,7 +377,7 @@ static bool compareEqualInt(QV4::Value &accumulator, QV4::Value lhs, int rhs)
if (lhs.m()->internalClass->vtable->isString)
return RuntimeHelpers::stringToNumber(static_cast<String &>(lhs).toQString()) == rhs;
accumulator = lhs;
- lhs = Primitive::fromReturnedValue(RuntimeHelpers::objectDefaultValue(&static_cast<QV4::Object &>(accumulator), PREFERREDTYPE_HINT));
+ lhs = Value::fromReturnedValue(RuntimeHelpers::objectDefaultValue(&static_cast<QV4::Object &>(accumulator), PREFERREDTYPE_HINT));
goto redo;
case QV4::Value::QT_Empty:
Q_UNREACHABLE();
@@ -393,7 +393,7 @@ static bool compareEqualInt(QV4::Value &accumulator, QV4::Value lhs, int rhs)
#define STORE_IP() frame->instructionPointer = int(code - function->codeData);
#define STORE_ACC() accumulator = acc;
-#define ACC Primitive::fromReturnedValue(acc)
+#define ACC Value::fromReturnedValue(acc)
#define VALUE_TO_INT(i, val) \
int i; \
do { \
@@ -675,10 +675,10 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
// check exception, in case the generator was called with throw() or return()
if (engine->hasException) {
// an empty value indicates that the generator was called with return()
- if (engine->exceptionValue->asReturnedValue() != Primitive::emptyValue().asReturnedValue())
+ if (engine->exceptionValue->asReturnedValue() != Value::emptyValue().asReturnedValue())
goto handleUnwind;
engine->hasException = false;
- *engine->exceptionValue = Primitive::undefinedValue();
+ *engine->exceptionValue = Value::undefinedValue();
} else {
code += offset;
}
@@ -697,7 +697,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
acc = engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow()));
goto handleUnwind;
}
- Value undef = Primitive::undefinedValue();
+ Value undef = Value::undefinedValue();
acc = static_cast<const FunctionObject &>(func).call(&undef, stack + argv, argc);
CHECK_EXCEPTION;
MOTH_END_INSTR(CallValue)
@@ -826,12 +826,12 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
MOTH_BEGIN_INSTR(GetException)
acc = engine->hasException ? engine->exceptionValue->asReturnedValue()
- : Primitive::emptyValue().asReturnedValue();
+ : Value::emptyValue().asReturnedValue();
engine->hasException = false;
MOTH_END_INSTR(HasException)
MOTH_BEGIN_INSTR(SetException)
- if (acc != Primitive::emptyValue().asReturnedValue()) {
+ if (acc != Value::emptyValue().asReturnedValue()) {
*engine->exceptionValue = acc;
engine->hasException = true;
}
@@ -1352,13 +1352,13 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
MOTH_END_INSTR(Ret)
MOTH_BEGIN_INSTR(InitializeBlockDeadTemporalZone)
- acc = Encode(Primitive::emptyValue());
+ acc = Encode(Value::emptyValue());
for (int i = firstReg, end = firstReg + count; i < end; ++i)
STACK_VALUE(i) = acc;
MOTH_END_INSTR(InitializeBlockDeadTemporalZone)
MOTH_BEGIN_INSTR(ThrowOnNullOrUndefined)
- if (Primitive::fromReturnedValue(acc).isNullOrUndefined()) {
+ if (Value::fromReturnedValue(acc).isNullOrUndefined()) {
engine->throwTypeError();
goto handleUnwind;
}