aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-01-15 21:54:12 +0100
committerLars Knoll <lars.knoll@digia.com>2015-01-23 12:30:38 +0100
commitef6b4938b9ec309d5faf0c966cb2b58f3de2ca77 (patch)
tree3d946ad66defb1ec5c60a50e16b6e7883ec33862 /src/qml/jsruntime
parent3dbf4e9a6979802fff55e2f5e6aa54a14280e128 (diff)
Cleanups
Simplify some code in BooleanObject Simplify access to call arguments and thisObject Change-Id: I2f8e844019bc587385608beb02f05b15f827535c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4argumentsobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4arraybuffer.cpp10
-rw-r--r--src/qml/jsruntime/qv4arraydata.cpp4
-rw-r--r--src/qml/jsruntime/qv4arraydata_p.h6
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp110
-rw-r--r--src/qml/jsruntime/qv4booleanobject.cpp21
-rw-r--r--src/qml/jsruntime/qv4context.cpp6
-rw-r--r--src/qml/jsruntime/qv4context_p.h15
-rw-r--r--src/qml/jsruntime/qv4dataview.cpp56
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp132
-rw-r--r--src/qml/jsruntime/qv4engine.cpp4
-rw-r--r--src/qml/jsruntime/qv4engine_p.h2
-rw-r--r--src/qml/jsruntime/qv4errorobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp24
-rw-r--r--src/qml/jsruntime/qv4globalobject.cpp38
-rw-r--r--src/qml/jsruntime/qv4include.cpp8
-rw-r--r--src/qml/jsruntime/qv4mathobject.cpp48
-rw-r--r--src/qml/jsruntime/qv4numberobject.cpp32
-rw-r--r--src/qml/jsruntime/qv4object_p.h16
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp42
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp28
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp10
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp2
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp14
-rw-r--r--src/qml/jsruntime/qv4sequenceobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp68
-rw-r--r--src/qml/jsruntime/qv4typedarray.cpp22
-rw-r--r--src/qml/jsruntime/qv4variantobject.cpp10
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp2
29 files changed, 375 insertions, 365 deletions
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp
index f48ab9e39d..82a6fd58e2 100644
--- a/src/qml/jsruntime/qv4argumentsobject.cpp
+++ b/src/qml/jsruntime/qv4argumentsobject.cpp
@@ -60,8 +60,8 @@ Heap::ArgumentsObject::ArgumentsObject(QV4::CallContext *context)
args->propertyAt(CallerPropertyIndex)->value = v4->thrower;
args->propertyAt(CallerPropertyIndex)->set = v4->thrower;
- args->arrayReserve(context->d()->callData->argc);
- args->arrayPut(0, context->d()->callData->args, context->d()->callData->argc);
+ args->arrayReserve(context->argc());
+ args->arrayPut(0, context->args(), context->argc());
args->d()->fullyCreated = true;
} else {
Q_ASSERT(CalleePropertyIndex == args->internalClass()->find(context->d()->engine->id_callee));
diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp
index 5d2c95bed4..e288023b80 100644
--- a/src/qml/jsruntime/qv4arraybuffer.cpp
+++ b/src/qml/jsruntime/qv4arraybuffer.cpp
@@ -123,7 +123,7 @@ void ArrayBufferPrototype::init(ExecutionEngine *engine, Object *ctor)
ReturnedValue ArrayBufferPrototype::method_get_byteLength(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<ArrayBuffer> v(scope, ctx->d()->callData->thisObject);
+ Scoped<ArrayBuffer> v(scope, ctx->thisObject());
if (!v)
return scope.engine->throwTypeError();
@@ -133,13 +133,13 @@ ReturnedValue ArrayBufferPrototype::method_get_byteLength(CallContext *ctx)
ReturnedValue ArrayBufferPrototype::method_slice(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<ArrayBuffer> a(scope, ctx->d()->callData->thisObject);
+ Scoped<ArrayBuffer> a(scope, ctx->thisObject());
if (!a)
return scope.engine->throwTypeError();
- double start = ctx->d()->callData->argc > 0 ? ctx->d()->callData->args[0].toInteger() : 0;
- double end = (ctx->d()->callData->argc < 2 || ctx->d()->callData->args[1].isUndefined()) ?
- a->d()->data->size : ctx->d()->callData->args[1].toInteger();
+ double start = ctx->argc() > 0 ? ctx->args()[0].toInteger() : 0;
+ double end = (ctx->argc() < 2 || ctx->args()[1].isUndefined()) ?
+ a->d()->data->size : ctx->args()[1].toInteger();
if (scope.engine->hasException)
return Encode::undefined();
diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp
index 68c289a52d..d3239b6098 100644
--- a/src/qml/jsruntime/qv4arraydata.cpp
+++ b/src/qml/jsruntime/qv4arraydata.cpp
@@ -265,7 +265,7 @@ void SimpleArrayData::setAttribute(Object *o, uint index, PropertyAttributes att
o->arrayData()->attrs[index] = attrs;
}
-void SimpleArrayData::push_front(Object *o, Value *values, uint n)
+void SimpleArrayData::push_front(Object *o, const Value *values, uint n)
{
Heap::SimpleArrayData *dd = static_cast<Heap::SimpleArrayData *>(o->d()->arrayData);
Q_ASSERT(!dd->attrs);
@@ -484,7 +484,7 @@ void SparseArrayData::setAttribute(Object *o, uint index, PropertyAttributes att
d->attrs[n->value] = attrs;
}
-void SparseArrayData::push_front(Object *o, Value *values, uint n)
+void SparseArrayData::push_front(Object *o, const Value *values, uint n)
{
Heap::SparseArrayData *d = static_cast<Heap::SparseArrayData *>(o->d()->arrayData);
Q_ASSERT(!d->attrs);
diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h
index 5ae3883647..7421b7b236 100644
--- a/src/qml/jsruntime/qv4arraydata_p.h
+++ b/src/qml/jsruntime/qv4arraydata_p.h
@@ -65,7 +65,7 @@ struct ArrayVTable
bool (*putArray)(Object *o, uint index, const Value *values, uint n);
bool (*del)(Object *o, uint index);
void (*setAttribute)(Object *o, uint index, PropertyAttributes attrs);
- void (*push_front)(Object *o, Value *values, uint n);
+ void (*push_front)(Object *o, const Value *values, uint n);
ReturnedValue (*pop_front)(Object *o);
uint (*truncate)(Object *o, uint newLen);
uint (*length)(const Heap::ArrayData *d);
@@ -228,7 +228,7 @@ struct Q_QML_EXPORT SimpleArrayData : public ArrayData
static bool putArray(Object *o, uint index, const Value *values, uint n);
static bool del(Object *o, uint index);
static void setAttribute(Object *o, uint index, PropertyAttributes attrs);
- static void push_front(Object *o, Value *values, uint n);
+ static void push_front(Object *o, const Value *values, uint n);
static ReturnedValue pop_front(Object *o);
static uint truncate(Object *o, uint newLen);
static uint length(const Heap::ArrayData *d);
@@ -257,7 +257,7 @@ struct Q_QML_EXPORT SparseArrayData : public ArrayData
static bool putArray(Object *o, uint index, const Value *values, uint n);
static bool del(Object *o, uint index);
static void setAttribute(Object *o, uint index, PropertyAttributes attrs);
- static void push_front(Object *o, Value *values, uint n);
+ static void push_front(Object *o, const Value *values, uint n);
static ReturnedValue pop_front(Object *o);
static uint truncate(Object *o, uint newLen);
static uint length(const Heap::ArrayData *d);
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index 0361d0e628..6b39c4f68e 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -110,21 +110,21 @@ void ArrayPrototype::init(ExecutionEngine *engine, Object *ctor)
ReturnedValue ArrayPrototype::method_isArray(CallContext *ctx)
{
- bool isArray = ctx->d()->callData->argc && ctx->d()->callData->args[0].asArrayObject();
+ bool isArray = ctx->argc() && ctx->args()[0].asArrayObject();
return Encode(isArray);
}
ReturnedValue ArrayPrototype::method_toString(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject o(scope, ctx->d()->callData->thisObject, ScopedObject::Convert);
+ ScopedObject o(scope, ctx->thisObject(), ScopedObject::Convert);
if (ctx->d()->engine->hasException)
return Encode::undefined();
ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("join")));
ScopedFunctionObject f(scope, o->get(s));
if (!!f) {
ScopedCallData d(scope, 0);
- d->thisObject = ctx->d()->callData->thisObject;
+ d->thisObject = ctx->thisObject();
return f->call(d);
}
return ObjectPrototype::method_toString(ctx);
@@ -140,7 +140,7 @@ ReturnedValue ArrayPrototype::method_concat(CallContext *ctx)
Scope scope(ctx);
ScopedObject result(scope, ctx->d()->engine->newArrayObject());
- ScopedObject thisObject(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject thisObject(scope, ctx->thisObject().toObject(scope.engine));
if (!thisObject)
return Encode::undefined();
if (thisObject->isArrayObject()) {
@@ -152,9 +152,9 @@ ReturnedValue ArrayPrototype::method_concat(CallContext *ctx)
ScopedArrayObject elt(scope);
ScopedObject eltAsObj(scope);
ScopedValue entry(scope);
- for (int i = 0; i < ctx->d()->callData->argc; ++i) {
- eltAsObj = ctx->d()->callData->args[i];
- elt = ctx->d()->callData->args[i];
+ for (int i = 0; i < ctx->argc(); ++i) {
+ eltAsObj = ctx->args()[i];
+ elt = ctx->args()[i];
if (elt) {
uint n = elt->getLength();
uint newLen = ArrayData::append(result, elt, n);
@@ -166,7 +166,7 @@ ReturnedValue ArrayPrototype::method_concat(CallContext *ctx)
result->putIndexed(startIndex + i, entry);
}
} else {
- result->arraySet(result->getLength(), ctx->d()->callData->args[i]);
+ result->arraySet(result->getLength(), ctx->args()[i]);
}
}
@@ -184,7 +184,7 @@ ReturnedValue ArrayPrototype::method_join(CallContext *ctx)
else
r4 = arg->toQString();
- ScopedObject self(scope, ctx->d()->callData->thisObject);
+ ScopedObject self(scope, ctx->thisObject());
ScopedValue length(scope, self->get(ctx->d()->engine->id_length));
const quint32 r2 = length->isUndefined() ? 0 : length->toUInt32();
@@ -235,7 +235,7 @@ ReturnedValue ArrayPrototype::method_join(CallContext *ctx)
ReturnedValue ArrayPrototype::method_pop(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
uint len = instance->getLength();
@@ -263,7 +263,7 @@ ReturnedValue ArrayPrototype::method_pop(CallContext *ctx)
ReturnedValue ArrayPrototype::method_push(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
@@ -272,15 +272,15 @@ ReturnedValue ArrayPrototype::method_push(CallContext *ctx)
uint len = instance->getLength();
- if (len + ctx->d()->callData->argc < len) {
+ if (len + ctx->argc() < len) {
// ughh...
double l = len;
ScopedString s(scope);
- for (int i = 0; i < ctx->d()->callData->argc; ++i) {
+ for (int i = 0; i < ctx->argc(); ++i) {
s = Primitive::fromDouble(l + i).toString(scope.engine);
- instance->put(s, ctx->d()->callData->args[i]);
+ instance->put(s, ctx->args()[i]);
}
- double newLen = l + ctx->d()->callData->argc;
+ double newLen = l + ctx->argc();
if (!instance->isArrayObject())
instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(newLen)));
else {
@@ -290,15 +290,15 @@ ReturnedValue ArrayPrototype::method_push(CallContext *ctx)
return Encode(newLen);
}
- if (!ctx->d()->callData->argc)
+ if (!ctx->argc())
;
else if (!instance->protoHasArray() && instance->arrayData()->length() <= len && instance->arrayData()->type == Heap::ArrayData::Simple) {
- instance->arrayData()->vtable()->putArray(instance, len, ctx->d()->callData->args, ctx->d()->callData->argc);
+ instance->arrayData()->vtable()->putArray(instance, len, ctx->args(), ctx->argc());
len = instance->arrayData()->length();
} else {
- for (int i = 0; i < ctx->d()->callData->argc; ++i)
- instance->putIndexed(len + i, ctx->d()->callData->args[i]);
- len += ctx->d()->callData->argc;
+ for (int i = 0; i < ctx->argc(); ++i)
+ instance->putIndexed(len + i, ctx->args()[i]);
+ len += ctx->argc();
}
if (instance->isArrayObject())
instance->setArrayLengthUnchecked(len);
@@ -311,7 +311,7 @@ ReturnedValue ArrayPrototype::method_push(CallContext *ctx)
ReturnedValue ArrayPrototype::method_reverse(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
uint length = instance->getLength();
@@ -343,7 +343,7 @@ ReturnedValue ArrayPrototype::method_reverse(CallContext *ctx)
ReturnedValue ArrayPrototype::method_shift(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
@@ -395,7 +395,7 @@ ReturnedValue ArrayPrototype::method_shift(CallContext *ctx)
ReturnedValue ArrayPrototype::method_slice(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject o(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject o(scope, ctx->thisObject().toObject(scope.engine));
if (!o)
return Encode::undefined();
@@ -410,8 +410,8 @@ ReturnedValue ArrayPrototype::method_slice(CallContext *ctx)
else
start = (uint) s;
uint end = len;
- if (ctx->d()->callData->argc > 1 && !ctx->d()->callData->args[1].isUndefined()) {
- double e = ctx->d()->callData->args[1].toInteger();
+ if (ctx->argc() > 1 && !ctx->args()[1].isUndefined()) {
+ double e = ctx->args()[1].toInteger();
if (e < 0)
end = (uint)qMax(len + e, 0.);
else if (e > len)
@@ -437,7 +437,7 @@ ReturnedValue ArrayPrototype::method_slice(CallContext *ctx)
ReturnedValue ArrayPrototype::method_sort(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
@@ -445,13 +445,13 @@ ReturnedValue ArrayPrototype::method_sort(CallContext *ctx)
ScopedValue comparefn(scope, ctx->argument(0));
ArrayData::sort(scope.engine, instance, comparefn, len);
- return ctx->d()->callData->thisObject.asReturnedValue();
+ return ctx->thisObject().asReturnedValue();
}
ReturnedValue ArrayPrototype::method_splice(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
uint len = instance->getLength();
@@ -479,7 +479,7 @@ ReturnedValue ArrayPrototype::method_splice(CallContext *ctx)
}
newArray->setArrayLengthUnchecked(deleteCount);
- uint itemCount = ctx->d()->callData->argc < 2 ? 0 : ctx->d()->callData->argc - 2;
+ uint itemCount = ctx->argc() < 2 ? 0 : ctx->argc() - 2;
if (itemCount < deleteCount) {
for (uint k = start; k < len - deleteCount; ++k) {
@@ -517,7 +517,7 @@ ReturnedValue ArrayPrototype::method_splice(CallContext *ctx)
}
for (uint i = 0; i < itemCount; ++i) {
- instance->putIndexed(start + i, ctx->d()->callData->args[i + 2]);
+ instance->putIndexed(start + i, ctx->args()[i + 2]);
if (scope.hasException())
return Encode::undefined();
}
@@ -531,7 +531,7 @@ ReturnedValue ArrayPrototype::method_splice(CallContext *ctx)
ReturnedValue ArrayPrototype::method_unshift(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
@@ -542,22 +542,22 @@ ReturnedValue ArrayPrototype::method_unshift(CallContext *ctx)
if (!instance->protoHasArray() && !instance->arrayData()->attrs && instance->arrayData()->length() <= len &&
instance->arrayData()->type != Heap::ArrayData::Custom) {
- instance->arrayData()->vtable()->push_front(instance, ctx->d()->callData->args, ctx->d()->callData->argc);
+ instance->arrayData()->vtable()->push_front(instance, ctx->args(), ctx->argc());
} else {
ScopedValue v(scope);
for (uint k = len; k > 0; --k) {
bool exists;
v = instance->getIndexed(k - 1, &exists);
if (exists)
- instance->putIndexed(k + ctx->d()->callData->argc - 1, v);
+ instance->putIndexed(k + ctx->argc() - 1, v);
else
- instance->deleteIndexedProperty(k + ctx->d()->callData->argc - 1);
+ instance->deleteIndexedProperty(k + ctx->argc() - 1);
}
- for (int i = 0; i < ctx->d()->callData->argc; ++i)
- instance->putIndexed(i, ctx->d()->callData->args[i]);
+ for (int i = 0; i < ctx->argc(); ++i)
+ instance->putIndexed(i, ctx->args()[i]);
}
- uint newLen = len + ctx->d()->callData->argc;
+ uint newLen = len + ctx->argc();
if (instance->isArrayObject())
instance->setArrayLengthUnchecked(newLen);
else
@@ -570,18 +570,18 @@ ReturnedValue ArrayPrototype::method_indexOf(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
uint len = instance->getLength();
if (!len)
return Encode(-1);
- ScopedValue searchValue(scope, ctx->d()->callData->argument(0));
+ ScopedValue searchValue(scope, ctx->argument(0));
uint fromIndex = 0;
- if (ctx->d()->callData->argc >= 2) {
- double f = ctx->d()->callData->args[1].toInteger();
+ if (ctx->argc() >= 2) {
+ double f = ctx->args()[1].toInteger();
if (scope.hasException())
return Encode::undefined();
if (f >= len)
@@ -639,7 +639,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
uint len = instance->getLength();
@@ -649,13 +649,13 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(CallContext *ctx)
ScopedValue searchValue(scope);
uint fromIndex = len;
- if (ctx->d()->callData->argc >= 1)
+ if (ctx->argc() >= 1)
searchValue = ctx->argument(0);
else
searchValue = Primitive::undefinedValue();
- if (ctx->d()->callData->argc >= 2) {
- double f = ctx->d()->callData->args[1].toInteger();
+ if (ctx->argc() >= 2) {
+ double f = ctx->args()[1].toInteger();
if (scope.hasException())
return Encode::undefined();
if (f > 0)
@@ -684,7 +684,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(CallContext *ctx)
ReturnedValue ArrayPrototype::method_every(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
@@ -718,7 +718,7 @@ ReturnedValue ArrayPrototype::method_every(CallContext *ctx)
ReturnedValue ArrayPrototype::method_some(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
@@ -752,7 +752,7 @@ ReturnedValue ArrayPrototype::method_some(CallContext *ctx)
ReturnedValue ArrayPrototype::method_forEach(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
@@ -783,7 +783,7 @@ ReturnedValue ArrayPrototype::method_forEach(CallContext *ctx)
ReturnedValue ArrayPrototype::method_map(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
@@ -820,7 +820,7 @@ ReturnedValue ArrayPrototype::method_map(CallContext *ctx)
ReturnedValue ArrayPrototype::method_filter(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
@@ -861,7 +861,7 @@ ReturnedValue ArrayPrototype::method_filter(CallContext *ctx)
ReturnedValue ArrayPrototype::method_reduce(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
@@ -875,7 +875,7 @@ ReturnedValue ArrayPrototype::method_reduce(CallContext *ctx)
ScopedValue acc(scope);
ScopedValue v(scope);
- if (ctx->d()->callData->argc > 1) {
+ if (ctx->argc() > 1) {
acc = ctx->argument(1);
} else {
bool kPresent = false;
@@ -911,7 +911,7 @@ ReturnedValue ArrayPrototype::method_reduce(CallContext *ctx)
ReturnedValue ArrayPrototype::method_reduceRight(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
if (!instance)
return Encode::undefined();
@@ -922,7 +922,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(CallContext *ctx)
return ctx->engine()->throwTypeError();
if (len == 0) {
- if (ctx->d()->callData->argc == 1)
+ if (ctx->argc() == 1)
return ctx->engine()->throwTypeError();
return ctx->argument(1);
}
@@ -930,7 +930,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(CallContext *ctx)
uint k = len;
ScopedValue acc(scope);
ScopedValue v(scope);
- if (ctx->d()->callData->argc > 1) {
+ if (ctx->argc() > 1) {
acc = ctx->argument(1);
} else {
bool kPresent = false;
diff --git a/src/qml/jsruntime/qv4booleanobject.cpp b/src/qml/jsruntime/qv4booleanobject.cpp
index c606e37310..0287945700 100644
--- a/src/qml/jsruntime/qv4booleanobject.cpp
+++ b/src/qml/jsruntime/qv4booleanobject.cpp
@@ -47,8 +47,7 @@ ReturnedValue BooleanCtor::construct(Managed *m, CallData *callData)
{
Scope scope(static_cast<BooleanCtor *>(m)->engine());
bool n = callData->argc ? callData->args[0].toBoolean() : false;
- ScopedValue b(scope, QV4::Primitive::fromBoolean(n));
- return Encode(scope.engine->newBooleanObject(b));
+ return Encode(scope.engine->newBooleanObject(n));
}
ReturnedValue BooleanCtor::call(Managed *, CallData *callData)
@@ -71,14 +70,13 @@ void BooleanPrototype::init(ExecutionEngine *engine, Object *ctor)
ReturnedValue BooleanPrototype::method_toString(CallContext *ctx)
{
bool result;
- if (ctx->d()->callData->thisObject.isBoolean()) {
- result = ctx->d()->callData->thisObject.booleanValue();
+ if (ctx->thisObject().isBoolean()) {
+ result = ctx->thisObject().booleanValue();
} else {
- Scope scope(ctx);
- Scoped<BooleanObject> thisObject(scope, ctx->d()->callData->thisObject);
+ BooleanObject *thisObject = ctx->thisObject().as<BooleanObject>();
if (!thisObject)
return ctx->engine()->throwTypeError();
- result = thisObject->value().booleanValue();
+ result = thisObject->value();
}
return Encode(ctx->d()->engine->newString(QLatin1String(result ? "true" : "false")));
@@ -86,13 +84,12 @@ ReturnedValue BooleanPrototype::method_toString(CallContext *ctx)
ReturnedValue BooleanPrototype::method_valueOf(CallContext *ctx)
{
- if (ctx->d()->callData->thisObject.isBoolean())
- return ctx->d()->callData->thisObject.asReturnedValue();
+ if (ctx->thisObject().isBoolean())
+ return ctx->thisObject().asReturnedValue();
- Scope scope(ctx);
- Scoped<BooleanObject> thisObject(scope, ctx->d()->callData->thisObject);
+ BooleanObject *thisObject = ctx->thisObject().as<BooleanObject>();
if (!thisObject)
return ctx->engine()->throwTypeError();
- return thisObject->value().asReturnedValue();
+ return Encode(thisObject->value());
}
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index 27d32bbcd3..8c637472a7 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -246,7 +246,7 @@ bool ExecutionContext::deleteProperty(String *name)
bool CallContext::needsOwnArguments() const
{
- return d()->function->needsActivation() || d()->callData->argc < static_cast<int>(d()->function->formalParameterCount());
+ return d()->function->needsActivation() || argc() < static_cast<int>(d()->function->formalParameterCount());
}
void ExecutionContext::markObjects(Heap::Base *m, ExecutionEngine *engine)
@@ -346,7 +346,7 @@ ReturnedValue ExecutionContext::getProperty(String *name)
name->makeIdentifier(scope.engine);
if (name->equals(d()->engine->id_this))
- return d()->callData->thisObject.asReturnedValue();
+ return thisObject().asReturnedValue();
bool hasWith = false;
bool hasCatchScope = false;
@@ -413,7 +413,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Heap::Object **
name->makeIdentifier(scope.engine);
if (name->equals(d()->engine->id_this))
- return d()->callData->thisObject.asReturnedValue();
+ return thisObject().asReturnedValue();
bool hasWith = false;
bool hasCatchScope = false;
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index 4d27b0456c..1431c5ac82 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -162,6 +162,19 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
Heap::FunctionObject *getFunctionObject() const;
static void markObjects(Heap::Base *m, ExecutionEngine *e);
+
+ const Value &thisObject() const {
+ return d()->callData->thisObject;
+ }
+ int argc() const {
+ return d()->callData->argc;
+ }
+ const Value *args() const {
+ return d()->callData->args;
+ }
+ ReturnedValue argument(int i) const {
+ return d()->callData->argument(i);
+ }
};
struct CallContext : public ExecutionContext
@@ -179,7 +192,7 @@ struct CallContext : public ExecutionContext
};
inline ReturnedValue CallContext::argument(int i) {
- return i < d()->callData->argc ? d()->callData->args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue();
+ return i < argc() ? args()[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue();
}
struct GlobalContext : public ExecutionContext
diff --git a/src/qml/jsruntime/qv4dataview.cpp b/src/qml/jsruntime/qv4dataview.cpp
index 55a41a7c6c..09d4db59af 100644
--- a/src/qml/jsruntime/qv4dataview.cpp
+++ b/src/qml/jsruntime/qv4dataview.cpp
@@ -123,7 +123,7 @@ void DataViewPrototype::init(ExecutionEngine *engine, Object *ctor)
ReturnedValue DataViewPrototype::method_get_buffer(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
+ Scoped<DataView> v(scope, ctx->thisObject());
if (!v)
return scope.engine->throwTypeError();
@@ -133,7 +133,7 @@ ReturnedValue DataViewPrototype::method_get_buffer(CallContext *ctx)
ReturnedValue DataViewPrototype::method_get_byteLength(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
+ Scoped<DataView> v(scope, ctx->thisObject());
if (!v)
return scope.engine->throwTypeError();
@@ -143,7 +143,7 @@ ReturnedValue DataViewPrototype::method_get_byteLength(CallContext *ctx)
ReturnedValue DataViewPrototype::method_get_byteOffset(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
+ Scoped<DataView> v(scope, ctx->thisObject());
if (!v)
return scope.engine->throwTypeError();
@@ -154,10 +154,10 @@ template <typename T>
ReturnedValue DataViewPrototype::method_getChar(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
- if (!v || ctx->d()->callData->argc < 1)
+ Scoped<DataView> v(scope, ctx->thisObject());
+ if (!v || ctx->argc() < 1)
return scope.engine->throwTypeError();
- double l = ctx->d()->callData->args[0].toNumber();
+ double l = ctx->args()[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
return scope.engine->throwTypeError();
@@ -172,16 +172,16 @@ template <typename T>
ReturnedValue DataViewPrototype::method_get(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
- if (!v || ctx->d()->callData->argc < 1)
+ Scoped<DataView> v(scope, ctx->thisObject());
+ if (!v || ctx->argc() < 1)
return scope.engine->throwTypeError();
- double l = ctx->d()->callData->args[0].toNumber();
+ double l = ctx->args()[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
return scope.engine->throwTypeError();
idx += v->d()->byteOffset;
- bool littleEndian = ctx->d()->callData->argc < 2 ? false : ctx->d()->callData->args[1].toBoolean();
+ bool littleEndian = ctx->argc() < 2 ? false : ctx->args()[1].toBoolean();
T t = littleEndian
? qFromLittleEndian<T>((uchar *)v->d()->buffer->data->data() + idx)
@@ -194,16 +194,16 @@ template <typename T>
ReturnedValue DataViewPrototype::method_getFloat(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
- if (!v || ctx->d()->callData->argc < 1)
+ Scoped<DataView> v(scope, ctx->thisObject());
+ if (!v || ctx->argc() < 1)
return scope.engine->throwTypeError();
- double l = ctx->d()->callData->args[0].toNumber();
+ double l = ctx->args()[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
return scope.engine->throwTypeError();
idx += v->d()->byteOffset;
- bool littleEndian = ctx->d()->callData->argc < 2 ? false : ctx->d()->callData->args[1].toBoolean();
+ bool littleEndian = ctx->argc() < 2 ? false : ctx->args()[1].toBoolean();
if (sizeof(T) == 4) {
// float
@@ -232,16 +232,16 @@ template <typename T>
ReturnedValue DataViewPrototype::method_setChar(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
- if (!v || ctx->d()->callData->argc < 1)
+ Scoped<DataView> v(scope, ctx->thisObject());
+ if (!v || ctx->argc() < 1)
return scope.engine->throwTypeError();
- double l = ctx->d()->callData->args[0].toNumber();
+ double l = ctx->args()[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
return scope.engine->throwTypeError();
idx += v->d()->byteOffset;
- int val = ctx->d()->callData->argc >= 2 ? ctx->d()->callData->args[1].toInt32() : 0;
+ int val = ctx->argc() >= 2 ? ctx->args()[1].toInt32() : 0;
v->d()->buffer->data->data()[idx] = (char)val;
return Encode::undefined();
@@ -251,18 +251,18 @@ template <typename T>
ReturnedValue DataViewPrototype::method_set(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
- if (!v || ctx->d()->callData->argc < 1)
+ Scoped<DataView> v(scope, ctx->thisObject());
+ if (!v || ctx->argc() < 1)
return scope.engine->throwTypeError();
- double l = ctx->d()->callData->args[0].toNumber();
+ double l = ctx->args()[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
return scope.engine->throwTypeError();
idx += v->d()->byteOffset;
- int val = ctx->d()->callData->argc >= 2 ? ctx->d()->callData->args[1].toInt32() : 0;
+ int val = ctx->argc() >= 2 ? ctx->args()[1].toInt32() : 0;
- bool littleEndian = ctx->d()->callData->argc < 3 ? false : ctx->d()->callData->args[2].toBoolean();
+ bool littleEndian = ctx->argc() < 3 ? false : ctx->args()[2].toBoolean();
if (littleEndian)
qToLittleEndian<T>(val, (uchar *)v->d()->buffer->data->data() + idx);
@@ -276,17 +276,17 @@ template <typename T>
ReturnedValue DataViewPrototype::method_setFloat(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
- if (!v || ctx->d()->callData->argc < 1)
+ Scoped<DataView> v(scope, ctx->thisObject());
+ if (!v || ctx->argc() < 1)
return scope.engine->throwTypeError();
- double l = ctx->d()->callData->args[0].toNumber();
+ double l = ctx->args()[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
return scope.engine->throwTypeError();
idx += v->d()->byteOffset;
- double val = ctx->d()->callData->argc >= 2 ? ctx->d()->callData->args[1].toNumber() : qSNaN();
- bool littleEndian = ctx->d()->callData->argc < 3 ? false : ctx->d()->callData->args[2].toBoolean();
+ double val = ctx->argc() >= 2 ? ctx->args()[1].toNumber() : qSNaN();
+ bool littleEndian = ctx->argc() < 3 ? false : ctx->args()[2].toBoolean();
if (sizeof(T) == 4) {
// float
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index 423c36963f..d11118ee88 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -755,7 +755,7 @@ void DatePrototype::init(ExecutionEngine *engine, Object *ctor)
double DatePrototype::getThisDate(ExecutionContext *ctx)
{
- if (DateObject *thisObject = ctx->d()->callData->thisObject.asDateObject())
+ if (DateObject *thisObject = ctx->thisObject().asDateObject())
return thisObject->date().asDouble();
else {
ctx->engine()->throwTypeError();
@@ -765,22 +765,22 @@ double DatePrototype::getThisDate(ExecutionContext *ctx)
ReturnedValue DatePrototype::method_parse(CallContext *ctx)
{
- if (!ctx->d()->callData->argc)
+ if (!ctx->argc())
return Encode(qSNaN());
- return Encode(ParseString(ctx->d()->callData->args[0].toQString()));
+ return Encode(ParseString(ctx->args()[0].toQString()));
}
ReturnedValue DatePrototype::method_UTC(CallContext *ctx)
{
- const int numArgs = ctx->d()->callData->argc;
+ const int numArgs = ctx->argc();
if (numArgs >= 2) {
- double year = ctx->d()->callData->args[0].toNumber();
- double month = ctx->d()->callData->args[1].toNumber();
- double day = numArgs >= 3 ? ctx->d()->callData->args[2].toNumber() : 1;
- double hours = numArgs >= 4 ? ctx->d()->callData->args[3].toNumber() : 0;
- double mins = numArgs >= 5 ? ctx->d()->callData->args[4].toNumber() : 0;
- double secs = numArgs >= 6 ? ctx->d()->callData->args[5].toNumber() : 0;
- double ms = numArgs >= 7 ? ctx->d()->callData->args[6].toNumber() : 0;
+ double year = ctx->args()[0].toNumber();
+ double month = ctx->args()[1].toNumber();
+ double day = numArgs >= 3 ? ctx->args()[2].toNumber() : 1;
+ double hours = numArgs >= 4 ? ctx->args()[3].toNumber() : 0;
+ double mins = numArgs >= 5 ? ctx->args()[4].toNumber() : 0;
+ double secs = numArgs >= 6 ? ctx->args()[5].toNumber() : 0;
+ double ms = numArgs >= 7 ? ctx->args()[6].toNumber() : 0;
if (year >= 0 && year <= 99)
year += 1900;
double t = MakeDate(MakeDay(year, month, day),
@@ -992,11 +992,11 @@ ReturnedValue DatePrototype::method_getTimezoneOffset(CallContext *ctx)
ReturnedValue DatePrototype::method_setTime(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<DateObject> self(scope, ctx->d()->callData->thisObject);
+ Scoped<DateObject> self(scope, ctx->thisObject());
if (!self)
return ctx->engine()->throwTypeError();
- double t = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double t = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
self->date().setDouble(TimeClip(t));
return self->date().asReturnedValue();
}
@@ -1004,37 +1004,37 @@ ReturnedValue DatePrototype::method_setTime(CallContext *ctx)
ReturnedValue DatePrototype::method_setMilliseconds(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<DateObject> self(scope, ctx->d()->callData->thisObject);
+ Scoped<DateObject> self(scope, ctx->thisObject());
if (!self)
return ctx->engine()->throwTypeError();
double t = LocalTime(self->date().asDouble());
- double ms = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double ms = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
self->date().setDouble(TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms)))));
return self->date().asReturnedValue();
}
ReturnedValue DatePrototype::method_setUTCMilliseconds(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
- double ms = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double ms = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
self->date().setDouble(TimeClip(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms))));
return self->date().asReturnedValue();
}
ReturnedValue DatePrototype::method_setSeconds(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
double t = LocalTime(self->date().asDouble());
- double sec = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
- double ms = (ctx->d()->callData->argc < 2) ? msFromTime(t) : ctx->d()->callData->args[1].toNumber();
+ double sec = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
+ double ms = (ctx->argc() < 2) ? msFromTime(t) : ctx->args()[1].toNumber();
t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms))));
self->date().setDouble(t);
return self->date().asReturnedValue();
@@ -1042,13 +1042,13 @@ ReturnedValue DatePrototype::method_setSeconds(CallContext *ctx)
ReturnedValue DatePrototype::method_setUTCSeconds(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
- double sec = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
- double ms = (ctx->d()->callData->argc < 2) ? msFromTime(t) : ctx->d()->callData->args[1].toNumber();
+ double sec = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
+ double ms = (ctx->argc() < 2) ? msFromTime(t) : ctx->args()[1].toNumber();
t = TimeClip(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms)));
self->date().setDouble(t);
return self->date().asReturnedValue();
@@ -1056,14 +1056,14 @@ ReturnedValue DatePrototype::method_setUTCSeconds(CallContext *ctx)
ReturnedValue DatePrototype::method_setMinutes(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
double t = LocalTime(self->date().asDouble());
- double min = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
- double sec = (ctx->d()->callData->argc < 2) ? SecFromTime(t) : ctx->d()->callData->args[1].toNumber();
- double ms = (ctx->d()->callData->argc < 3) ? msFromTime(t) : ctx->d()->callData->args[2].toNumber();
+ double min = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
+ double sec = (ctx->argc() < 2) ? SecFromTime(t) : ctx->args()[1].toNumber();
+ double ms = (ctx->argc() < 3) ? msFromTime(t) : ctx->args()[2].toNumber();
t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms))));
self->date().setDouble(t);
return self->date().asReturnedValue();
@@ -1071,14 +1071,14 @@ ReturnedValue DatePrototype::method_setMinutes(CallContext *ctx)
ReturnedValue DatePrototype::method_setUTCMinutes(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
- double min = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
- double sec = (ctx->d()->callData->argc < 2) ? SecFromTime(t) : ctx->d()->callData->args[1].toNumber();
- double ms = (ctx->d()->callData->argc < 3) ? msFromTime(t) : ctx->d()->callData->args[2].toNumber();
+ double min = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
+ double sec = (ctx->argc() < 2) ? SecFromTime(t) : ctx->args()[1].toNumber();
+ double ms = (ctx->argc() < 3) ? msFromTime(t) : ctx->args()[2].toNumber();
t = TimeClip(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms)));
self->date().setDouble(t);
return self->date().asReturnedValue();
@@ -1086,15 +1086,15 @@ ReturnedValue DatePrototype::method_setUTCMinutes(CallContext *ctx)
ReturnedValue DatePrototype::method_setHours(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
double t = LocalTime(self->date().asDouble());
- double hour = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
- double min = (ctx->d()->callData->argc < 2) ? MinFromTime(t) : ctx->d()->callData->args[1].toNumber();
- double sec = (ctx->d()->callData->argc < 3) ? SecFromTime(t) : ctx->d()->callData->args[2].toNumber();
- double ms = (ctx->d()->callData->argc < 4) ? msFromTime(t) : ctx->d()->callData->args[3].toNumber();
+ double hour = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
+ double min = (ctx->argc() < 2) ? MinFromTime(t) : ctx->args()[1].toNumber();
+ double sec = (ctx->argc() < 3) ? SecFromTime(t) : ctx->args()[2].toNumber();
+ double ms = (ctx->argc() < 4) ? msFromTime(t) : ctx->args()[3].toNumber();
t = TimeClip(UTC(MakeDate(Day(t), MakeTime(hour, min, sec, ms))));
self->date().setDouble(t);
return self->date().asReturnedValue();
@@ -1102,15 +1102,15 @@ ReturnedValue DatePrototype::method_setHours(CallContext *ctx)
ReturnedValue DatePrototype::method_setUTCHours(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
- double hour = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
- double min = (ctx->d()->callData->argc < 2) ? MinFromTime(t) : ctx->d()->callData->args[1].toNumber();
- double sec = (ctx->d()->callData->argc < 3) ? SecFromTime(t) : ctx->d()->callData->args[2].toNumber();
- double ms = (ctx->d()->callData->argc < 4) ? msFromTime(t) : ctx->d()->callData->args[3].toNumber();
+ double hour = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
+ double min = (ctx->argc() < 2) ? MinFromTime(t) : ctx->args()[1].toNumber();
+ double sec = (ctx->argc() < 3) ? SecFromTime(t) : ctx->args()[2].toNumber();
+ double ms = (ctx->argc() < 4) ? msFromTime(t) : ctx->args()[3].toNumber();
t = TimeClip(MakeDate(Day(t), MakeTime(hour, min, sec, ms)));
self->date().setDouble(t);
return self->date().asReturnedValue();
@@ -1118,12 +1118,12 @@ ReturnedValue DatePrototype::method_setUTCHours(CallContext *ctx)
ReturnedValue DatePrototype::method_setDate(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
double t = LocalTime(self->date().asDouble());
- double date = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double date = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t))));
self->date().setDouble(t);
return self->date().asReturnedValue();
@@ -1131,12 +1131,12 @@ ReturnedValue DatePrototype::method_setDate(CallContext *ctx)
ReturnedValue DatePrototype::method_setUTCDate(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
- double date = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double date = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
t = TimeClip(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t)));
self->date().setDouble(t);
return self->date().asReturnedValue();
@@ -1144,13 +1144,13 @@ ReturnedValue DatePrototype::method_setUTCDate(CallContext *ctx)
ReturnedValue DatePrototype::method_setMonth(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
double t = LocalTime(self->date().asDouble());
- double month = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
- double date = (ctx->d()->callData->argc < 2) ? DateFromTime(t) : ctx->d()->callData->args[1].toNumber();
+ double month = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
+ double date = (ctx->argc() < 2) ? DateFromTime(t) : ctx->args()[1].toNumber();
t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t))));
self->date().setDouble(t);
return self->date().asReturnedValue();
@@ -1158,13 +1158,13 @@ ReturnedValue DatePrototype::method_setMonth(CallContext *ctx)
ReturnedValue DatePrototype::method_setUTCMonth(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
- double month = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
- double date = (ctx->d()->callData->argc < 2) ? DateFromTime(t) : ctx->d()->callData->args[1].toNumber();
+ double month = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
+ double date = (ctx->argc() < 2) ? DateFromTime(t) : ctx->args()[1].toNumber();
t = TimeClip(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t)));
self->date().setDouble(t);
return self->date().asReturnedValue();
@@ -1172,7 +1172,7 @@ ReturnedValue DatePrototype::method_setUTCMonth(CallContext *ctx)
ReturnedValue DatePrototype::method_setYear(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
@@ -1181,7 +1181,7 @@ ReturnedValue DatePrototype::method_setYear(CallContext *ctx)
t = 0;
else
t = LocalTime(t);
- double year = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double year = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
double r;
if (std::isnan(year)) {
r = qSNaN();
@@ -1198,14 +1198,14 @@ ReturnedValue DatePrototype::method_setYear(CallContext *ctx)
ReturnedValue DatePrototype::method_setUTCFullYear(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
- double year = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
- double month = (ctx->d()->callData->argc < 2) ? MonthFromTime(t) : ctx->d()->callData->args[1].toNumber();
- double date = (ctx->d()->callData->argc < 3) ? DateFromTime(t) : ctx->d()->callData->args[2].toNumber();
+ double year = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
+ double month = (ctx->argc() < 2) ? MonthFromTime(t) : ctx->args()[1].toNumber();
+ double date = (ctx->argc() < 3) ? DateFromTime(t) : ctx->args()[2].toNumber();
t = TimeClip(MakeDate(MakeDay(year, month, date), TimeWithinDay(t)));
self->date().setDouble(t);
return self->date().asReturnedValue();
@@ -1213,16 +1213,16 @@ ReturnedValue DatePrototype::method_setUTCFullYear(CallContext *ctx)
ReturnedValue DatePrototype::method_setFullYear(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
double t = LocalTime(self->date().asDouble());
if (std::isnan(t))
t = 0;
- double year = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
- double month = (ctx->d()->callData->argc < 2) ? MonthFromTime(t) : ctx->d()->callData->args[1].toNumber();
- double date = (ctx->d()->callData->argc < 3) ? DateFromTime(t) : ctx->d()->callData->args[2].toNumber();
+ double year = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN();
+ double month = (ctx->argc() < 2) ? MonthFromTime(t) : ctx->args()[1].toNumber();
+ double date = (ctx->argc() < 3) ? DateFromTime(t) : ctx->args()[2].toNumber();
t = TimeClip(UTC(MakeDate(MakeDay(year, month, date), TimeWithinDay(t))));
self->date().setDouble(t);
return self->date().asReturnedValue();
@@ -1230,7 +1230,7 @@ ReturnedValue DatePrototype::method_setFullYear(CallContext *ctx)
ReturnedValue DatePrototype::method_toUTCString(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
@@ -1253,13 +1253,13 @@ static void addZeroPrefixedInt(QString &str, int num, int nDigits)
ReturnedValue DatePrototype::method_toISOString(CallContext *ctx)
{
- DateObject *self = ctx->d()->callData->thisObject.asDateObject();
+ DateObject *self = ctx->thisObject().asDateObject();
if (!self)
return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
if (!std::isfinite(t))
- return ctx->engine()->throwRangeError(ctx->d()->callData->thisObject);
+ return ctx->engine()->throwRangeError(ctx->thisObject());
QString result;
int year = (int)YearFromTime(t);
@@ -1292,7 +1292,7 @@ ReturnedValue DatePrototype::method_toISOString(CallContext *ctx)
ReturnedValue DatePrototype::method_toJSON(CallContext *ctx)
{
Scope scope(ctx);
- ScopedValue O(scope, RuntimeHelpers::toObject(scope.engine, ctx->d()->callData->thisObject));
+ ScopedValue O(scope, RuntimeHelpers::toObject(scope.engine, ctx->thisObject()));
ScopedValue tv(scope, RuntimeHelpers::toPrimitive(O, NUMBER_HINT));
if (tv->isNumber() && !std::isfinite(tv->toNumber()))
@@ -1306,7 +1306,7 @@ ReturnedValue DatePrototype::method_toJSON(CallContext *ctx)
return ctx->engine()->throwTypeError();
ScopedCallData callData(scope);
- callData->thisObject = ctx->d()->callData->thisObject;
+ callData->thisObject = ctx->thisObject();
return toIso->call(callData);
}
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 49d77863df..9579f3ddb1 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -547,10 +547,10 @@ Heap::Object *ExecutionEngine::newNumberObject(const Value &value)
return object->d();
}
-Heap::Object *ExecutionEngine::newBooleanObject(const Value &value)
+Heap::Object *ExecutionEngine::newBooleanObject(bool b)
{
Scope scope(this);
- ScopedObject object(scope, memoryManager->alloc<BooleanObject>(this, value));
+ ScopedObject object(scope, memoryManager->alloc<BooleanObject>(this, b));
return object->d();
}
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index e482aeffa9..124f4e8e24 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -262,7 +262,7 @@ public:
Heap::Object *newStringObject(const Value &value);
Heap::Object *newNumberObject(const Value &value);
- Heap::Object *newBooleanObject(const Value &value);
+ Heap::Object *newBooleanObject(bool b);
Heap::ArrayObject *newArrayObject(int count = 0);
Heap::ArrayObject *newArrayObject(const QStringList &list);
diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp
index bdbec790ca..09aa41db61 100644
--- a/src/qml/jsruntime/qv4errorobject.cpp
+++ b/src/qml/jsruntime/qv4errorobject.cpp
@@ -148,7 +148,7 @@ Heap::ErrorObject::ErrorObject(InternalClass *ic, QV4::Object *prototype, const
ReturnedValue ErrorObject::method_get_stack(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<ErrorObject> This(scope, ctx->d()->callData->thisObject);
+ Scoped<ErrorObject> This(scope, ctx->thisObject());
if (!This)
return ctx->engine()->throwTypeError();
if (!This->d()->stack) {
@@ -355,7 +355,7 @@ ReturnedValue ErrorPrototype::method_toString(CallContext *ctx)
{
Scope scope(ctx);
- Object *o = ctx->d()->callData->thisObject.asObject();
+ Object *o = ctx->thisObject().asObject();
if (!o)
return ctx->engine()->throwTypeError();
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 1ead3b747f..63efb4f9f6 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -300,7 +300,7 @@ void FunctionPrototype::init(ExecutionEngine *engine, Object *ctor)
ReturnedValue FunctionPrototype::method_toString(CallContext *ctx)
{
- FunctionObject *fun = ctx->d()->callData->thisObject.asFunctionObject();
+ FunctionObject *fun = ctx->thisObject().asFunctionObject();
if (!fun)
return ctx->engine()->throwTypeError();
@@ -310,7 +310,7 @@ ReturnedValue FunctionPrototype::method_toString(CallContext *ctx)
ReturnedValue FunctionPrototype::method_apply(CallContext *ctx)
{
Scope scope(ctx);
- ScopedFunctionObject o(scope, ctx->d()->callData->thisObject.asFunctionObject());
+ ScopedFunctionObject o(scope, ctx->thisObject().asFunctionObject());
if (!o)
return ctx->engine()->throwTypeError();
@@ -352,14 +352,14 @@ ReturnedValue FunctionPrototype::method_call(CallContext *ctx)
{
Scope scope(ctx);
- ScopedFunctionObject o(scope, ctx->d()->callData->thisObject.asFunctionObject());
+ ScopedFunctionObject o(scope, ctx->thisObject().asFunctionObject());
if (!o)
return ctx->engine()->throwTypeError();
- ScopedCallData callData(scope, ctx->d()->callData->argc ? ctx->d()->callData->argc - 1 : 0);
- if (ctx->d()->callData->argc) {
- for (int i = 1; i < ctx->d()->callData->argc; ++i)
- callData->args[i - 1] = ctx->d()->callData->args[i];
+ ScopedCallData callData(scope, ctx->argc() ? ctx->argc() - 1 : 0);
+ if (ctx->argc()) {
+ for (int i = 1; i < ctx->argc(); ++i)
+ callData->args[i - 1] = ctx->args()[i];
}
callData->thisObject = ctx->argument(0);
return o->call(callData);
@@ -368,16 +368,16 @@ ReturnedValue FunctionPrototype::method_call(CallContext *ctx)
ReturnedValue FunctionPrototype::method_bind(CallContext *ctx)
{
Scope scope(ctx);
- ScopedFunctionObject target(scope, ctx->d()->callData->thisObject);
+ ScopedFunctionObject target(scope, ctx->thisObject());
if (!target)
return ctx->engine()->throwTypeError();
ScopedValue boundThis(scope, ctx->argument(0));
Scoped<MemberData> boundArgs(scope, (Heap::MemberData *)0);
- if (ctx->d()->callData->argc > 1) {
- boundArgs = MemberData::reallocate(scope.engine, 0, ctx->d()->callData->argc - 1);
- boundArgs->d()->size = ctx->d()->callData->argc - 1;
- memcpy(boundArgs->data(), ctx->d()->callData->args + 1, (ctx->d()->callData->argc - 1)*sizeof(Value));
+ if (ctx->argc() > 1) {
+ boundArgs = MemberData::reallocate(scope.engine, 0, ctx->argc() - 1);
+ boundArgs->d()->size = ctx->argc() - 1;
+ memcpy(boundArgs->data(), ctx->args() + 1, (ctx->argc() - 1)*sizeof(Value));
}
ScopedContext global(scope, scope.engine->rootContext());
diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp
index 823eeda76d..b5b09afc36 100644
--- a/src/qml/jsruntime/qv4globalobject.cpp
+++ b/src/qml/jsruntime/qv4globalobject.cpp
@@ -385,7 +385,7 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall)
if (function->isStrict() || (ctx->d()->strictMode)) {
ScopedFunctionObject e(scope, FunctionObject::createScriptFunction(ctx, function));
ScopedCallData callData(scope, 0);
- callData->thisObject = ctx->d()->callData->thisObject;
+ callData->thisObject = ctx->thisObject();
return e->call(callData);
}
@@ -537,38 +537,38 @@ ReturnedValue GlobalFunctions::method_parseFloat(CallContext *ctx)
/// isNaN [15.1.2.4]
ReturnedValue GlobalFunctions::method_isNaN(CallContext *ctx)
{
- if (!ctx->d()->callData->argc)
+ if (!ctx->argc())
// undefined gets converted to NaN
return Encode(true);
- if (ctx->d()->callData->args[0].integerCompatible())
+ if (ctx->args()[0].integerCompatible())
return Encode(false);
- double d = ctx->d()->callData->args[0].toNumber();
+ double d = ctx->args()[0].toNumber();
return Encode((bool)std::isnan(d));
}
/// isFinite [15.1.2.5]
ReturnedValue GlobalFunctions::method_isFinite(CallContext *ctx)
{
- if (!ctx->d()->callData->argc)
+ if (!ctx->argc())
// undefined gets converted to NaN
return Encode(false);
- if (ctx->d()->callData->args[0].integerCompatible())
+ if (ctx->args()[0].integerCompatible())
return Encode(true);
- double d = ctx->d()->callData->args[0].toNumber();
+ double d = ctx->args()[0].toNumber();
return Encode((bool)std::isfinite(d));
}
/// decodeURI [15.1.3.1]
ReturnedValue GlobalFunctions::method_decodeURI(CallContext *context)
{
- if (context->d()->callData->argc == 0)
+ if (context->argc() == 0)
return Encode::undefined();
- QString uriString = context->d()->callData->args[0].toQString();
+ QString uriString = context->args()[0].toQString();
bool ok;
QString out = decode(uriString, DecodeNonReserved, &ok);
if (!ok) {
@@ -583,10 +583,10 @@ ReturnedValue GlobalFunctions::method_decodeURI(CallContext *context)
/// decodeURIComponent [15.1.3.2]
ReturnedValue GlobalFunctions::method_decodeURIComponent(CallContext *context)
{
- if (context->d()->callData->argc == 0)
+ if (context->argc() == 0)
return Encode::undefined();
- QString uriString = context->d()->callData->args[0].toQString();
+ QString uriString = context->args()[0].toQString();
bool ok;
QString out = decode(uriString, DecodeAll, &ok);
if (!ok) {
@@ -601,10 +601,10 @@ ReturnedValue GlobalFunctions::method_decodeURIComponent(CallContext *context)
/// encodeURI [15.1.3.3]
ReturnedValue GlobalFunctions::method_encodeURI(CallContext *context)
{
- if (context->d()->callData->argc == 0)
+ if (context->argc() == 0)
return Encode::undefined();
- QString uriString = context->d()->callData->args[0].toQString();
+ QString uriString = context->args()[0].toQString();
bool ok;
QString out = encode(uriString, uriUnescapedReserved, &ok);
if (!ok) {
@@ -619,10 +619,10 @@ ReturnedValue GlobalFunctions::method_encodeURI(CallContext *context)
/// encodeURIComponent [15.1.3.4]
ReturnedValue GlobalFunctions::method_encodeURIComponent(CallContext *context)
{
- if (context->d()->callData->argc == 0)
+ if (context->argc() == 0)
return Encode::undefined();
- QString uriString = context->d()->callData->args[0].toQString();
+ QString uriString = context->args()[0].toQString();
bool ok;
QString out = encode(uriString, uriUnescaped, &ok);
if (!ok) {
@@ -636,18 +636,18 @@ ReturnedValue GlobalFunctions::method_encodeURIComponent(CallContext *context)
ReturnedValue GlobalFunctions::method_escape(CallContext *context)
{
- if (!context->d()->callData->argc)
+ if (!context->argc())
return context->d()->engine->newString(QStringLiteral("undefined"))->asReturnedValue();
- QString str = context->d()->callData->args[0].toQString();
+ QString str = context->args()[0].toQString();
return context->d()->engine->newString(escape(str))->asReturnedValue();
}
ReturnedValue GlobalFunctions::method_unescape(CallContext *context)
{
- if (!context->d()->callData->argc)
+ if (!context->argc())
return context->d()->engine->newString(QStringLiteral("undefined"))->asReturnedValue();
- QString str = context->d()->callData->args[0].toQString();
+ QString str = context->args()[0].toQString();
return context->d()->engine->newString(unescape(str))->asReturnedValue();
}
diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp
index 814e6fbfe8..b74728da20 100644
--- a/src/qml/jsruntime/qv4include.cpp
+++ b/src/qml/jsruntime/qv4include.cpp
@@ -172,7 +172,7 @@ void QV4Include::finished()
*/
QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx)
{
- if (!ctx->d()->callData->argc)
+ if (!ctx->argc())
return QV4::Encode::undefined();
QV4::Scope scope(ctx->engine());
@@ -181,11 +181,11 @@ QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx)
if (!context || !context->isJSContext)
V4THROW_ERROR("Qt.include(): Can only be called from JavaScript files");
- QUrl url(scope.engine->resolvedUrl(ctx->d()->callData->args[0].toQStringNoThrow()));
+ QUrl url(scope.engine->resolvedUrl(ctx->args()[0].toQStringNoThrow()));
QV4::ScopedValue callbackFunction(scope, QV4::Primitive::undefinedValue());
- if (ctx->d()->callData->argc >= 2 && ctx->d()->callData->args[1].asFunctionObject())
- callbackFunction = ctx->d()->callData->args[1];
+ if (ctx->argc() >= 2 && ctx->args()[1].asFunctionObject())
+ callbackFunction = ctx->args()[1];
QString localFile = QQmlFile::urlToLocalFileOrQrc(url);
diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp
index b0b50499d5..88097b212a 100644
--- a/src/qml/jsruntime/qv4mathobject.cpp
+++ b/src/qml/jsruntime/qv4mathobject.cpp
@@ -96,15 +96,15 @@ static double copySign(double x, double y)
ReturnedValue MathObject::method_abs(CallContext *context)
{
- if (!context->d()->callData->argc)
+ if (!context->argc())
return Encode(qSNaN());
- if (context->d()->callData->args[0].isInteger()) {
- int i = context->d()->callData->args[0].integerValue();
+ if (context->args()[0].isInteger()) {
+ int i = context->args()[0].integerValue();
return Encode(i < 0 ? - i : i);
}
- double v = context->d()->callData->args[0].toNumber();
+ double v = context->args()[0].toNumber();
if (v == 0) // 0 | -0
return Encode(0);
@@ -113,7 +113,7 @@ ReturnedValue MathObject::method_abs(CallContext *context)
ReturnedValue MathObject::method_acos(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : 2;
+ double v = context->argc() ? context->args()[0].toNumber() : 2;
if (v > 1)
return Encode(qSNaN());
@@ -122,7 +122,7 @@ ReturnedValue MathObject::method_acos(CallContext *context)
ReturnedValue MathObject::method_asin(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : 2;
+ double v = context->argc() ? context->args()[0].toNumber() : 2;
if (v > 1)
return Encode(qSNaN());
else
@@ -131,7 +131,7 @@ ReturnedValue MathObject::method_asin(CallContext *context)
ReturnedValue MathObject::method_atan(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
if (v == 0.0)
return Encode(v);
else
@@ -140,8 +140,8 @@ ReturnedValue MathObject::method_atan(CallContext *context)
ReturnedValue MathObject::method_atan2(CallContext *context)
{
- double v1 = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
- double v2 = context->d()->callData->argc > 1 ? context->d()->callData->args[1].toNumber() : qSNaN();
+ double v1 = context->argc() ? context->args()[0].toNumber() : qSNaN();
+ double v2 = context->argc() > 1 ? context->args()[1].toNumber() : qSNaN();
if ((v1 < 0) && qIsFinite(v1) && qIsInf(v2) && (copySign(1.0, v2) == 1.0))
return Encode(copySign(0, -1.0));
@@ -158,7 +158,7 @@ ReturnedValue MathObject::method_atan2(CallContext *context)
ReturnedValue MathObject::method_ceil(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
if (v < 0.0 && v > -1.0)
return Encode(copySign(0, -1.0));
else
@@ -167,13 +167,13 @@ ReturnedValue MathObject::method_ceil(CallContext *context)
ReturnedValue MathObject::method_cos(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
return Encode(::cos(v));
}
ReturnedValue MathObject::method_exp(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
if (qIsInf(v)) {
if (copySign(1.0, v) == -1.0)
return Encode(0);
@@ -186,13 +186,13 @@ ReturnedValue MathObject::method_exp(CallContext *context)
ReturnedValue MathObject::method_floor(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
return Encode(::floor(v));
}
ReturnedValue MathObject::method_log(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
if (v < 0)
return Encode(qSNaN());
else
@@ -202,8 +202,8 @@ ReturnedValue MathObject::method_log(CallContext *context)
ReturnedValue MathObject::method_max(CallContext *context)
{
double mx = -qInf();
- for (int i = 0; i < context->d()->callData->argc; ++i) {
- double x = context->d()->callData->args[i].toNumber();
+ for (int i = 0; i < context->argc(); ++i) {
+ double x = context->args()[i].toNumber();
if (x > mx || std::isnan(x))
mx = x;
}
@@ -213,8 +213,8 @@ ReturnedValue MathObject::method_max(CallContext *context)
ReturnedValue MathObject::method_min(CallContext *context)
{
double mx = qInf();
- for (int i = 0; i < context->d()->callData->argc; ++i) {
- double x = context->d()->callData->args[i].toNumber();
+ for (int i = 0; i < context->argc(); ++i) {
+ double x = context->args()[i].toNumber();
if ((x == 0 && mx == x && copySign(1.0, x) == -1.0)
|| (x < mx) || std::isnan(x)) {
mx = x;
@@ -225,8 +225,8 @@ ReturnedValue MathObject::method_min(CallContext *context)
ReturnedValue MathObject::method_pow(CallContext *context)
{
- double x = context->d()->callData->argc > 0 ? context->d()->callData->args[0].toNumber() : qSNaN();
- double y = context->d()->callData->argc > 1 ? context->d()->callData->args[1].toNumber() : qSNaN();
+ double x = context->argc() > 0 ? context->args()[0].toNumber() : qSNaN();
+ double y = context->argc() > 1 ? context->args()[1].toNumber() : qSNaN();
if (std::isnan(y))
return Encode(qSNaN());
@@ -286,26 +286,26 @@ ReturnedValue MathObject::method_random(CallContext *context)
ReturnedValue MathObject::method_round(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
v = copySign(::floor(v + 0.5), v);
return Encode(v);
}
ReturnedValue MathObject::method_sin(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
return Encode(::sin(v));
}
ReturnedValue MathObject::method_sqrt(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
return Encode(::sqrt(v));
}
ReturnedValue MathObject::method_tan(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
if (v == 0.0)
return Encode(v);
else
diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp
index dcde8f13f3..bbe6bb977c 100644
--- a/src/qml/jsruntime/qv4numberobject.cpp
+++ b/src/qml/jsruntime/qv4numberobject.cpp
@@ -52,7 +52,7 @@ Heap::NumberCtor::NumberCtor(QV4::ExecutionContext *scope)
ReturnedValue NumberCtor::construct(Managed *m, CallData *callData)
{
- Scope scope(static_cast<NumberCtor *>(m)->engine());
+ Scope scope(m->cast<NumberCtor>()->engine());
double dbl = callData->argc ? callData->args[0].toNumber() : 0.;
ScopedValue d(scope, QV4::Primitive::fromDouble(dbl));
return Encode(scope.engine->newNumberObject(d));
@@ -96,9 +96,9 @@ void NumberPrototype::init(ExecutionEngine *engine, Object *ctor)
inline ReturnedValue thisNumberValue(ExecutionContext *ctx)
{
- if (ctx->d()->callData->thisObject.isNumber())
- return ctx->d()->callData->thisObject.asReturnedValue();
- NumberObject *n = ctx->d()->callData->thisObject.asNumberObject();
+ if (ctx->thisObject().isNumber())
+ return ctx->thisObject().asReturnedValue();
+ NumberObject *n = ctx->thisObject().asNumberObject();
if (!n)
return ctx->engine()->throwTypeError();
return n->value().asReturnedValue();
@@ -106,9 +106,9 @@ inline ReturnedValue thisNumberValue(ExecutionContext *ctx)
inline double thisNumber(ExecutionContext *ctx)
{
- if (ctx->d()->callData->thisObject.isNumber())
- return ctx->d()->callData->thisObject.asDouble();
- NumberObject *n = ctx->d()->callData->thisObject.asNumberObject();
+ if (ctx->thisObject().isNumber())
+ return ctx->thisObject().asDouble();
+ NumberObject *n = ctx->thisObject().asNumberObject();
if (!n)
return ctx->engine()->throwTypeError();
return n->value().asDouble();
@@ -121,8 +121,8 @@ ReturnedValue NumberPrototype::method_toString(CallContext *ctx)
if (scope.engine->hasException)
return Encode::undefined();
- if (ctx->d()->callData->argc && !ctx->d()->callData->args[0].isUndefined()) {
- int radix = ctx->d()->callData->args[0].toInt32();
+ if (ctx->argc() && !ctx->args()[0].isUndefined()) {
+ int radix = ctx->args()[0].toInt32();
if (radix < 2 || radix > 36)
return ctx->engine()->throwError(QString::fromLatin1("Number.prototype.toString: %0 is not a valid radix")
.arg(radix));
@@ -191,14 +191,14 @@ ReturnedValue NumberPrototype::method_toFixed(CallContext *ctx)
double fdigits = 0;
- if (ctx->d()->callData->argc > 0)
- fdigits = ctx->d()->callData->args[0].toInteger();
+ if (ctx->argc() > 0)
+ fdigits = ctx->args()[0].toInteger();
if (std::isnan(fdigits))
fdigits = 0;
if (fdigits < 0 || fdigits > 20)
- return ctx->engine()->throwRangeError(ctx->d()->callData->thisObject);
+ return ctx->engine()->throwRangeError(ctx->thisObject());
QString str;
if (std::isnan(v))
@@ -221,8 +221,8 @@ ReturnedValue NumberPrototype::method_toExponential(CallContext *ctx)
int fdigits = -1;
- if (ctx->d()->callData->argc && !ctx->d()->callData->args[0].isUndefined()) {
- fdigits = ctx->d()->callData->args[0].toInt32();
+ if (ctx->argc() && !ctx->args()[0].isUndefined()) {
+ fdigits = ctx->args()[0].toInt32();
if (fdigits < 0 || fdigits > 20) {
ScopedString error(scope, scope.engine->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range")));
return ctx->engine()->throwRangeError(error);
@@ -244,10 +244,10 @@ ReturnedValue NumberPrototype::method_toPrecision(CallContext *ctx)
if (scope.engine->hasException)
return Encode::undefined();
- if (!ctx->d()->callData->argc || ctx->d()->callData->args[0].isUndefined())
+ if (!ctx->argc() || ctx->args()[0].isUndefined())
return RuntimeHelpers::toString(scope.engine, v);
- double precision = ctx->d()->callData->args[0].toInt32();
+ double precision = ctx->args()[0].toInt32();
if (precision < 1 || precision > 21) {
ScopedString error(scope, scope.engine->newString(QStringLiteral("Number.prototype.toPrecision: precision out of range")));
return ctx->engine()->throwRangeError(error);
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index 1c36f179b2..4e88cd785e 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -220,7 +220,7 @@ public:
bool arrayPut(uint index, const Value &value) {
return arrayData()->vtable()->put(this, index, value);
}
- bool arrayPut(uint index, Value *values, uint n) {
+ bool arrayPut(uint index, const Value *values, uint n) {
return arrayData()->vtable()->putArray(this, index, values, n);
}
void setArrayAttributes(uint i, PropertyAttributes a) {
@@ -333,17 +333,17 @@ namespace Heap {
struct BooleanObject : Object {
BooleanObject(InternalClass *ic, QV4::Object *prototype)
- : Object(ic, prototype)
+ : Object(ic, prototype),
+ b(false)
{
- value = Encode((bool)false);
}
- BooleanObject(ExecutionEngine *engine, const Value &val)
- : Object(engine->emptyClass, engine->booleanPrototype.asObject())
+ BooleanObject(ExecutionEngine *engine, bool b)
+ : Object(engine->emptyClass, engine->booleanPrototype.asObject()),
+ b(b)
{
- value = val;
}
- Value value;
+ bool b;
};
struct NumberObject : Object {
@@ -383,7 +383,7 @@ struct BooleanObject: Object {
V4_OBJECT2(BooleanObject, Object)
Q_MANAGED_TYPE(BooleanObject)
- Value value() const { return d()->value; }
+ bool value() const { return d()->b; }
};
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index 289421e867..dce3c8124b 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -153,7 +153,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyNames(CallContext *context)
if (!O)
return context->engine()->throwTypeError();
- ScopedArrayObject array(scope, getOwnPropertyNames(context->d()->engine, context->d()->callData->args[0]));
+ ScopedArrayObject array(scope, getOwnPropertyNames(context->d()->engine, context->args()[0]));
return array.asReturnedValue();
}
@@ -167,7 +167,7 @@ ReturnedValue ObjectPrototype::method_create(CallContext *ctx)
ScopedObject newObject(scope, ctx->d()->engine->newObject());
newObject->setPrototype(O->asObject());
- if (ctx->d()->callData->argc > 1 && !ctx->d()->callData->args[1].isUndefined()) {
+ if (ctx->argc() > 1 && !ctx->args()[1].isUndefined()) {
ctx->d()->callData->args[0] = newObject.asReturnedValue();
return method_defineProperties(ctx);
}
@@ -385,12 +385,12 @@ ReturnedValue ObjectPrototype::method_keys(CallContext *ctx)
ReturnedValue ObjectPrototype::method_toString(CallContext *ctx)
{
Scope scope(ctx);
- if (ctx->d()->callData->thisObject.isUndefined()) {
+ if (ctx->thisObject().isUndefined()) {
return ctx->d()->engine->newString(QStringLiteral("[object Undefined]"))->asReturnedValue();
- } else if (ctx->d()->callData->thisObject.isNull()) {
+ } else if (ctx->thisObject().isNull()) {
return ctx->d()->engine->newString(QStringLiteral("[object Null]"))->asReturnedValue();
} else {
- ScopedObject obj(scope, RuntimeHelpers::toObject(scope.engine, ctx->d()->callData->thisObject));
+ ScopedObject obj(scope, RuntimeHelpers::toObject(scope.engine, ctx->thisObject()));
QString className = obj->className();
return ctx->d()->engine->newString(QString::fromLatin1("[object %1]").arg(className))->asReturnedValue();
}
@@ -399,7 +399,7 @@ ReturnedValue ObjectPrototype::method_toString(CallContext *ctx)
ReturnedValue ObjectPrototype::method_toLocaleString(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject o(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedObject o(scope, ctx->thisObject().toObject(scope.engine));
if (!o)
return Encode::undefined();
ScopedFunctionObject f(scope, o->get(ctx->d()->engine->id_toString));
@@ -413,7 +413,7 @@ ReturnedValue ObjectPrototype::method_toLocaleString(CallContext *ctx)
ReturnedValue ObjectPrototype::method_valueOf(CallContext *ctx)
{
Scope scope(ctx);
- ScopedValue v(scope, ctx->d()->callData->thisObject.toObject(scope.engine));
+ ScopedValue v(scope, ctx->thisObject().toObject(scope.engine));
if (ctx->d()->engine->hasException)
return Encode::undefined();
return v->asReturnedValue();
@@ -425,7 +425,7 @@ ReturnedValue ObjectPrototype::method_hasOwnProperty(CallContext *ctx)
ScopedString P(scope, ctx->argument(0), ScopedString::Convert);
if (scope.engine->hasException)
return Encode::undefined();
- ScopedObject O(scope, ctx->d()->callData->thisObject, ScopedObject::Convert);
+ ScopedObject O(scope, ctx->thisObject(), ScopedObject::Convert);
if (scope.engine->hasException)
return Encode::undefined();
bool r = O->hasOwnProperty(P);
@@ -441,7 +441,7 @@ ReturnedValue ObjectPrototype::method_isPrototypeOf(CallContext *ctx)
if (!V)
return Encode(false);
- ScopedObject O(scope, ctx->d()->callData->thisObject, ScopedObject::Convert);
+ ScopedObject O(scope, ctx->thisObject(), ScopedObject::Convert);
if (scope.engine->hasException)
return Encode::undefined();
ScopedObject proto(scope, V->prototype());
@@ -460,7 +460,7 @@ ReturnedValue ObjectPrototype::method_propertyIsEnumerable(CallContext *ctx)
if (scope.engine->hasException)
return Encode::undefined();
- ScopedObject o(scope, ctx->d()->callData->thisObject, ScopedObject::Convert);
+ ScopedObject o(scope, ctx->thisObject(), ScopedObject::Convert);
if (scope.engine->hasException)
return Encode::undefined();
PropertyAttributes attrs;
@@ -470,7 +470,7 @@ ReturnedValue ObjectPrototype::method_propertyIsEnumerable(CallContext *ctx)
ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx)
{
- if (ctx->d()->callData->argc < 2)
+ if (ctx->argc() < 2)
return ctx->engine()->throwTypeError();
Scope scope(ctx);
@@ -482,9 +482,9 @@ ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx)
if (scope.engine->hasException)
return Encode::undefined();
- ScopedObject o(scope, ctx->d()->callData->thisObject);
+ ScopedObject o(scope, ctx->thisObject());
if (!o) {
- if (!ctx->d()->callData->thisObject.isUndefined())
+ if (!ctx->thisObject().isUndefined())
return Encode::undefined();
o = ctx->d()->engine->globalObject();
}
@@ -498,7 +498,7 @@ ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx)
ReturnedValue ObjectPrototype::method_defineSetter(CallContext *ctx)
{
- if (ctx->d()->callData->argc < 2)
+ if (ctx->argc() < 2)
return ctx->engine()->throwTypeError();
Scope scope(ctx);
@@ -510,9 +510,9 @@ ReturnedValue ObjectPrototype::method_defineSetter(CallContext *ctx)
if (scope.engine->hasException)
return Encode::undefined();
- ScopedObject o(scope, ctx->d()->callData->thisObject);
+ ScopedObject o(scope, ctx->thisObject());
if (!o) {
- if (!ctx->d()->callData->thisObject.isUndefined())
+ if (!ctx->thisObject().isUndefined())
return Encode::undefined();
o = ctx->d()->engine->globalObject();
}
@@ -527,7 +527,7 @@ ReturnedValue ObjectPrototype::method_defineSetter(CallContext *ctx)
ReturnedValue ObjectPrototype::method_get_proto(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject o(scope, ctx->d()->callData->thisObject.asObject());
+ ScopedObject o(scope, ctx->thisObject().asObject());
if (!o)
return ctx->engine()->throwTypeError();
@@ -537,16 +537,16 @@ ReturnedValue ObjectPrototype::method_get_proto(CallContext *ctx)
ReturnedValue ObjectPrototype::method_set_proto(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject o(scope, ctx->d()->callData->thisObject);
- if (!o || !ctx->d()->callData->argc)
+ ScopedObject o(scope, ctx->thisObject());
+ if (!o || !ctx->argc())
return ctx->engine()->throwTypeError();
- if (ctx->d()->callData->args[0].isNull()) {
+ if (ctx->args()[0].isNull()) {
o->setPrototype(0);
return Encode::undefined();
}
- ScopedObject p(scope, ctx->d()->callData->args[0]);
+ ScopedObject p(scope, ctx->args()[0]);
bool ok = false;
if (!!p) {
if (o->prototype() == p->d()) {
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index c65b7b6d55..f0c94d2d0e 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -886,10 +886,10 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase
ReturnedValue QObjectWrapper::method_connect(CallContext *ctx)
{
- if (ctx->d()->callData->argc == 0)
+ if (ctx->argc() == 0)
V4THROW_ERROR("Function.prototype.connect: no arguments given");
- QPair<QObject *, int> signalInfo = extractQtSignal(ctx->d()->callData->thisObject);
+ QPair<QObject *, int> signalInfo = extractQtSignal(ctx->thisObject());
QObject *signalObject = signalInfo.first;
int signalIndex = signalInfo.second; // in method range, not signal range!
@@ -906,11 +906,11 @@ ReturnedValue QObjectWrapper::method_connect(CallContext *ctx)
QV4::ScopedFunctionObject f(scope);
QV4::ScopedValue thisObject (scope, QV4::Encode::undefined());
- if (ctx->d()->callData->argc == 1) {
- f = ctx->d()->callData->args[0];
- } else if (ctx->d()->callData->argc >= 2) {
- thisObject = ctx->d()->callData->args[0];
- f = ctx->d()->callData->args[1];
+ if (ctx->argc() == 1) {
+ f = ctx->args()[0];
+ } else if (ctx->argc() >= 2) {
+ thisObject = ctx->args()[0];
+ f = ctx->args()[1];
}
if (!f)
@@ -937,12 +937,12 @@ ReturnedValue QObjectWrapper::method_connect(CallContext *ctx)
ReturnedValue QObjectWrapper::method_disconnect(CallContext *ctx)
{
- if (ctx->d()->callData->argc == 0)
+ if (ctx->argc() == 0)
V4THROW_ERROR("Function.prototype.disconnect: no arguments given");
QV4::Scope scope(ctx);
- QPair<QObject *, int> signalInfo = extractQtSignal(ctx->d()->callData->thisObject);
+ QPair<QObject *, int> signalInfo = extractQtSignal(ctx->thisObject());
QObject *signalObject = signalInfo.first;
int signalIndex = signalInfo.second;
@@ -958,11 +958,11 @@ ReturnedValue QObjectWrapper::method_disconnect(CallContext *ctx)
QV4::ScopedFunctionObject functionValue(scope);
QV4::ScopedValue functionThisValue(scope, QV4::Encode::undefined());
- if (ctx->d()->callData->argc == 1) {
- functionValue = ctx->d()->callData->args[0];
- } else if (ctx->d()->callData->argc >= 2) {
- functionThisValue = ctx->d()->callData->args[0];
- functionValue = ctx->d()->callData->args[1];
+ if (ctx->argc() == 1) {
+ functionValue = ctx->args()[0];
+ } else if (ctx->argc() >= 2) {
+ functionThisValue = ctx->args()[0];
+ functionValue = ctx->args()[1];
}
if (!functionValue)
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index 0736056838..c0e4f137ad 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -345,7 +345,7 @@ void RegExpPrototype::init(ExecutionEngine *engine, Object *constructor)
ReturnedValue RegExpPrototype::method_exec(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<RegExpObject> r(scope, ctx->d()->callData->thisObject.as<RegExpObject>());
+ Scoped<RegExpObject> r(scope, ctx->thisObject().as<RegExpObject>());
if (!r)
return ctx->engine()->throwTypeError();
@@ -409,7 +409,7 @@ ReturnedValue RegExpPrototype::method_test(CallContext *ctx)
ReturnedValue RegExpPrototype::method_toString(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<RegExpObject> r(scope, ctx->d()->callData->thisObject.as<RegExpObject>());
+ Scoped<RegExpObject> r(scope, ctx->thisObject().as<RegExpObject>());
if (!r)
return ctx->engine()->throwTypeError();
@@ -419,12 +419,12 @@ ReturnedValue RegExpPrototype::method_toString(CallContext *ctx)
ReturnedValue RegExpPrototype::method_compile(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<RegExpObject> r(scope, ctx->d()->callData->thisObject.as<RegExpObject>());
+ Scoped<RegExpObject> r(scope, ctx->thisObject().as<RegExpObject>());
if (!r)
return ctx->engine()->throwTypeError();
- ScopedCallData callData(scope, ctx->d()->callData->argc);
- memcpy(callData->args, ctx->d()->callData->args, ctx->d()->callData->argc*sizeof(Value));
+ ScopedCallData callData(scope, ctx->argc());
+ memcpy(callData->args, ctx->args(), ctx->argc()*sizeof(Value));
Scoped<RegExpObject> re(scope, ctx->d()->engine->regExpCtor.asFunctionObject()->construct(callData));
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 4bbbb6f401..4167823c6b 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -435,7 +435,7 @@ Heap::Object *RuntimeHelpers::convertToObject(ExecutionEngine *engine, const Val
engine->throwTypeError();
return 0;
case Value::Boolean_Type:
- return engine->newBooleanObject(value);
+ return engine->newBooleanObject(value.booleanValue());
case Value::Managed_Type:
Q_ASSERT(value.isString());
return engine->newStringObject(value);
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index 83fd2efa60..046f7f62b1 100644
--- a/src/qml/jsruntime/qv4sequenceobject.cpp
+++ b/src/qml/jsruntime/qv4sequenceobject.cpp
@@ -375,8 +375,8 @@ public:
}
QV4::Scope scope(ctx);
- if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].asFunctionObject()) {
- CompareFunctor cf(ctx, ctx->d()->callData->args[0]);
+ if (ctx->argc() == 1 && ctx->args()[0].asFunctionObject()) {
+ CompareFunctor cf(ctx, ctx->args()[0]);
std::sort(d()->container.begin(), d()->container.end(), cf);
} else {
DefaultCompareFunctor cf;
@@ -390,7 +390,7 @@ public:
static QV4::ReturnedValue method_get_length(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->d()->callData->thisObject.as<QQmlSequence<Container> >());
+ QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->thisObject().as<QQmlSequence<Container> >());
if (!This)
return ctx->engine()->throwTypeError();
@@ -405,11 +405,11 @@ public:
static QV4::ReturnedValue method_set_length(QV4::CallContext* ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->d()->callData->thisObject.as<QQmlSequence<Container> >());
+ QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->thisObject().as<QQmlSequence<Container> >());
if (!This)
return ctx->engine()->throwTypeError();
- quint32 newLength = ctx->d()->callData->args[0].toUInt32();
+ quint32 newLength = ctx->args()[0].toUInt32();
/* Qt containers have int (rather than uint) allowable indexes. */
if (newLength > INT_MAX) {
generateWarning(scope.engine, QLatin1String("Index out of range during length set"));
@@ -558,11 +558,11 @@ void SequencePrototype::init()
QV4::ReturnedValue SequencePrototype::method_sort(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::ScopedObject o(scope, ctx->d()->callData->thisObject);
+ QV4::ScopedObject o(scope, ctx->thisObject());
if (!o || !o->isListType())
return ctx->engine()->throwTypeError();
- if (ctx->d()->callData->argc >= 2)
+ if (ctx->argc() >= 2)
return o.asReturnedValue();
#define CALL_SORT(SequenceElementType, SequenceElementTypeName, SequenceType, DefaultValue) \
diff --git a/src/qml/jsruntime/qv4sequenceobject_p.h b/src/qml/jsruntime/qv4sequenceobject_p.h
index 0009fa45fa..3cd56a65d6 100644
--- a/src/qml/jsruntime/qv4sequenceobject_p.h
+++ b/src/qml/jsruntime/qv4sequenceobject_p.h
@@ -62,7 +62,7 @@ struct SequencePrototype : public QV4::Object
static ReturnedValue method_valueOf(QV4::CallContext *ctx)
{
- return ctx->d()->callData->thisObject.toString(ctx->engine())->asReturnedValue();
+ return ctx->thisObject().toString(ctx->engine())->asReturnedValue();
}
static ReturnedValue method_sort(QV4::CallContext *ctx);
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index 55bc3c58db..6eb74e3a82 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -220,7 +220,7 @@ void StringPrototype::init(ExecutionEngine *engine, Object *ctor)
static QString getThisString(ExecutionContext *ctx)
{
Scope scope(ctx);
- ScopedValue t(scope, ctx->d()->callData->thisObject);
+ ScopedValue t(scope, ctx->thisObject());
if (t->isString())
return t->stringValue()->toQString();
if (StringObject *thisString = t->asStringObject())
@@ -234,10 +234,10 @@ static QString getThisString(ExecutionContext *ctx)
ReturnedValue StringPrototype::method_toString(CallContext *context)
{
- if (context->d()->callData->thisObject.isString())
- return context->d()->callData->thisObject.asReturnedValue();
+ if (context->thisObject().isString())
+ return context->thisObject().asReturnedValue();
- StringObject *o = context->d()->callData->thisObject.asStringObject();
+ StringObject *o = context->thisObject().asStringObject();
if (!o)
return context->engine()->throwTypeError();
return o->d()->value.asReturnedValue();
@@ -250,8 +250,8 @@ ReturnedValue StringPrototype::method_charAt(CallContext *context)
return Encode::undefined();
int pos = 0;
- if (context->d()->callData->argc > 0)
- pos = (int) context->d()->callData->args[0].toInteger();
+ if (context->argc() > 0)
+ pos = (int) context->args()[0].toInteger();
QString result;
if (pos >= 0 && pos < str.length())
@@ -267,8 +267,8 @@ ReturnedValue StringPrototype::method_charCodeAt(CallContext *context)
return Encode::undefined();
int pos = 0;
- if (context->d()->callData->argc > 0)
- pos = (int) context->d()->callData->args[0].toInteger();
+ if (context->argc() > 0)
+ pos = (int) context->args()[0].toInteger();
if (pos >= 0 && pos < str.length())
@@ -286,8 +286,8 @@ ReturnedValue StringPrototype::method_concat(CallContext *context)
return Encode::undefined();
ScopedValue v(scope);
- for (int i = 0; i < context->d()->callData->argc; ++i) {
- v = RuntimeHelpers::toString(scope.engine, context->d()->callData->args[i]);
+ for (int i = 0; i < context->argc(); ++i) {
+ v = RuntimeHelpers::toString(scope.engine, context->args()[i]);
if (scope.hasException())
return Encode::undefined();
Q_ASSERT(v->isString());
@@ -304,12 +304,12 @@ ReturnedValue StringPrototype::method_indexOf(CallContext *context)
return Encode::undefined();
QString searchString;
- if (context->d()->callData->argc)
- searchString = context->d()->callData->args[0].toQString();
+ if (context->argc())
+ searchString = context->args()[0].toQString();
int pos = 0;
- if (context->d()->callData->argc > 1)
- pos = (int) context->d()->callData->args[1].toInteger();
+ if (context->argc() > 1)
+ pos = (int) context->args()[1].toInteger();
int index = -1;
if (! value.isEmpty())
@@ -327,8 +327,8 @@ ReturnedValue StringPrototype::method_lastIndexOf(CallContext *context)
return Encode::undefined();
QString searchString;
- if (context->d()->callData->argc)
- searchString = context->d()->callData->args[0].toQString();
+ if (context->argc())
+ searchString = context->args()[0].toQString();
ScopedValue posArg(scope, context->argument(1));
double position = RuntimeHelpers::toNumber(posArg);
@@ -353,20 +353,20 @@ ReturnedValue StringPrototype::method_localeCompare(CallContext *context)
if (scope.engine->hasException)
return Encode::undefined();
- ScopedValue v(scope, context->d()->callData->argument(0));
+ ScopedValue v(scope, context->argument(0));
const QString that = v->toQString();
return Encode(QString::localeAwareCompare(value, that));
}
ReturnedValue StringPrototype::method_match(CallContext *context)
{
- if (context->d()->callData->thisObject.isUndefined() || context->d()->callData->thisObject.isNull())
+ if (context->thisObject().isUndefined() || context->thisObject().isNull())
return context->engine()->throwTypeError();
Scope scope(context);
- ScopedString s(scope, context->d()->callData->thisObject.toString(scope.engine));
+ ScopedString s(scope, context->thisObject().toString(scope.engine));
- ScopedValue regexp(scope, context->d()->callData->argument(0));
+ ScopedValue regexp(scope, context->argument(0));
Scoped<RegExpObject> rx(scope, regexp);
if (!rx) {
ScopedCallData callData(scope, 1);
@@ -473,10 +473,10 @@ ReturnedValue StringPrototype::method_replace(CallContext *ctx)
{
Scope scope(ctx);
QString string;
- if (StringObject *thisString = ctx->d()->callData->thisObject.asStringObject())
+ if (StringObject *thisString = ctx->thisObject().asStringObject())
string = thisString->d()->value.stringValue()->toQString();
else
- string = ctx->d()->callData->thisObject.toQString();
+ string = ctx->thisObject().toQString();
int numCaptures = 0;
int numStringMatches = 0;
@@ -618,9 +618,9 @@ ReturnedValue StringPrototype::method_slice(CallContext *ctx)
const double length = text.length();
- double start = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toInteger() : 0;
- double end = (ctx->d()->callData->argc < 2 || ctx->d()->callData->args[1].isUndefined())
- ? length : ctx->d()->callData->args[1].toInteger();
+ double start = ctx->argc() ? ctx->args()[0].toInteger() : 0;
+ double end = (ctx->argc() < 2 || ctx->args()[1].isUndefined())
+ ? length : ctx->args()[1].toInteger();
if (start < 0)
start = qMax(length + start, 0.);
@@ -728,12 +728,12 @@ ReturnedValue StringPrototype::method_substr(CallContext *context)
return Encode::undefined();
double start = 0;
- if (context->d()->callData->argc > 0)
- start = context->d()->callData->args[0].toInteger();
+ if (context->argc() > 0)
+ start = context->args()[0].toInteger();
double length = +qInf();
- if (context->d()->callData->argc > 1)
- length = context->d()->callData->args[1].toInteger();
+ if (context->argc() > 1)
+ length = context->args()[1].toInteger();
double count = value.length();
if (start < 0)
@@ -756,8 +756,8 @@ ReturnedValue StringPrototype::method_substring(CallContext *context)
double start = 0;
double end = length;
- if (context->d()->callData->argc > 0)
- start = context->d()->callData->args[0].toInteger();
+ if (context->argc() > 0)
+ start = context->args()[0].toInteger();
Scope scope(context);
ScopedValue endValue(scope, context->argument(1));
@@ -815,10 +815,10 @@ ReturnedValue StringPrototype::method_toLocaleUpperCase(CallContext *ctx)
ReturnedValue StringPrototype::method_fromCharCode(CallContext *context)
{
- QString str(context->d()->callData->argc, Qt::Uninitialized);
+ QString str(context->argc(), Qt::Uninitialized);
QChar *ch = str.data();
- for (int i = 0; i < context->d()->callData->argc; ++i) {
- *ch = QChar(context->d()->callData->args[i].toUInt16());
+ for (int i = 0; i < context->argc(); ++i) {
+ *ch = QChar(context->args()[i].toUInt16());
++ch;
}
return context->d()->engine->newString(str)->asReturnedValue();
diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp
index 1b9c5d58e4..ba3ebdd60c 100644
--- a/src/qml/jsruntime/qv4typedarray.cpp
+++ b/src/qml/jsruntime/qv4typedarray.cpp
@@ -404,7 +404,7 @@ void TypedArrayPrototype::init(ExecutionEngine *engine, TypedArrayCtor *ctor)
ReturnedValue TypedArrayPrototype::method_get_buffer(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<TypedArray> v(scope, ctx->d()->callData->thisObject);
+ Scoped<TypedArray> v(scope, ctx->thisObject());
if (!v)
return scope.engine->throwTypeError();
@@ -414,7 +414,7 @@ ReturnedValue TypedArrayPrototype::method_get_buffer(CallContext *ctx)
ReturnedValue TypedArrayPrototype::method_get_byteLength(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<TypedArray> v(scope, ctx->d()->callData->thisObject);
+ Scoped<TypedArray> v(scope, ctx->thisObject());
if (!v)
return scope.engine->throwTypeError();
@@ -424,7 +424,7 @@ ReturnedValue TypedArrayPrototype::method_get_byteLength(CallContext *ctx)
ReturnedValue TypedArrayPrototype::method_get_byteOffset(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<TypedArray> v(scope, ctx->d()->callData->thisObject);
+ Scoped<TypedArray> v(scope, ctx->thisObject());
if (!v)
return scope.engine->throwTypeError();
@@ -434,7 +434,7 @@ ReturnedValue TypedArrayPrototype::method_get_byteOffset(CallContext *ctx)
ReturnedValue TypedArrayPrototype::method_get_length(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<TypedArray> v(scope, ctx->d()->callData->thisObject);
+ Scoped<TypedArray> v(scope, ctx->thisObject());
if (!v)
return scope.engine->throwTypeError();
@@ -444,14 +444,14 @@ ReturnedValue TypedArrayPrototype::method_get_length(CallContext *ctx)
ReturnedValue TypedArrayPrototype::method_set(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<TypedArray> a(scope, ctx->d()->callData->thisObject);
+ Scoped<TypedArray> a(scope, ctx->thisObject());
if (!a)
return scope.engine->throwTypeError();
Scoped<ArrayBuffer> buffer(scope, a->d()->buffer);
if (!buffer)
scope.engine->throwTypeError();
- double doffset = ctx->d()->callData->argc >= 2 ? ctx->d()->callData->args[1].toInteger() : 0;
+ double doffset = ctx->argc() >= 2 ? ctx->args()[1].toInteger() : 0;
if (scope.engine->hasException)
return Encode::undefined();
@@ -460,10 +460,10 @@ ReturnedValue TypedArrayPrototype::method_set(CallContext *ctx)
uint offset = (uint)doffset;
uint elementSize = a->d()->type->bytesPerElement;
- Scoped<TypedArray> srcTypedArray(scope, ctx->d()->callData->args[0]);
+ Scoped<TypedArray> srcTypedArray(scope, ctx->args()[0]);
if (!srcTypedArray) {
// src is a regular object
- ScopedObject o(scope, ctx->d()->callData->args[0].toObject(scope.engine));
+ ScopedObject o(scope, ctx->args()[0].toObject(scope.engine));
if (scope.engine->hasException || !o)
return scope.engine->throwTypeError();
@@ -533,7 +533,7 @@ ReturnedValue TypedArrayPrototype::method_set(CallContext *ctx)
ReturnedValue TypedArrayPrototype::method_subarray(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<TypedArray> a(scope, ctx->d()->callData->thisObject);
+ Scoped<TypedArray> a(scope, ctx->thisObject());
if (!a)
return scope.engine->throwTypeError();
@@ -543,12 +543,12 @@ ReturnedValue TypedArrayPrototype::method_subarray(CallContext *ctx)
return scope.engine->throwTypeError();
int len = a->length();
- double b = ctx->d()->callData->argc > 0 ? ctx->d()->callData->args[0].toInteger() : 0;
+ double b = ctx->argc() > 0 ? ctx->args()[0].toInteger() : 0;
if (b < 0)
b = len + b;
uint begin = (uint)qBound(0., b, (double)len);
- double e = ctx->d()->callData->argc < 2 || ctx->d()->callData->args[1].isUndefined() ? len : ctx->d()->callData->args[1].toInteger();
+ double e = ctx->argc() < 2 || ctx->args()[1].isUndefined() ? len : ctx->args()[1].toInteger();
if (e < 0)
e = len + e;
uint end = (uint)qBound(0., e, (double)len);
diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp
index a1339bb90a..cf323fc6bc 100644
--- a/src/qml/jsruntime/qv4variantobject.cpp
+++ b/src/qml/jsruntime/qv4variantobject.cpp
@@ -103,7 +103,7 @@ void VariantPrototype::init()
QV4::ReturnedValue VariantPrototype::method_preserve(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<VariantObject> o(scope, ctx->d()->callData->thisObject.as<QV4::VariantObject>());
+ Scoped<VariantObject> o(scope, ctx->thisObject().as<QV4::VariantObject>());
if (o && o->d()->isScarce())
o->d()->node.remove();
return Encode::undefined();
@@ -112,7 +112,7 @@ QV4::ReturnedValue VariantPrototype::method_preserve(CallContext *ctx)
QV4::ReturnedValue VariantPrototype::method_destroy(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<VariantObject> o(scope, ctx->d()->callData->thisObject.as<QV4::VariantObject>());
+ Scoped<VariantObject> o(scope, ctx->thisObject().as<QV4::VariantObject>());
if (o) {
if (o->d()->isScarce())
o->d()->node.remove();
@@ -124,7 +124,7 @@ QV4::ReturnedValue VariantPrototype::method_destroy(CallContext *ctx)
QV4::ReturnedValue VariantPrototype::method_toString(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<VariantObject> o(scope, ctx->d()->callData->thisObject.as<QV4::VariantObject>());
+ Scoped<VariantObject> o(scope, ctx->thisObject().as<QV4::VariantObject>());
if (!o)
return Encode::undefined();
QString result = o->d()->data.toString();
@@ -136,7 +136,7 @@ QV4::ReturnedValue VariantPrototype::method_toString(CallContext *ctx)
QV4::ReturnedValue VariantPrototype::method_valueOf(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<VariantObject> o(scope, ctx->d()->callData->thisObject.as<QV4::VariantObject>());
+ Scoped<VariantObject> o(scope, ctx->thisObject().as<QV4::VariantObject>());
if (o) {
QVariant v = o->d()->data;
switch (v.type()) {
@@ -157,7 +157,7 @@ QV4::ReturnedValue VariantPrototype::method_valueOf(CallContext *ctx)
break;
}
}
- return ctx->d()->callData->thisObject.asReturnedValue();
+ return ctx->thisObject().asReturnedValue();
}
QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index 87b1387eed..6f1838728e 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -627,7 +627,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
MOTH_END_INSTR(Debug)
MOTH_BEGIN_INSTR(LoadThis)
- VALUE(instr.result) = context->d()->callData->thisObject;
+ VALUE(instr.result) = context->thisObject();
MOTH_END_INSTR(LoadThis)
MOTH_BEGIN_INSTR(LoadQmlIdArray)