aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-07-28 10:07:57 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2014-11-04 20:17:54 +0100
commit486948817b26da2c62802bb93a0f671715c609d4 (patch)
tree45cd51615a6d187ac504c18c4dee4aa31cf9a771
parent6f6b350976ccfe959223b1fbe8c21fe71efc45bd (diff)
Move the throw methods from ExecutionContext to ExecutionEngine
The methods don't require a context, and thus shouldn't be implemented there. Change-Id: If058e0c5067093a4161f2275ac4288aa2bc500f3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--src/imports/localstorage/plugin.cpp8
-rw-r--r--src/particles/qquickv4particledata.cpp22
-rw-r--r--src/qml/compiler/qv4codegen.cpp4
-rw-r--r--src/qml/jsruntime/qv4argumentsobject.cpp6
-rw-r--r--src/qml/jsruntime/qv4arraybuffer.cpp12
-rw-r--r--src/qml/jsruntime/qv4arraydata.cpp2
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp24
-rw-r--r--src/qml/jsruntime/qv4booleanobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4context.cpp98
-rw-r--r--src/qml/jsruntime/qv4context_p.h13
-rw-r--r--src/qml/jsruntime/qv4dataview.cpp34
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp42
-rw-r--r--src/qml/jsruntime/qv4engine.cpp92
-rw-r--r--src/qml/jsruntime/qv4engine_p.h16
-rw-r--r--src/qml/jsruntime/qv4errorobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp18
-rw-r--r--src/qml/jsruntime/qv4functionobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4globalobject.cpp8
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp6
-rw-r--r--src/qml/jsruntime/qv4lookup.cpp6
-rw-r--r--src/qml/jsruntime/qv4numberobject.cpp12
-rw-r--r--src/qml/jsruntime/qv4object.cpp26
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp56
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp20
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp12
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp46
-rw-r--r--src/qml/jsruntime/qv4script.cpp4
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp6
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp12
-rw-r--r--src/qml/jsruntime/qv4typedarray.cpp42
-rw-r--r--src/qml/qml/qqmlcomponent.cpp10
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp4
-rw-r--r--src/qml/qml/qqmllocale_p.h2
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp2
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp6
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp32
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp22
-rw-r--r--src/qml/qml/v8/qv4domerrors_p.h2
-rw-r--r--src/qml/qml/v8/qv8engine_p.h4
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp18
-rw-r--r--src/qml/util/qqmladaptormodel.cpp16
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp10
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.cpp2
43 files changed, 391 insertions, 396 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index 02dc1a5078..8133202213 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -60,7 +60,7 @@ using namespace QV4;
QV4::Scoped<String> v(scope, scope.engine->newString(desc)); \
QV4::Scoped<Object> ex(scope, scope.engine->newErrorObject(v)); \
ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Primitive::fromInt32(error))); \
- ctx->throwError(ex); \
+ ctx->engine()->throwError(ex); \
return Encode::undefined(); \
}
@@ -68,13 +68,13 @@ using namespace QV4;
QV4::Scoped<String> v(scope, scope.engine->newString(desc)); \
QV4::Scoped<Object> ex(scope, scope.engine->newErrorObject(v)); \
ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Primitive::fromInt32(error))); \
- args->setReturnValue(ctx->throwError(ex)); \
+ args->setReturnValue(ctx->engine()->throwError(ex)); \
return; \
}
#define V4THROW_REFERENCE(string) { \
QV4::Scoped<String> v(scope, scope.engine->newString(string)); \
- ctx->throwReferenceError(v); \
+ ctx->engine()->throwReferenceError(v); \
return Encode::undefined(); \
}
@@ -179,7 +179,7 @@ static ReturnedValue qmlsqldatabase_rows_setForwardOnly(CallContext *ctx)
if (!r || r->d()->type != QQmlSqlDatabaseWrapper::Rows)
V4THROW_REFERENCE("Not a SQLDatabase::Rows object");
if (ctx->d()->callData->argc < 1)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
r->d()->sqlQuery.setForwardOnly(ctx->d()->callData->args[0].toBoolean());
return Encode::undefined();
diff --git a/src/particles/qquickv4particledata.cpp b/src/particles/qquickv4particledata.cpp
index 586066ec24..90eeca7b8e 100644
--- a/src/particles/qquickv4particledata.cpp
+++ b/src/particles/qquickv4particledata.cpp
@@ -294,7 +294,7 @@ static QV4::ReturnedValue particleData_discard(QV4::CallContext *ctx)
QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject);
if (!r || !r->d()->datum)
- return ctx->throwError(QStringLiteral("Not a valid ParticleData object"));
+ return ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object"));
r->d()->datum->lifeSpan = 0; //Don't kill(), because it could still be in the middle of being created
return QV4::Encode::undefined();
@@ -306,7 +306,7 @@ static QV4::ReturnedValue particleData_lifeLeft(QV4::CallContext *ctx)
QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject);
if (!r || !r->d()->datum)
- return ctx->throwError(QStringLiteral("Not a valid ParticleData object"));
+ return ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object"));
return QV4::Encode(r->d()->datum->lifeLeft());
}
@@ -317,7 +317,7 @@ static QV4::ReturnedValue particleData_curSize(QV4::CallContext *ctx)
QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject);
if (!r || !r->d()->datum)
- return ctx->throwError(QStringLiteral("Not a valid ParticleData object"));
+ return ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object"));
return QV4::Encode(r->d()->datum->curSize());
}
@@ -326,7 +326,7 @@ static QV4::ReturnedValue particleData_curSize(QV4::CallContext *ctx)
QV4::Scope scope(ctx); \
QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum) \
- ctx->throwError(QStringLiteral("Not a valid ParticleData object")); \
+ ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object")); \
\
return QV4::Encode((r->d()->datum->color. VAR )/255.0);\
}\
@@ -336,7 +336,7 @@ static QV4::ReturnedValue particleData_set_ ## NAME (QV4::CallContext *ctx)\
QV4::Scope scope(ctx); \
QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum)\
- ctx->throwError(QStringLiteral("Not a valid ParticleData object"));\
+ ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object"));\
\
double d = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : 0; \
r->d()->datum->color. VAR = qMin(255, qMax(0, (int)floor(d * 255.0)));\
@@ -349,7 +349,7 @@ static QV4::ReturnedValue particleData_set_ ## NAME (QV4::CallContext *ctx)\
QV4::Scope scope(ctx); \
QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum) \
- ctx->throwError(QStringLiteral("Not a valid ParticleData object")); \
+ ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object")); \
\
return QV4::Encode(r->d()->datum-> VARIABLE);\
}\
@@ -359,7 +359,7 @@ static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::CallContext *ctx)\
QV4::Scope scope(ctx); \
QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum)\
- ctx->throwError(QStringLiteral("Not a valid ParticleData object"));\
+ ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object"));\
\
r->d()->datum-> VARIABLE = (ctx->d()->callData->argc && ctx->d()->callData->args[0].toBoolean()) ? 1.0 : 0.0;\
return QV4::Encode::undefined(); \
@@ -370,7 +370,7 @@ static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::CallContext *ctx)\
QV4::Scope scope(ctx); \
QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum) \
- ctx->throwError(QStringLiteral("Not a valid ParticleData object")); \
+ ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object")); \
\
return QV4::Encode(r->d()->datum-> VARIABLE);\
}\
@@ -380,7 +380,7 @@ static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::CallContext *ctx)\
QV4::Scope scope(ctx); \
QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum)\
- ctx->throwError(QStringLiteral("Not a valid ParticleData object"));\
+ ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object"));\
\
r->d()->datum-> VARIABLE = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();\
return QV4::Encode::undefined(); \
@@ -391,7 +391,7 @@ static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::CallContext *ctx)\
QV4::Scope scope(ctx); \
QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum) \
- ctx->throwError(QStringLiteral("Not a valid ParticleData object")); \
+ ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object")); \
\
return QV4::Encode(r->d()->datum-> GETTER ());\
}\
@@ -401,7 +401,7 @@ static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::CallContext *ctx)\
QV4::Scope scope(ctx); \
QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum)\
- ctx->throwError(QStringLiteral("Not a valid ParticleData object"));\
+ ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object"));\
\
r->d()->datum-> SETTER (ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN());\
return QV4::Encode::undefined(); \
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index a7b5326861..c66202262b 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -2861,7 +2861,7 @@ void RuntimeCodegen::throwSyntaxError(const AST::SourceLocation &loc, const QStr
if (hasError)
return;
hasError = true;
- context->throwSyntaxError(detail, _module->fileName, loc.startLine, loc.startColumn);
+ context->engine()->throwSyntaxError(detail, _module->fileName, loc.startLine, loc.startColumn);
}
void RuntimeCodegen::throwReferenceError(const AST::SourceLocation &loc, const QString &detail)
@@ -2869,7 +2869,7 @@ void RuntimeCodegen::throwReferenceError(const AST::SourceLocation &loc, const Q
if (hasError)
return;
hasError = true;
- context->throwReferenceError(detail, _module->fileName, loc.startLine, loc.startColumn);
+ context->engine()->throwReferenceError(detail, _module->fileName, loc.startLine, loc.startColumn);
}
#endif // V4_BOOTSTRAP
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp
index 4af8927a2e..a83e20a4d3 100644
--- a/src/qml/jsruntime/qv4argumentsobject.cpp
+++ b/src/qml/jsruntime/qv4argumentsobject.cpp
@@ -134,7 +134,7 @@ bool ArgumentsObject::defineOwnProperty(ExecutionContext *ctx, uint index, const
}
if (ctx->d()->strictMode && !result)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return result;
}
@@ -200,7 +200,7 @@ ReturnedValue ArgumentsGetterFunction::call(Managed *getter, CallData *callData)
Scoped<ArgumentsGetterFunction> g(scope, static_cast<ArgumentsGetterFunction *>(getter));
Scoped<ArgumentsObject> o(scope, callData->thisObject.as<ArgumentsObject>());
if (!o)
- return v4->currentContext()->throwTypeError();
+ return v4->throwTypeError();
Q_ASSERT(g->index() < static_cast<unsigned>(o->context()->d()->callData->argc));
return o->context()->argument(g->index());
@@ -215,7 +215,7 @@ ReturnedValue ArgumentsSetterFunction::call(Managed *setter, CallData *callData)
Scoped<ArgumentsSetterFunction> s(scope, static_cast<ArgumentsSetterFunction *>(setter));
Scoped<ArgumentsObject> o(scope, callData->thisObject.as<ArgumentsObject>());
if (!o)
- return v4->currentContext()->throwTypeError();
+ return v4->throwTypeError();
Q_ASSERT(s->index() < static_cast<unsigned>(o->context()->d()->callData->argc));
o->context()->d()->callData->args[s->index()] = callData->argc ? callData->args[0].asReturnedValue() : Encode::undefined();
diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp
index c97b16a255..82ab2a2a87 100644
--- a/src/qml/jsruntime/qv4arraybuffer.cpp
+++ b/src/qml/jsruntime/qv4arraybuffer.cpp
@@ -56,7 +56,7 @@ ReturnedValue ArrayBufferCtor::construct(Managed *m, CallData *callData)
return Encode::undefined();
uint len = (uint)qBound(0., dl, (double)UINT_MAX);
if (len != dl)
- return v4->currentContext()->throwRangeError(QLatin1String("ArrayBuffer constructor: invalid length"));
+ return v4->throwRangeError(QLatin1String("ArrayBuffer constructor: invalid length"));
Scoped<ArrayBuffer> a(scope, v4->memoryManager->alloc<ArrayBuffer>(v4, len));
if (scope.engine->hasException)
@@ -89,7 +89,7 @@ ArrayBuffer::Data::Data(ExecutionEngine *e, int length)
data = QTypedArrayData<char>::allocate(length + 1);
if (!data) {
data = 0;
- e->currentContext()->throwRangeError(QStringLiteral("ArrayBuffer: out of memory"));
+ e->throwRangeError(QStringLiteral("ArrayBuffer: out of memory"));
return;
}
data->size = length;
@@ -128,7 +128,7 @@ ReturnedValue ArrayBufferPrototype::method_get_byteLength(CallContext *ctx)
Scope scope(ctx);
Scoped<ArrayBuffer> v(scope, ctx->d()->callData->thisObject);
if (!v)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
return Encode(v->d()->data->size);
}
@@ -138,7 +138,7 @@ ReturnedValue ArrayBufferPrototype::method_slice(CallContext *ctx)
Scope scope(ctx);
Scoped<ArrayBuffer> a(scope, ctx->d()->callData->thisObject);
if (!a)
- return ctx->throwTypeError();
+ 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()) ?
@@ -151,14 +151,14 @@ ReturnedValue ArrayBufferPrototype::method_slice(CallContext *ctx)
Scoped<FunctionObject> constructor(scope, a->get(scope.engine->id_constructor));
if (!constructor)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
ScopedCallData callData(scope, 1);
double newLen = qMax(final - first, 0.);
callData->args[0] = QV4::Encode(newLen);
QV4::Scoped<ArrayBuffer> newBuffer(scope, constructor->construct(callData));
if (!newBuffer || newBuffer->d()->data->size < (int)newLen)
- return scope.engine->currentContext()->throwTypeError();
+ return scope.engine->throwTypeError();
memcpy(newBuffer->d()->data->data(), a->d()->data->data() + (uint)first, newLen);
diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp
index 4c8c172d0d..12bffef04e 100644
--- a/src/qml/jsruntime/qv4arraydata.cpp
+++ b/src/qml/jsruntime/qv4arraydata.cpp
@@ -747,7 +747,7 @@ void ArrayData::sort(ExecutionContext *context, Object *thisObject, const ValueR
return;
if (!(comparefn->isUndefined() || comparefn->asObject())) {
- context->throwTypeError();
+ context->engine()->throwTypeError();
return;
}
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index 1d17672714..bbc0867c22 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -58,7 +58,7 @@ ReturnedValue ArrayCtor::construct(Managed *m, CallData *callData)
len = callData->args[0].asArrayLength(&ok);
if (!ok)
- return v4->currentContext()->throwRangeError(callData->args[0]);
+ return v4->throwRangeError(callData->args[0]);
if (len < 0x1000)
a->arrayReserve(len);
@@ -286,7 +286,7 @@ ReturnedValue ArrayPrototype::method_push(CallContext *ctx)
instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(newLen)));
else {
ScopedString str(scope, ctx->d()->engine->newString(QStringLiteral("Array.prototype.push: Overflow")));
- return ctx->throwRangeError(str);
+ return ctx->engine()->throwRangeError(str);
}
return Encode(newLen);
}
@@ -691,7 +691,7 @@ ReturnedValue ArrayPrototype::method_every(CallContext *ctx)
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
ScopedCallData callData(scope, 3);
callData->args[2] = instance;
@@ -725,7 +725,7 @@ ReturnedValue ArrayPrototype::method_some(CallContext *ctx)
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
ScopedCallData callData(scope, 3);
callData->thisObject = ctx->argument(1);
@@ -759,7 +759,7 @@ ReturnedValue ArrayPrototype::method_forEach(CallContext *ctx)
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
ScopedCallData callData(scope, 3);
callData->thisObject = ctx->argument(1);
@@ -790,7 +790,7 @@ ReturnedValue ArrayPrototype::method_map(CallContext *ctx)
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
Scoped<ArrayObject> a(scope, ctx->d()->engine->newArrayObject());
a->arrayReserve(len);
@@ -827,7 +827,7 @@ ReturnedValue ArrayPrototype::method_filter(CallContext *ctx)
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
Scoped<ArrayObject> a(scope, ctx->d()->engine->newArrayObject());
a->arrayReserve(len);
@@ -868,7 +868,7 @@ ReturnedValue ArrayPrototype::method_reduce(CallContext *ctx)
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
uint k = 0;
ScopedValue acc(scope);
@@ -885,7 +885,7 @@ ReturnedValue ArrayPrototype::method_reduce(CallContext *ctx)
++k;
}
if (!kPresent)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
}
ScopedCallData callData(scope, 4);
@@ -918,11 +918,11 @@ ReturnedValue ArrayPrototype::method_reduceRight(CallContext *ctx)
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (len == 0) {
if (ctx->d()->callData->argc == 1)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return ctx->argument(1);
}
@@ -940,7 +940,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(CallContext *ctx)
--k;
}
if (!kPresent)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
}
ScopedCallData callData(scope, 4);
diff --git a/src/qml/jsruntime/qv4booleanobject.cpp b/src/qml/jsruntime/qv4booleanobject.cpp
index b58fcbe709..17f638426a 100644
--- a/src/qml/jsruntime/qv4booleanobject.cpp
+++ b/src/qml/jsruntime/qv4booleanobject.cpp
@@ -78,7 +78,7 @@ ReturnedValue BooleanPrototype::method_toString(CallContext *ctx)
Scope scope(ctx);
Scoped<BooleanObject> thisObject(scope, ctx->d()->callData->thisObject);
if (!thisObject)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
result = thisObject->value().booleanValue();
}
@@ -93,7 +93,7 @@ ReturnedValue BooleanPrototype::method_valueOf(CallContext *ctx)
Scope scope(ctx);
Scoped<BooleanObject> thisObject(scope, ctx->d()->callData->thisObject);
if (!thisObject)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return thisObject->value().asReturnedValue();
}
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index 7393041eb9..0d9c047521 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -237,7 +237,7 @@ bool ExecutionContext::deleteProperty(String *name)
}
if (d()->strictMode)
- throwSyntaxError(QStringLiteral("Can't delete property %1").arg(name->toQString()));
+ engine()->throwSyntaxError(QStringLiteral("Can't delete property %1").arg(name->toQString()));
return true;
}
@@ -328,7 +328,7 @@ void ExecutionContext::setProperty(String *name, const ValueRef value)
}
if (d()->strictMode || name->equals(d()->engine->id_this.getPointer())) {
ScopedValue n(scope, name->asReturnedValue());
- throwReferenceError(n);
+ engine()->throwReferenceError(n);
return;
}
d()->engine->globalObject->put(name, value);
@@ -395,7 +395,7 @@ ReturnedValue ExecutionContext::getProperty(String *name)
}
}
ScopedValue n(scope, name);
- return throwReferenceError(n);
+ return engine()->throwReferenceError(n);
}
ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object *&base)
@@ -464,100 +464,10 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object *&base)
}
}
ScopedValue n(scope, name);
- return throwReferenceError(n);
-}
-
-
-ReturnedValue ExecutionContext::throwError(const ValueRef value)
-{
- return d()->engine->throwException(value);
-}
-
-ReturnedValue ExecutionContext::throwError(const QString &message)
-{
- Scope scope(this);
- ScopedValue v(scope, d()->engine->newString(message));
- v = d()->engine->newErrorObject(v);
- return throwError(v);
-}
-
-ReturnedValue ExecutionContext::throwSyntaxError(const QString &message, const QString &fileName, int line, int column)
-{
- Scope scope(this);
- Scoped<Object> error(scope, d()->engine->newSyntaxErrorObject(message, fileName, line, column));
- return throwError(error);
-}
-
-ReturnedValue ExecutionContext::throwSyntaxError(const QString &message)
-{
- Scope scope(this);
- Scoped<Object> error(scope, d()->engine->newSyntaxErrorObject(message));
- return throwError(error);
-}
-
-ReturnedValue ExecutionContext::throwTypeError()
-{
- Scope scope(this);
- Scoped<Object> error(scope, d()->engine->newTypeErrorObject(QStringLiteral("Type error")));
- return throwError(error);
-}
-
-ReturnedValue ExecutionContext::throwTypeError(const QString &message)
-{
- Scope scope(this);
- Scoped<Object> error(scope, d()->engine->newTypeErrorObject(message));
- return throwError(error);
-}
-
-ReturnedValue ExecutionContext::throwUnimplemented(const QString &message)
-{
- Scope scope(this);
- ScopedValue v(scope, d()->engine->newString(QStringLiteral("Unimplemented ") + message));
- v = d()->engine->newErrorObject(v);
- return throwError(v);
+ return engine()->throwReferenceError(n);
}
ReturnedValue ExecutionContext::catchException(StackTrace *trace)
{
return d()->engine->catchException(this, trace);
}
-
-ReturnedValue ExecutionContext::throwReferenceError(const ValueRef value)
-{
- Scope scope(this);
- Scoped<String> s(scope, value->toString(this));
- QString msg = s->toQString() + QStringLiteral(" is not defined");
- Scoped<Object> error(scope, d()->engine->newReferenceErrorObject(msg));
- return throwError(error);
-}
-
-ReturnedValue ExecutionContext::throwReferenceError(const QString &message, const QString &fileName, int line, int column)
-{
- Scope scope(this);
- QString msg = message;
- Scoped<Object> error(scope, d()->engine->newReferenceErrorObject(msg, fileName, line, column));
- return throwError(error);
-}
-
-ReturnedValue ExecutionContext::throwRangeError(const ValueRef value)
-{
- Scope scope(this);
- ScopedString s(scope, value->toString(this));
- QString msg = s->toQString() + QStringLiteral(" out of range");
- ScopedObject error(scope, d()->engine->newRangeErrorObject(msg));
- return throwError(error);
-}
-
-ReturnedValue ExecutionContext::throwRangeError(const QString &message)
-{
- Scope scope(this);
- ScopedObject error(scope, d()->engine->newRangeErrorObject(message));
- return throwError(error);
-}
-
-ReturnedValue ExecutionContext::throwURIError(const ValueRef msg)
-{
- Scope scope(this);
- ScopedObject error(scope, d()->engine->newURIErrorObject(msg));
- return throwError(error);
-}
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index 5235b651fb..4f0f16b357 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -126,19 +126,6 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
void createMutableBinding(String *name, bool deletable);
- ReturnedValue throwError(const QV4::ValueRef value);
- ReturnedValue throwError(const QString &message);
- ReturnedValue throwSyntaxError(const QString &message);
- ReturnedValue throwSyntaxError(const QString &message, const QString &fileName, int lineNumber, int column);
- ReturnedValue throwTypeError();
- ReturnedValue throwTypeError(const QString &message);
- ReturnedValue throwReferenceError(const ValueRef value);
- ReturnedValue throwReferenceError(const QString &value, const QString &fileName, int lineNumber, int column);
- ReturnedValue throwRangeError(const ValueRef value);
- ReturnedValue throwRangeError(const QString &message);
- ReturnedValue throwURIError(const ValueRef msg);
- ReturnedValue throwUnimplemented(const QString &message);
-
void setProperty(String *name, const ValueRef value);
ReturnedValue getProperty(String *name);
ReturnedValue getPropertyAndBase(String *name, Object *&base);
diff --git a/src/qml/jsruntime/qv4dataview.cpp b/src/qml/jsruntime/qv4dataview.cpp
index 2750b2ceff..717a8f681f 100644
--- a/src/qml/jsruntime/qv4dataview.cpp
+++ b/src/qml/jsruntime/qv4dataview.cpp
@@ -52,7 +52,7 @@ ReturnedValue DataViewCtor::construct(Managed *m, CallData *callData)
Scope scope(m->engine());
Scoped<ArrayBuffer> buffer(scope, callData->argument(0));
if (!buffer)
- return scope.engine->currentContext()->throwTypeError();
+ return scope.engine->throwTypeError();
double bo = callData->argc > 1 ? callData->args[1].toNumber() : 0;
uint byteOffset = (uint)bo;
@@ -60,7 +60,7 @@ ReturnedValue DataViewCtor::construct(Managed *m, CallData *callData)
double bl = callData->argc < 3 || callData->args[2].isUndefined() ? (bufferLength - bo) : callData->args[2].toNumber();
uint byteLength = (uint)bl;
if (bo != byteOffset || bl != byteLength || byteOffset + byteLength > bufferLength)
- return scope.engine->currentContext()->throwRangeError(QStringLiteral("DataView: constructor arguments out of range"));
+ return scope.engine->throwRangeError(QStringLiteral("DataView: constructor arguments out of range"));
Scoped<DataView> a(scope, scope.engine->memoryManager->alloc<DataView>(scope.engine));
a->d()->buffer = buffer;
@@ -126,7 +126,7 @@ ReturnedValue DataViewPrototype::method_get_buffer(CallContext *ctx)
Scope scope(ctx);
Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
if (!v)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
return Encode(v->d()->buffer->asReturnedValue());
}
@@ -136,7 +136,7 @@ ReturnedValue DataViewPrototype::method_get_byteLength(CallContext *ctx)
Scope scope(ctx);
Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
if (!v)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
return Encode(v->d()->byteLength);
}
@@ -146,7 +146,7 @@ ReturnedValue DataViewPrototype::method_get_byteOffset(CallContext *ctx)
Scope scope(ctx);
Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
if (!v)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
return Encode(v->d()->byteOffset);
}
@@ -157,11 +157,11 @@ ReturnedValue DataViewPrototype::method_getChar(CallContext *ctx)
Scope scope(ctx);
Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
if (!v || ctx->d()->callData->argc < 1)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
double l = ctx->d()->callData->args[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
idx += v->d()->byteOffset;
T t = T(v->d()->buffer->d()->data->data()[idx]);
@@ -175,11 +175,11 @@ ReturnedValue DataViewPrototype::method_get(CallContext *ctx)
Scope scope(ctx);
Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
if (!v || ctx->d()->callData->argc < 1)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
double l = ctx->d()->callData->args[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
idx += v->d()->byteOffset;
bool littleEndian = ctx->d()->callData->argc < 2 ? false : ctx->d()->callData->args[1].toBoolean();
@@ -197,11 +197,11 @@ ReturnedValue DataViewPrototype::method_getFloat(CallContext *ctx)
Scope scope(ctx);
Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
if (!v || ctx->d()->callData->argc < 1)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
double l = ctx->d()->callData->args[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
idx += v->d()->byteOffset;
bool littleEndian = ctx->d()->callData->argc < 2 ? false : ctx->d()->callData->args[1].toBoolean();
@@ -235,11 +235,11 @@ ReturnedValue DataViewPrototype::method_setChar(CallContext *ctx)
Scope scope(ctx);
Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
if (!v || ctx->d()->callData->argc < 1)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
double l = ctx->d()->callData->args[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
idx += v->d()->byteOffset;
int val = ctx->d()->callData->argc >= 2 ? ctx->d()->callData->args[1].toInt32() : 0;
@@ -254,11 +254,11 @@ ReturnedValue DataViewPrototype::method_set(CallContext *ctx)
Scope scope(ctx);
Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
if (!v || ctx->d()->callData->argc < 1)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
double l = ctx->d()->callData->args[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
idx += v->d()->byteOffset;
int val = ctx->d()->callData->argc >= 2 ? ctx->d()->callData->args[1].toInt32() : 0;
@@ -279,11 +279,11 @@ ReturnedValue DataViewPrototype::method_setFloat(CallContext *ctx)
Scope scope(ctx);
Scoped<DataView> v(scope, ctx->d()->callData->thisObject);
if (!v || ctx->d()->callData->argc < 1)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
double l = ctx->d()->callData->args[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
idx += v->d()->byteOffset;
double val = ctx->d()->callData->argc >= 2 ? ctx->d()->callData->args[1].toNumber() : qSNaN();
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index c8bd73dd4c..25727166a5 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -764,7 +764,7 @@ double DatePrototype::getThisDate(ExecutionContext *ctx)
if (DateObject *thisObject = ctx->d()->callData->thisObject.asDateObject())
return thisObject->date().asDouble();
else {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return 0;
}
}
@@ -1000,7 +1000,7 @@ ReturnedValue DatePrototype::method_setTime(CallContext *ctx)
Scope scope(ctx);
Scoped<DateObject> self(scope, ctx->d()->callData->thisObject);
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
self->date().setDouble(TimeClip(t));
@@ -1012,7 +1012,7 @@ ReturnedValue DatePrototype::method_setMilliseconds(CallContext *ctx)
Scope scope(ctx);
Scoped<DateObject> self(scope, ctx->d()->callData->thisObject);
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = LocalTime(self->date().asDouble());
double ms = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
@@ -1024,7 +1024,7 @@ ReturnedValue DatePrototype::method_setUTCMilliseconds(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
double ms = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
@@ -1036,7 +1036,7 @@ ReturnedValue DatePrototype::method_setSeconds(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = LocalTime(self->date().asDouble());
double sec = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
@@ -1050,7 +1050,7 @@ ReturnedValue DatePrototype::method_setUTCSeconds(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
double sec = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
@@ -1064,7 +1064,7 @@ ReturnedValue DatePrototype::method_setMinutes(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = LocalTime(self->date().asDouble());
double min = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
@@ -1079,7 +1079,7 @@ ReturnedValue DatePrototype::method_setUTCMinutes(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
double min = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
@@ -1094,7 +1094,7 @@ ReturnedValue DatePrototype::method_setHours(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = LocalTime(self->date().asDouble());
double hour = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
@@ -1110,7 +1110,7 @@ ReturnedValue DatePrototype::method_setUTCHours(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
double hour = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
@@ -1126,7 +1126,7 @@ ReturnedValue DatePrototype::method_setDate(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = LocalTime(self->date().asDouble());
double date = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
@@ -1139,7 +1139,7 @@ ReturnedValue DatePrototype::method_setUTCDate(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
double date = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
@@ -1152,7 +1152,7 @@ ReturnedValue DatePrototype::method_setMonth(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = LocalTime(self->date().asDouble());
double month = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
@@ -1166,7 +1166,7 @@ ReturnedValue DatePrototype::method_setUTCMonth(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
double month = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
@@ -1180,7 +1180,7 @@ ReturnedValue DatePrototype::method_setYear(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
if (std::isnan(t))
@@ -1206,7 +1206,7 @@ ReturnedValue DatePrototype::method_setUTCFullYear(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
double year = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
@@ -1221,7 +1221,7 @@ ReturnedValue DatePrototype::method_setFullYear(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = LocalTime(self->date().asDouble());
if (std::isnan(t))
@@ -1238,7 +1238,7 @@ ReturnedValue DatePrototype::method_toUTCString(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
return ctx->d()->engine->newString(ToUTCString(t))->asReturnedValue();
@@ -1261,11 +1261,11 @@ ReturnedValue DatePrototype::method_toISOString(CallContext *ctx)
{
DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
double t = self->date().asDouble();
if (!std::isfinite(t))
- return ctx->throwRangeError(ctx->d()->callData->thisObject);
+ return ctx->engine()->throwRangeError(ctx->d()->callData->thisObject);
QString result;
int year = (int)YearFromTime(t);
@@ -1309,7 +1309,7 @@ ReturnedValue DatePrototype::method_toJSON(CallContext *ctx)
FunctionObject *toIso = v->asFunctionObject();
if (!toIso)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
ScopedCallData callData(scope, 0);
callData->thisObject = ctx->d()->callData->thisObject;
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 42cd860919..f72c2f8071 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -90,7 +90,7 @@ static QBasicAtomicInt engineSerial = Q_BASIC_ATOMIC_INITIALIZER(1);
static ReturnedValue throwTypeError(CallContext *ctx)
{
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
}
const int MinimumStackSize = 256; // in kbytes
@@ -444,7 +444,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
globalObject->defineDefaultProperty(QStringLiteral("unescape"), GlobalFunctions::method_unescape, 1);
Scoped<String> name(scope, newString(QStringLiteral("thrower")));
- thrower = ScopedFunctionObject(scope, BuiltinFunction::create(rootContext, name.getPointer(), throwTypeError)).getPointer();
+ thrower = ScopedFunctionObject(scope, BuiltinFunction::create(rootContext, name.getPointer(), ::throwTypeError)).getPointer();
}
ExecutionEngine::~ExecutionEngine()
@@ -968,7 +968,7 @@ QmlExtensions *ExecutionEngine::qmlExtensions()
return m_qmlExtensions;
}
-ReturnedValue ExecutionEngine::throwException(const ValueRef value)
+ReturnedValue ExecutionEngine::throwError(const ValueRef value)
{
// we can get in here with an exception already set, as the runtime
// doesn't check after every operation that can throw.
@@ -1006,6 +1006,92 @@ ReturnedValue ExecutionEngine::catchException(ExecutionContext *catchingContext,
return res;
}
+ReturnedValue ExecutionEngine::throwError(const QString &message)
+{
+ Scope scope(this);
+ ScopedValue v(scope, newString(message));
+ v = newErrorObject(v);
+ return throwError(v);
+}
+
+ReturnedValue ExecutionEngine::throwSyntaxError(const QString &message, const QString &fileName, int line, int column)
+{
+ Scope scope(this);
+ Scoped<Object> error(scope, newSyntaxErrorObject(message, fileName, line, column));
+ return throwError(error);
+}
+
+ReturnedValue ExecutionEngine::throwSyntaxError(const QString &message)
+{
+ Scope scope(this);
+ Scoped<Object> error(scope, newSyntaxErrorObject(message));
+ return throwError(error);
+}
+
+
+ReturnedValue ExecutionEngine::throwTypeError()
+{
+ Scope scope(this);
+ Scoped<Object> error(scope, newTypeErrorObject(QStringLiteral("Type error")));
+ return throwError(error);
+}
+
+ReturnedValue ExecutionEngine::throwTypeError(const QString &message)
+{
+ Scope scope(this);
+ Scoped<Object> error(scope, newTypeErrorObject(message));
+ return throwError(error);
+}
+
+ReturnedValue ExecutionEngine::throwReferenceError(const ValueRef value)
+{
+ Scope scope(this);
+ Scoped<String> s(scope, value->toString(this));
+ QString msg = s->toQString() + QStringLiteral(" is not defined");
+ Scoped<Object> error(scope, newReferenceErrorObject(msg));
+ return throwError(error);
+}
+
+ReturnedValue ExecutionEngine::throwReferenceError(const QString &message, const QString &fileName, int line, int column)
+{
+ Scope scope(this);
+ QString msg = message;
+ Scoped<Object> error(scope, newReferenceErrorObject(msg, fileName, line, column));
+ return throwError(error);
+}
+
+ReturnedValue ExecutionEngine::throwRangeError(const QString &message)
+{
+ Scope scope(this);
+ ScopedObject error(scope, newRangeErrorObject(message));
+ return throwError(error);
+}
+
+ReturnedValue ExecutionEngine::throwRangeError(const ValueRef value)
+{
+ Scope scope(this);
+ ScopedString s(scope, value->toString(this));
+ QString msg = s->toQString() + QStringLiteral(" out of range");
+ ScopedObject error(scope, newRangeErrorObject(msg));
+ return throwError(error);
+}
+
+ReturnedValue ExecutionEngine::throwURIError(const ValueRef msg)
+{
+ Scope scope(this);
+ ScopedObject error(scope, newURIErrorObject(msg));
+ return throwError(error);
+}
+
+ReturnedValue ExecutionEngine::throwUnimplemented(const QString &message)
+{
+ Scope scope(this);
+ ScopedValue v(scope, newString(QStringLiteral("Unimplemented ") + message));
+ v = newErrorObject(v);
+ return throwError(v);
+}
+
+
QQmlError ExecutionEngine::catchExceptionAsQmlError(ExecutionContext *context)
{
QV4::StackTrace trace;
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index 6c9b90cb30..6186c3c3d8 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -112,7 +112,7 @@ struct ExecutionContextSaver;
#define CHECK_STACK_LIMITS(v4) \
if ((v4->jsStackTop <= v4->jsStackLimit) && (reinterpret_cast<quintptr>(&v4) >= v4->cStackLimit || v4->recheckCStackLimits())) {} \
else \
- return v4->currentContext()->throwRangeError(QStringLiteral("Maximum call stack size exceeded."))
+ return v4->throwRangeError(QStringLiteral("Maximum call stack size exceeded."))
struct Q_QML_EXPORT ExecutionEngine
@@ -364,9 +364,21 @@ public:
Value exceptionValue;
StackTrace exceptionStackTrace;
- ReturnedValue throwException(const ValueRef value);
+ ReturnedValue throwError(const ValueRef value);
ReturnedValue catchException(ExecutionContext *catchingContext, StackTrace *trace);
+ ReturnedValue throwError(const QString &message);
+ ReturnedValue throwSyntaxError(const QString &message);
+ ReturnedValue throwSyntaxError(const QString &message, const QString &fileName, int lineNumber, int column);
+ ReturnedValue throwTypeError();
+ ReturnedValue throwTypeError(const QString &message);
+ ReturnedValue throwReferenceError(const ValueRef value);
+ ReturnedValue throwReferenceError(const QString &value, const QString &fileName, int lineNumber, int column);
+ ReturnedValue throwRangeError(const ValueRef value);
+ ReturnedValue throwRangeError(const QString &message);
+ ReturnedValue throwURIError(const ValueRef msg);
+ ReturnedValue throwUnimplemented(const QString &message);
+
// Use only inside catch(...) -- will re-throw if no JS exception
static QQmlError catchExceptionAsQmlError(QV4::ExecutionContext *context);
diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp
index d87083275d..19b5a8097f 100644
--- a/src/qml/jsruntime/qv4errorobject.cpp
+++ b/src/qml/jsruntime/qv4errorobject.cpp
@@ -150,7 +150,7 @@ ReturnedValue ErrorObject::method_get_stack(CallContext *ctx)
Scope scope(ctx);
Scoped<ErrorObject> This(scope, ctx->d()->callData->thisObject);
if (!This)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (!This->d()->stack) {
QString trace;
for (int i = 0; i < This->d()->stackTrace.count(); ++i) {
@@ -365,7 +365,7 @@ ReturnedValue ErrorPrototype::method_toString(CallContext *ctx)
Object *o = ctx->d()->callData->thisObject.asObject();
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
ScopedValue name(scope, o->get(ctx->d()->engine->id_name));
QString qname;
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 49a560d092..417aaff756 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -143,7 +143,7 @@ ReturnedValue FunctionObject::newInstance()
ReturnedValue FunctionObject::construct(Managed *that, CallData *)
{
- that->internalClass()->engine->currentContext()->throwTypeError();
+ that->internalClass()->engine->throwTypeError();
return Encode::undefined();
}
@@ -208,12 +208,12 @@ ReturnedValue FunctionCtor::construct(Managed *that, CallData *callData)
const bool parsed = parser.parseExpression();
if (!parsed)
- return v4->currentContext()->throwSyntaxError(QLatin1String("Parse error"));
+ return v4->throwSyntaxError(QLatin1String("Parse error"));
using namespace QQmlJS::AST;
FunctionExpression *fe = QQmlJS::AST::cast<FunctionExpression *>(parser.rootNode());
if (!fe)
- return v4->currentContext()->throwSyntaxError(QLatin1String("Parse error"));
+ return v4->throwSyntaxError(QLatin1String("Parse error"));
IR::Module module(v4->debugger != 0);
@@ -262,7 +262,7 @@ ReturnedValue FunctionPrototype::method_toString(CallContext *ctx)
{
FunctionObject *fun = ctx->d()->callData->thisObject.asFunctionObject();
if (!fun)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return ctx->d()->engine->newString(QStringLiteral("function() { [code] }"))->asReturnedValue();
}
@@ -272,7 +272,7 @@ ReturnedValue FunctionPrototype::method_apply(CallContext *ctx)
Scope scope(ctx);
FunctionObject *o = ctx->d()->callData->thisObject.asFunctionObject();
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
ScopedValue arg(scope, ctx->argument(1));
@@ -282,7 +282,7 @@ ReturnedValue FunctionPrototype::method_apply(CallContext *ctx)
if (!arr) {
len = 0;
if (!arg->isNullOrUndefined())
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
} else {
len = arr->getLength();
}
@@ -314,7 +314,7 @@ ReturnedValue FunctionPrototype::method_call(CallContext *ctx)
FunctionObject *o = ctx->d()->callData->thisObject.asFunctionObject();
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
ScopedCallData callData(scope, ctx->d()->callData->argc ? ctx->d()->callData->argc - 1 : 0);
if (ctx->d()->callData->argc) {
@@ -330,7 +330,7 @@ ReturnedValue FunctionPrototype::method_bind(CallContext *ctx)
Scope scope(ctx);
Scoped<FunctionObject> target(scope, ctx->d()->callData->thisObject);
if (!target)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
ScopedValue boundThis(scope, ctx->argument(0));
Members boundArgs;
@@ -539,7 +539,7 @@ BuiltinFunction::Data::Data(ExecutionContext *scope, String *name, ReturnedValue
ReturnedValue BuiltinFunction::construct(Managed *f, CallData *)
{
- return f->internalClass()->engine->currentContext()->throwTypeError();
+ return f->internalClass()->engine->throwTypeError();
}
ReturnedValue BuiltinFunction::call(Managed *that, CallData *callData)
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h
index 32fa2e0349..fc57ac0dfe 100644
--- a/src/qml/jsruntime/qv4functionobject_p.h
+++ b/src/qml/jsruntime/qv4functionobject_p.h
@@ -170,7 +170,7 @@ struct IndexedBuiltinFunction: FunctionObject
static ReturnedValue construct(Managed *m, CallData *)
{
- return m->engine()->currentContext()->throwTypeError();
+ return m->engine()->throwTypeError();
}
static ReturnedValue call(Managed *that, CallData *callData);
diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp
index 49032e5bcf..e194460bfd 100644
--- a/src/qml/jsruntime/qv4globalobject.cpp
+++ b/src/qml/jsruntime/qv4globalobject.cpp
@@ -584,7 +584,7 @@ ReturnedValue GlobalFunctions::method_decodeURI(CallContext *context)
if (!ok) {
Scope scope(context);
ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence")));
- return context->throwURIError(s);
+ return context->engine()->throwURIError(s);
}
return context->d()->engine->newString(out)->asReturnedValue();
@@ -602,7 +602,7 @@ ReturnedValue GlobalFunctions::method_decodeURIComponent(CallContext *context)
if (!ok) {
Scope scope(context);
ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence")));
- return context->throwURIError(s);
+ return context->engine()->throwURIError(s);
}
return context->d()->engine->newString(out)->asReturnedValue();
@@ -620,7 +620,7 @@ ReturnedValue GlobalFunctions::method_encodeURI(CallContext *context)
if (!ok) {
Scope scope(context);
ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence")));
- return context->throwURIError(s);
+ return context->engine()->throwURIError(s);
}
return context->d()->engine->newString(out)->asReturnedValue();
@@ -638,7 +638,7 @@ ReturnedValue GlobalFunctions::method_encodeURIComponent(CallContext *context)
if (!ok) {
Scope scope(context);
ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence")));
- return context->throwURIError(s);
+ return context->engine()->throwURIError(s);
}
return context->d()->engine->newString(out)->asReturnedValue();
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index fc5fb6aaeb..74cf26c381 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -777,7 +777,7 @@ QString Stringify::makeMember(const QString &key, ValueRef v)
QString Stringify::JO(Object *o)
{
if (stack.contains(o)) {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return QString();
}
@@ -834,7 +834,7 @@ QString Stringify::JO(Object *o)
QString Stringify::JA(ArrayObject *a)
{
if (stack.contains(a)) {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return QString();
}
@@ -900,7 +900,7 @@ ReturnedValue JsonObject::method_parse(CallContext *ctx)
ScopedValue result(scope, parser.parse(&error));
if (error.error != QJsonParseError::NoError) {
DEBUG << "parse error" << error.errorString();
- return ctx->throwSyntaxError(QStringLiteral("JSON.parse: Parse error"));
+ return ctx->engine()->throwSyntaxError(QStringLiteral("JSON.parse: Parse error"));
}
return result.asReturnedValue();
diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp
index 254666eca2..f7ebb62b8d 100644
--- a/src/qml/jsruntime/qv4lookup.cpp
+++ b/src/qml/jsruntime/qv4lookup.cpp
@@ -130,7 +130,7 @@ ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const ValueRef object, co
if (object->isNullOrUndefined()) {
QString message = QStringLiteral("Cannot read property '%1' of %2").arg(index->toQStringNoThrow()).arg(object->toQStringNoThrow());
- return ctx->throwTypeError(message);
+ return ctx->engine()->throwTypeError(message);
}
o = RuntimeHelpers::convertToObject(ctx, object);
@@ -240,7 +240,7 @@ ReturnedValue Lookup::getterGeneric(QV4::Lookup *l, const ValueRef object)
switch (object->type()) {
case Value::Undefined_Type:
case Value::Null_Type:
- return engine->currentContext()->throwTypeError();
+ return engine->throwTypeError();
case Value::Boolean_Type:
proto = engine->booleanClass->prototype;
break;
@@ -598,7 +598,7 @@ ReturnedValue Lookup::globalGetterGeneric(Lookup *l, ExecutionContext *ctx)
}
Scope scope(ctx);
Scoped<String> n(scope, l->name);
- return ctx->throwReferenceError(n);
+ return ctx->engine()->throwReferenceError(n);
}
ReturnedValue Lookup::globalGetter0(Lookup *l, ExecutionContext *ctx)
diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp
index 9f9c55d818..44826c94c8 100644
--- a/src/qml/jsruntime/qv4numberobject.cpp
+++ b/src/qml/jsruntime/qv4numberobject.cpp
@@ -101,7 +101,7 @@ inline ReturnedValue thisNumberValue(ExecutionContext *ctx)
return ctx->d()->callData->thisObject.asReturnedValue();
NumberObject *n = ctx->d()->callData->thisObject.asNumberObject();
if (!n)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return n->value().asReturnedValue();
}
@@ -111,7 +111,7 @@ inline double thisNumber(ExecutionContext *ctx)
return ctx->d()->callData->thisObject.asDouble();
NumberObject *n = ctx->d()->callData->thisObject.asNumberObject();
if (!n)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return n->value().asDouble();
}
@@ -124,7 +124,7 @@ ReturnedValue NumberPrototype::method_toString(CallContext *ctx)
if (ctx->d()->callData->argc && !ctx->d()->callData->args[0].isUndefined()) {
int radix = ctx->d()->callData->args[0].toInt32();
if (radix < 2 || radix > 36)
- return ctx->throwError(QString::fromLatin1("Number.prototype.toString: %0 is not a valid radix")
+ return ctx->engine()->throwError(QString::fromLatin1("Number.prototype.toString: %0 is not a valid radix")
.arg(radix));
if (std::isnan(num)) {
@@ -197,7 +197,7 @@ ReturnedValue NumberPrototype::method_toFixed(CallContext *ctx)
fdigits = 0;
if (fdigits < 0 || fdigits > 20)
- return ctx->throwRangeError(ctx->d()->callData->thisObject);
+ return ctx->engine()->throwRangeError(ctx->d()->callData->thisObject);
QString str;
if (std::isnan(v))
@@ -224,7 +224,7 @@ ReturnedValue NumberPrototype::method_toExponential(CallContext *ctx)
fdigits = ctx->d()->callData->args[0].toInt32();
if (fdigits < 0 || fdigits > 20) {
ScopedString error(scope, ctx->d()->engine->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range")));
- return ctx->throwRangeError(error);
+ return ctx->engine()->throwRangeError(error);
}
}
@@ -249,7 +249,7 @@ ReturnedValue NumberPrototype::method_toPrecision(CallContext *ctx)
double precision = ctx->d()->callData->args[0].toInt32();
if (precision < 1 || precision > 21) {
ScopedString error(scope, ctx->d()->engine->newString(QStringLiteral("Number.prototype.toPrecision: precision out of range")));
- return ctx->throwRangeError(error);
+ return ctx->engine()->throwRangeError(error);
}
char str[100];
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index b70a18f6a5..5d003ba287 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -117,7 +117,7 @@ void Object::putValue(Property *pd, PropertyAttributes attrs, const ValueRef val
reject:
if (engine()->currentContext()->d()->strictMode)
- engine()->currentContext()->throwTypeError();
+ engine()->throwTypeError();
}
void Object::defineDefaultProperty(const QString &name, ValueRef value)
@@ -356,12 +356,12 @@ bool Object::hasOwnProperty(uint index) const
ReturnedValue Object::construct(Managed *m, CallData *)
{
- return m->engine()->currentContext()->throwTypeError();
+ return m->engine()->throwTypeError();
}
ReturnedValue Object::call(Managed *m, CallData *)
{
- return m->engine()->currentContext()->throwTypeError();
+ return m->engine()->throwTypeError();
}
ReturnedValue Object::get(Managed *m, String *name, bool *hasProperty)
@@ -665,7 +665,7 @@ void Object::internalPut(String *name, const ValueRef value)
bool ok;
uint l = value->asArrayLength(&ok);
if (!ok) {
- engine()->currentContext()->throwRangeError(value);
+ engine()->throwRangeError(value);
return;
}
ok = setArrayLength(l);
@@ -714,7 +714,7 @@ void Object::internalPut(String *name, const ValueRef value)
QString message = QStringLiteral("Cannot assign to read-only property \"");
message += name->toQString();
message += QLatin1Char('\"');
- engine()->currentContext()->throwTypeError(message);
+ engine()->throwTypeError(message);
}
}
@@ -783,7 +783,7 @@ void Object::internalPutIndexed(uint index, const ValueRef value)
reject:
if (engine()->currentContext()->d()->strictMode)
- engine()->currentContext()->throwTypeError();
+ engine()->throwTypeError();
}
// Section 8.12.7
@@ -805,7 +805,7 @@ bool Object::internalDeleteProperty(String *name)
return true;
}
if (engine()->currentContext()->d()->strictMode)
- engine()->currentContext()->throwTypeError();
+ engine()->throwTypeError();
return false;
}
@@ -821,7 +821,7 @@ bool Object::internalDeleteIndexedProperty(uint index)
return true;
if (engine()->currentContext()->d()->strictMode)
- engine()->currentContext()->throwTypeError();
+ engine()->throwTypeError();
return false;
}
@@ -853,7 +853,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, String *name, const Pr
uint l = p.value.asArrayLength(&ok);
if (!ok) {
ScopedValue v(scope, p.value);
- ctx->throwRangeError(v);
+ ctx->engine()->throwRangeError(v);
return false;
}
succeeded = setArrayLength(l);
@@ -887,7 +887,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, String *name, const Pr
return __defineOwnProperty__(ctx, memberIndex, name, p, attrs);
reject:
if (ctx->d()->strictMode)
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return false;
}
@@ -903,7 +903,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Prop
return defineOwnProperty2(ctx, index, p, attrs);
reject:
if (ctx->d()->strictMode)
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return false;
}
@@ -939,7 +939,7 @@ bool Object::defineOwnProperty2(ExecutionContext *ctx, uint index, const Propert
return __defineOwnProperty__(ctx, index, 0, p, attrs);
reject:
if (ctx->d()->strictMode)
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return false;
}
@@ -1032,7 +1032,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, String *me
return true;
reject:
if (ctx->d()->strictMode)
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return false;
}
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index d448d21f0c..5a4fe253e2 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -118,7 +118,7 @@ ReturnedValue ObjectPrototype::method_getPrototypeOf(CallContext *ctx)
Scope scope(ctx);
Scoped<Object> o(scope, ctx->argument(0));
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
Scoped<Object> p(scope, o->prototype());
return !!p ? p->asReturnedValue() : Encode::null();
@@ -129,7 +129,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptor(CallContext *ctx)
Scope scope(ctx);
Scoped<Object> O(scope, ctx->argument(0));
if (!O)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (ArgumentsObject::isNonStrictArgumentsObject(O.getPointer()))
Scoped<ArgumentsObject>(scope, O)->fullyCreate();
@@ -148,7 +148,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyNames(CallContext *context)
Scope scope(context);
ScopedObject O(scope, context->argument(0));
if (!O)
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
ScopedArrayObject array(scope, getOwnPropertyNames(context->d()->engine, context->d()->callData->args[0]));
return array.asReturnedValue();
@@ -159,7 +159,7 @@ ReturnedValue ObjectPrototype::method_create(CallContext *ctx)
Scope scope(ctx);
ScopedValue O(scope, ctx->argument(0));
if (!O->isObject() && !O->isNull())
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
Scoped<Object> newObject(scope, ctx->d()->engine->newObject());
newObject->setPrototype(O->asObject());
@@ -177,7 +177,7 @@ ReturnedValue ObjectPrototype::method_defineProperty(CallContext *ctx)
Scope scope(ctx);
Scoped<Object> O(scope, ctx->argument(0));
if (!O)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
Scoped<String> name(scope, ctx->argument(1), Scoped<String>::Convert);
if (scope.engine->hasException)
@@ -191,7 +191,7 @@ ReturnedValue ObjectPrototype::method_defineProperty(CallContext *ctx)
return Encode::undefined();
if (!O->__defineOwnProperty__(ctx, name.getPointer(), pd, attrs))
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return O.asReturnedValue();
}
@@ -201,7 +201,7 @@ ReturnedValue ObjectPrototype::method_defineProperties(CallContext *ctx)
Scope scope(ctx);
Scoped<Object> O(scope, ctx->argument(0));
if (!O)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
Scoped<Object> o(scope, ctx->argument(1), Scoped<Object>::Convert);
if (scope.engine->hasException)
@@ -231,7 +231,7 @@ ReturnedValue ObjectPrototype::method_defineProperties(CallContext *ctx)
else
ok = O->__defineOwnProperty__(ctx, index, n, nattrs);
if (!ok)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
}
return O.asReturnedValue();
@@ -242,7 +242,7 @@ ReturnedValue ObjectPrototype::method_seal(CallContext *ctx)
Scope scope(ctx);
Scoped<Object> o(scope, ctx->argument(0));
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
o->setExtensible(false);
@@ -264,7 +264,7 @@ ReturnedValue ObjectPrototype::method_freeze(CallContext *ctx)
Scope scope(ctx);
Scoped<Object> o(scope, ctx->argument(0));
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (ArgumentsObject::isNonStrictArgumentsObject(o.getPointer()))
Scoped<ArgumentsObject>(scope, o)->fullyCreate();
@@ -290,7 +290,7 @@ ReturnedValue ObjectPrototype::method_preventExtensions(CallContext *ctx)
Scope scope(ctx);
Scoped<Object> o(scope, ctx->argument(0));
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
o->setExtensible(false);
return o.asReturnedValue();
@@ -301,7 +301,7 @@ ReturnedValue ObjectPrototype::method_isSealed(CallContext *ctx)
Scope scope(ctx);
Scoped<Object> o(scope, ctx->argument(0));
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (o->isExtensible())
return Encode(false);
@@ -330,7 +330,7 @@ ReturnedValue ObjectPrototype::method_isFrozen(CallContext *ctx)
Scope scope(ctx);
Scoped<Object> o(scope, ctx->argument(0));
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (o->isExtensible())
return Encode(false);
@@ -359,7 +359,7 @@ ReturnedValue ObjectPrototype::method_isExtensible(CallContext *ctx)
Scope scope(ctx);
Scoped<Object> o(scope, ctx->argument(0));
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return Encode((bool)o->isExtensible());
}
@@ -369,7 +369,7 @@ ReturnedValue ObjectPrototype::method_keys(CallContext *ctx)
Scope scope(ctx);
Scoped<Object> o(scope, ctx->argument(0));
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
Scoped<ArrayObject> a(scope, ctx->d()->engine->newArrayObject());
@@ -407,7 +407,7 @@ ReturnedValue ObjectPrototype::method_toLocaleString(CallContext *ctx)
return Encode::undefined();
Scoped<FunctionObject> f(scope, o->get(ctx->d()->engine->id_toString));
if (!f)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
ScopedCallData callData(scope, 0);
callData->thisObject = o;
return f->call(callData);
@@ -474,12 +474,12 @@ ReturnedValue ObjectPrototype::method_propertyIsEnumerable(CallContext *ctx)
ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx)
{
if (ctx->d()->callData->argc < 2)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
Scope scope(ctx);
Scoped<FunctionObject> f(scope, ctx->argument(1));
if (!f)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
Scoped<String> prop(scope, ctx->argument(0), Scoped<String>::Convert);
if (scope.engine->hasException)
@@ -502,12 +502,12 @@ ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx)
ReturnedValue ObjectPrototype::method_defineSetter(CallContext *ctx)
{
if (ctx->d()->callData->argc < 2)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
Scope scope(ctx);
Scoped<FunctionObject> f(scope, ctx->argument(1));
if (!f)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
Scoped<String> prop(scope, ctx->argument(0), Scoped<String>::Convert);
if (scope.engine->hasException)
@@ -532,7 +532,7 @@ ReturnedValue ObjectPrototype::method_get_proto(CallContext *ctx)
Scope scope(ctx);
ScopedObject o(scope, ctx->d()->callData->thisObject.asObject());
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return o->prototype()->asReturnedValue();
}
@@ -542,7 +542,7 @@ ReturnedValue ObjectPrototype::method_set_proto(CallContext *ctx)
Scope scope(ctx);
Scoped<Object> o(scope, ctx->d()->callData->thisObject);
if (!o || !ctx->d()->callData->argc)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (ctx->d()->callData->args[0].isNull()) {
o->setPrototype(0);
@@ -559,7 +559,7 @@ ReturnedValue ObjectPrototype::method_set_proto(CallContext *ctx)
}
}
if (!ok)
- return ctx->throwTypeError(QStringLiteral("Cyclic __proto__ value"));
+ return ctx->engine()->throwTypeError(QStringLiteral("Cyclic __proto__ value"));
return Encode::undefined();
}
@@ -568,7 +568,7 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, const ValueRef
Scope scope(ctx);
ScopedObject o(scope, v);
if (!o) {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return;
}
@@ -589,7 +589,7 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, const ValueRef
if (f || get->isUndefined()) {
desc->value = get;
} else {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return;
}
attrs->setType(PropertyAttributes::Accessor);
@@ -601,7 +601,7 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, const ValueRef
if (f || set->isUndefined()) {
desc->set = set;
} else {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return;
}
attrs->setType(PropertyAttributes::Accessor);
@@ -609,7 +609,7 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, const ValueRef
if (o->hasProperty(ctx->d()->engine->id_writable)) {
if (attrs->isAccessor()) {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return;
}
attrs->setWritable((tmp = o->get(ctx->d()->engine->id_writable))->toBoolean());
@@ -619,7 +619,7 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, const ValueRef
if (o->hasProperty(ctx->d()->engine->id_value)) {
if (attrs->isAccessor()) {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return;
}
desc->value = o->get(ctx->d()->engine->id_value);
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index f2c30e618f..77bfc24a29 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -443,7 +443,7 @@ void QObjectWrapper::setProperty(QObject *object, ExecutionContext *ctx, QQmlPro
if (!property->isWritable() && !property->isQList()) {
QString error = QLatin1String("Cannot assign to read-only property \"") +
property->name(object) + QLatin1Char('\"');
- ctx->throwTypeError(error);
+ ctx->engine()->throwTypeError(error);
return;
}
@@ -459,7 +459,7 @@ void QObjectWrapper::setProperty(QObject *object, ExecutionContext *ctx, QQmlPro
error += QLatin1String("[unknown property type]");
else
error += QLatin1String(QMetaType::typeName(property->propType));
- ctx->throwError(error);
+ ctx->engine()->throwError(error);
return;
}
} else {
@@ -511,7 +511,7 @@ void QObjectWrapper::setProperty(QObject *object, ExecutionContext *ctx, QQmlPro
error += QLatin1String("[unknown property type]");
else
error += QLatin1String(QMetaType::typeName(property->propType));
- ctx->throwError(error);
+ ctx->engine()->throwError(error);
return;
} else if (value->asFunctionObject()) {
// this is handled by the binding creation above
@@ -560,7 +560,7 @@ void QObjectWrapper::setProperty(QObject *object, ExecutionContext *ctx, QQmlPro
QLatin1String(valueType) +
QLatin1String(" to ") +
QLatin1String(targetTypeName);
- ctx->throwError(error);
+ ctx->engine()->throwError(error);
return;
}
}
@@ -693,7 +693,7 @@ void QObjectWrapper::put(Managed *m, String *name, const ValueRef value)
if (ddata && ddata->context) {
QString error = QLatin1String("Cannot assign to non-existent property \"") +
name->toQString() + QLatin1Char('\"');
- v4->currentContext()->throwError(error);
+ v4->throwError(error);
} else {
QV4::Object::put(m, name, value);
}
@@ -1374,7 +1374,7 @@ static QV4::ReturnedValue CallPrecise(QObject *object, const QQmlPropertyData &d
if (returnType == QMetaType::UnknownType) {
QString typeName = QString::fromLatin1(unknownTypeError);
QString error = QString::fromLatin1("Unknown method return type: %1").arg(typeName);
- return QV8Engine::getV4(engine)->currentContext()->throwError(error);
+ return QV8Engine::getV4(engine)->throwError(error);
}
if (data.hasArguments()) {
@@ -1388,12 +1388,12 @@ static QV4::ReturnedValue CallPrecise(QObject *object, const QQmlPropertyData &d
if (!args) {
QString typeName = QString::fromLatin1(unknownTypeError);
QString error = QString::fromLatin1("Unknown method parameter type: %1").arg(typeName);
- return QV8Engine::getV4(engine)->currentContext()->throwError(error);
+ return QV8Engine::getV4(engine)->throwError(error);
}
if (args[0] > callArgs->argc) {
QString error = QLatin1String("Insufficient arguments");
- return QV8Engine::getV4(engine)->currentContext()->throwError(error);
+ return QV8Engine::getV4(engine)->throwError(error);
}
return CallMethod(object, data.coreIndex, returnType, args[0], args + 1, engine, callArgs);
@@ -1492,7 +1492,7 @@ static QV4::ReturnedValue CallOverloaded(QObject *object, const QQmlPropertyData
candidate = RelatedMethod(object, candidate, dummy);
}
- return QV8Engine::getV4(engine)->currentContext()->throwError(error);
+ return QV8Engine::getV4(engine)->throwError(error);
}
}
@@ -1793,7 +1793,7 @@ QV4::ReturnedValue QObjectMethod::method_destroy(QV4::ExecutionContext *ctx, con
if (!d()->object)
return Encode::undefined();
if (QQmlData::keepAliveDuringGarbageCollection(d()->object))
- return ctx->throwError(QStringLiteral("Invalid attempt to destroy() an indestructible object"));
+ return ctx->engine()->throwError(QStringLiteral("Invalid attempt to destroy() an indestructible object"));
int delay = 0;
if (argc > 0)
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index f1771782d7..b16a6bd875 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -254,7 +254,7 @@ ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData)
Scoped<RegExpObject> re(scope, r);
if (re) {
if (!f->isUndefined())
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return Encode(ctx->d()->engine->newRegExpObject(re->value(), re->global()));
}
@@ -281,14 +281,14 @@ ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData)
} else if (str.at(i) == QLatin1Char('m') && !multiLine) {
multiLine = true;
} else {
- return ctx->throwSyntaxError(QStringLiteral("Invalid flags supplied to RegExp constructor"));
+ return ctx->engine()->throwSyntaxError(QStringLiteral("Invalid flags supplied to RegExp constructor"));
}
}
}
Scoped<RegExp> regexp(scope, RegExp::create(ctx->d()->engine, pattern, ignoreCase, multiLine));
if (!regexp->isValid())
- return ctx->throwSyntaxError(QStringLiteral("Invalid regular expression"));
+ return ctx->engine()->throwSyntaxError(QStringLiteral("Invalid regular expression"));
return Encode(ctx->d()->engine->newRegExpObject(regexp, global));
}
@@ -353,7 +353,7 @@ ReturnedValue RegExpPrototype::method_exec(CallContext *ctx)
Scope scope(ctx);
Scoped<RegExpObject> r(scope, ctx->d()->callData->thisObject.as<RegExpObject>());
if (!r)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
ScopedValue arg(scope, ctx->argument(0));
arg = RuntimeHelpers::toString(ctx, arg);
@@ -417,7 +417,7 @@ ReturnedValue RegExpPrototype::method_toString(CallContext *ctx)
Scope scope(ctx);
Scoped<RegExpObject> r(scope, ctx->d()->callData->thisObject.as<RegExpObject>());
if (!r)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return ctx->d()->engine->newString(r->toString())->asReturnedValue();
}
@@ -427,7 +427,7 @@ ReturnedValue RegExpPrototype::method_compile(CallContext *ctx)
Scope scope(ctx);
Scoped<RegExpObject> r(scope, ctx->d()->callData->thisObject.as<RegExpObject>());
if (!r)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
ScopedCallData callData(scope, ctx->d()->callData->argc);
memcpy(callData->args, ctx->d()->callData->args, ctx->d()->callData->argc*sizeof(Value));
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index fbf5ba1759..b817bc594b 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -300,7 +300,7 @@ QV4::ReturnedValue Runtime::instanceof(ExecutionContext *ctx, const ValueRef lef
FunctionObject *f = right->asFunctionObject();
if (!f)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (f->subtype() == FunctionObject::BoundFunction)
f = static_cast<BoundFunction *>(f)->target();
@@ -311,7 +311,7 @@ QV4::ReturnedValue Runtime::instanceof(ExecutionContext *ctx, const ValueRef lef
Object *o = QV4::Value::fromReturnedValue(f->protoProperty()).asObject();
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
while (v) {
v = v->prototype();
@@ -328,7 +328,7 @@ QV4::ReturnedValue Runtime::instanceof(ExecutionContext *ctx, const ValueRef lef
QV4::ReturnedValue Runtime::in(ExecutionContext *ctx, const ValueRef left, const ValueRef right)
{
if (!right->isObject())
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
Scope scope(ctx);
ScopedString s(scope, left->toString(ctx));
if (scope.hasException())
@@ -406,7 +406,7 @@ ReturnedValue RuntimeHelpers::objectDefaultValue(Object *object, int typeHint)
return r->asReturnedValue();
}
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
}
@@ -417,7 +417,7 @@ Returned<Object> *RuntimeHelpers::convertToObject(ExecutionContext *ctx, const V
switch (value->type()) {
case Value::Undefined_Type:
case Value::Null_Type:
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return 0;
case Value::Boolean_Type:
return ctx->engine()->newBooleanObject(value);
@@ -571,7 +571,7 @@ ReturnedValue Runtime::getElement(ExecutionContext *ctx, const ValueRef object,
if (object->isNullOrUndefined()) {
QString message = QStringLiteral("Cannot read property '%1' of %2").arg(index->toQStringNoThrow()).arg(object->toQStringNoThrow());
- return ctx->throwTypeError(message);
+ return ctx->engine()->throwTypeError(message);
}
o = RuntimeHelpers::convertToObject(ctx, object);
@@ -654,7 +654,7 @@ ReturnedValue Runtime::getProperty(ExecutionContext *ctx, const ValueRef object,
if (object->isNullOrUndefined()) {
QString message = QStringLiteral("Cannot read property '%1' of %2").arg(name->toQString()).arg(object->toQStringNoThrow());
- return ctx->throwTypeError(message);
+ return ctx->engine()->throwTypeError(message);
}
o = RuntimeHelpers::convertToObject(ctx, object);
@@ -884,7 +884,7 @@ ReturnedValue Runtime::callGlobalLookup(ExecutionContext *context, uint index, C
Lookup *l = context->d()->lookups + index;
Scoped<FunctionObject> o(scope, l->globalGetter(l, context));
if (!o)
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
if (o.getPointer() == scope.engine->evalFunction && l->name->equals(scope.engine->id_eval))
return static_cast<EvalFunction *>(o.getPointer())->evalCall(callData, true);
@@ -914,7 +914,7 @@ ReturnedValue Runtime::callActivationProperty(ExecutionContext *context, String
if (base)
objectAsString = ScopedValue(scope, base.asReturnedValue())->toQStringNoThrow();
QString msg = QStringLiteral("Property '%1' of object %2 is not a function").arg(name->toQString()).arg(objectAsString);
- return context->throwTypeError(msg);
+ return context->engine()->throwTypeError(msg);
}
if (o == scope.engine->evalFunction && name->equals(scope.engine->id_eval)) {
@@ -932,7 +932,7 @@ ReturnedValue Runtime::callProperty(ExecutionContext *context, String *name, Cal
Q_ASSERT(!callData->thisObject.isEmpty());
if (callData->thisObject.isNullOrUndefined()) {
QString message = QStringLiteral("Cannot call method '%1' of %2").arg(name->toQString()).arg(callData->thisObject.toQStringNoThrow());
- return context->throwTypeError(message);
+ return context->engine()->throwTypeError(message);
}
baseObject = RuntimeHelpers::convertToObject(context, ValueRef(&callData->thisObject));
@@ -944,7 +944,7 @@ ReturnedValue Runtime::callProperty(ExecutionContext *context, String *name, Cal
Scoped<FunctionObject> o(scope, baseObject->get(name));
if (!o) {
QString error = QStringLiteral("Property '%1' of object %2 is not a function").arg(name->toQString(), callData->thisObject.toQStringNoThrow());
- return context->throwTypeError(error);
+ return context->engine()->throwTypeError(error);
}
return o->call(callData);
@@ -956,7 +956,7 @@ ReturnedValue Runtime::callPropertyLookup(ExecutionContext *context, uint index,
Value v;
v = l->getter(l, callData->thisObject);
if (!v.isObject())
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return v.objectValue()->call(callData);
}
@@ -973,7 +973,7 @@ ReturnedValue Runtime::callElement(ExecutionContext *context, const ValueRef ind
ScopedObject o(scope, baseObject->get(s.getPointer()));
if (!o)
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return o->call(callData);
}
@@ -981,7 +981,7 @@ ReturnedValue Runtime::callElement(ExecutionContext *context, const ValueRef ind
ReturnedValue Runtime::callValue(ExecutionContext *context, const ValueRef func, CallData *callData)
{
if (!func->isObject())
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return func->objectValue()->call(callData);
}
@@ -995,7 +995,7 @@ ReturnedValue Runtime::constructGlobalLookup(ExecutionContext *context, uint ind
Lookup *l = context->d()->lookups + index;
Scoped<Object> f(scope, l->globalGetter(l, context));
if (!f)
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return f->construct(callData);
}
@@ -1010,7 +1010,7 @@ ReturnedValue Runtime::constructActivationProperty(ExecutionContext *context, St
Object *f = func->asObject();
if (!f)
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return f->construct(callData);
}
@@ -1019,7 +1019,7 @@ ReturnedValue Runtime::constructValue(ExecutionContext *context, const ValueRef
{
Object *f = func->asObject();
if (!f)
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return f->construct(callData);
}
@@ -1033,7 +1033,7 @@ ReturnedValue Runtime::constructProperty(ExecutionContext *context, String *name
Scoped<Object> f(scope, thisObject->get(name));
if (!f)
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return f->construct(callData);
}
@@ -1044,7 +1044,7 @@ ReturnedValue Runtime::constructPropertyLookup(ExecutionContext *context, uint i
Value v;
v = l->getter(l, callData->thisObject);
if (!v.isObject())
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return v.objectValue()->construct(callData);
}
@@ -1053,7 +1053,7 @@ ReturnedValue Runtime::constructPropertyLookup(ExecutionContext *context, uint i
void Runtime::throwException(ExecutionContext *context, const ValueRef value)
{
if (!value->isEmpty())
- context->throwError(value);
+ context->engine()->throwError(value);
}
ReturnedValue Runtime::typeofValue(ExecutionContext *ctx, const ValueRef value)
@@ -1320,7 +1320,7 @@ ReturnedValue Runtime::getQmlQObjectProperty(ExecutionContext *ctx, const ValueR
Scope scope(ctx);
QV4::Scoped<QObjectWrapper> wrapper(scope, object);
if (!wrapper) {
- ctx->throwTypeError(QStringLiteral("Cannot read property of null"));
+ ctx->engine()->throwTypeError(QStringLiteral("Cannot read property of null"));
return Encode::undefined();
}
return QV4::QObjectWrapper::getProperty(wrapper->object(), ctx, propertyIndex, captureRequired);
@@ -1343,7 +1343,7 @@ ReturnedValue Runtime::getQmlSingletonQObjectProperty(ExecutionContext *ctx, con
Scope scope(ctx);
QV4::Scoped<QmlTypeWrapper> wrapper(scope, object);
if (!wrapper) {
- ctx->throwTypeError(QStringLiteral("Cannot read property of null"));
+ scope.engine->throwTypeError(QStringLiteral("Cannot read property of null"));
return Encode::undefined();
}
return QV4::QObjectWrapper::getProperty(wrapper->singletonObject(), ctx, propertyIndex, captureRequired);
@@ -1354,7 +1354,7 @@ void Runtime::setQmlQObjectProperty(ExecutionContext *ctx, const ValueRef object
Scope scope(ctx);
QV4::Scoped<QObjectWrapper> wrapper(scope, object);
if (!wrapper) {
- ctx->throwTypeError(QStringLiteral("Cannot write property of null"));
+ ctx->engine()->throwTypeError(QStringLiteral("Cannot write property of null"));
return;
}
wrapper->setProperty(ctx, propertyIndex, value);
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index 20b0832a96..a3454d8dc6 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -224,7 +224,7 @@ void Script::parse()
foreach (const QQmlJS::DiagnosticMessage &m, parser.diagnosticMessages()) {
if (m.isError()) {
- scope->throwSyntaxError(m.message, sourceFile, m.loc.startLine, m.loc.startColumn);
+ scope->engine()->throwSyntaxError(m.message, sourceFile, m.loc.startLine, m.loc.startColumn);
return;
} else {
qWarning() << sourceFile << ':' << m.loc.startLine << ':' << m.loc.startColumn
@@ -268,7 +268,7 @@ void Script::parse()
if (!vmFunction) {
// ### FIX file/line number
Scoped<Object> error(valueScope, v4->newSyntaxErrorObject(QStringLiteral("Syntax error")));
- v4->currentContext()->throwError(error);
+ v4->throwError(error);
}
}
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index 462c4b43f4..00b78b9954 100644
--- a/src/qml/jsruntime/qv4sequenceobject.cpp
+++ b/src/qml/jsruntime/qv4sequenceobject.cpp
@@ -402,7 +402,7 @@ public:
QV4::Scope scope(ctx);
QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->d()->callData->thisObject.as<QQmlSequence<Container> >());
if (!This)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (This->d()->isReference) {
if (!This->d()->object)
@@ -417,7 +417,7 @@ public:
QV4::Scope scope(ctx);
QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->d()->callData->thisObject.as<QQmlSequence<Container> >());
if (!This)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
quint32 newLength = ctx->d()->callData->args[0].toUInt32();
/* Qt containers have int (rather than uint) allowable indexes. */
@@ -545,7 +545,7 @@ QV4::ReturnedValue SequencePrototype::method_sort(QV4::CallContext *ctx)
QV4::Scope scope(ctx);
QV4::ScopedObject o(scope, ctx->d()->callData->thisObject);
if (!o || !o->isListType())
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (ctx->d()->callData->argc >= 2)
return o.asReturnedValue();
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index 397a6efdf8..0591a05b37 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -109,13 +109,13 @@ bool StringObject::deleteIndexedProperty(Managed *m, uint index)
Scope scope(v4);
Scoped<StringObject> o(scope, m->asStringObject());
if (!o) {
- v4->currentContext()->throwTypeError();
+ v4->throwTypeError();
return false;
}
if (index < static_cast<uint>(o->d()->value.stringValue()->toQString().length())) {
if (v4->currentContext()->d()->strictMode)
- v4->currentContext()->throwTypeError();
+ v4->throwTypeError();
return false;
}
return true;
@@ -230,7 +230,7 @@ static QString getThisString(ExecutionContext *ctx)
if (StringObject *thisString = t->asStringObject())
return thisString->d()->value.stringValue()->toQString();
if (t->isUndefined() || t->isNull()) {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return QString();
}
return t->toQString();
@@ -243,7 +243,7 @@ ReturnedValue StringPrototype::method_toString(CallContext *context)
StringObject *o = context->d()->callData->thisObject.asStringObject();
if (!o)
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return o->d()->value.asReturnedValue();
}
@@ -365,7 +365,7 @@ ReturnedValue StringPrototype::method_localeCompare(CallContext *context)
ReturnedValue StringPrototype::method_match(CallContext *context)
{
if (context->d()->callData->thisObject.isUndefined() || context->d()->callData->thisObject.isNull())
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
Scope scope(context);
ScopedString s(scope, context->d()->callData->thisObject.toString(context));
@@ -380,7 +380,7 @@ ReturnedValue StringPrototype::method_match(CallContext *context)
if (!rx)
// ### CHECK
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
bool global = rx->global();
diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp
index 08d272862b..06712831c2 100644
--- a/src/qml/jsruntime/qv4typedarray.cpp
+++ b/src/qml/jsruntime/qv4typedarray.cpp
@@ -212,7 +212,7 @@ ReturnedValue TypedArrayCtor::construct(Managed *m, CallData *callData)
return Encode::undefined();
uint len = (uint)l;
if (l != len)
- scope.engine->currentContext()->throwRangeError(QStringLiteral("Non integer length for typed array."));
+ scope.engine->throwRangeError(QStringLiteral("Non integer length for typed array."));
uint byteLength = len * operations[that->d()->type].bytesPerElement;
Scoped<ArrayBuffer> buffer(scope, scope.engine->memoryManager->alloc<ArrayBuffer>(scope.engine, byteLength));
if (scope.engine->hasException)
@@ -271,20 +271,20 @@ ReturnedValue TypedArrayCtor::construct(Managed *m, CallData *callData)
uint byteOffset = (uint)dbyteOffset;
uint elementSize = operations[that->d()->type].bytesPerElement;
if (dbyteOffset < 0 || (byteOffset % elementSize) || dbyteOffset > buffer->byteLength())
- return scope.engine->currentContext()->throwRangeError(QStringLiteral("new TypedArray: invalid byteOffset"));
+ return scope.engine->throwRangeError(QStringLiteral("new TypedArray: invalid byteOffset"));
uint byteLength;
if (callData->argc < 3 || callData->args[2].isUndefined()) {
byteLength = buffer->byteLength() - byteOffset;
if (buffer->byteLength() < byteOffset || byteLength % elementSize)
- return scope.engine->currentContext()->throwRangeError(QStringLiteral("new TypedArray: invalid length"));
+ return scope.engine->throwRangeError(QStringLiteral("new TypedArray: invalid length"));
} else {
double l = qBound(0., callData->args[2].toInteger(), (double)UINT_MAX);
if (scope.engine->hasException)
return Encode::undefined();
l *= elementSize;
if (buffer->byteLength() - byteOffset < l)
- return scope.engine->currentContext()->throwRangeError(QStringLiteral("new TypedArray: invalid length"));
+ return scope.engine->throwRangeError(QStringLiteral("new TypedArray: invalid length"));
byteLength = (uint)l;
}
@@ -300,7 +300,7 @@ ReturnedValue TypedArrayCtor::construct(Managed *m, CallData *callData)
ScopedObject o(scope, callData->argument(0));
uint l = (uint) qBound(0., ScopedValue(scope, o->get(scope.engine->id_length))->toInteger(), (double)UINT_MAX);
if (scope.engine->hasException)
- return scope.engine->currentContext()->throwTypeError();
+ return scope.engine->throwTypeError();
uint elementSize = operations[that->d()->type].bytesPerElement;
Scoped<ArrayBuffer> newBuffer(scope, scope.engine->memoryManager->alloc<ArrayBuffer>(scope.engine, l * elementSize));
@@ -379,7 +379,7 @@ void TypedArray::putIndexed(Managed *m, uint index, const ValueRef value)
reject:
if (scope.engine->currentContext()->d()->strictMode)
- scope.engine->currentContext()->throwTypeError();
+ scope.engine->throwTypeError();
}
void TypedArrayPrototype::init(ExecutionEngine *engine, TypedArrayCtor *ctor)
@@ -405,7 +405,7 @@ ReturnedValue TypedArrayPrototype::method_get_buffer(CallContext *ctx)
Scope scope(ctx);
Scoped<TypedArray> v(scope, ctx->d()->callData->thisObject);
if (!v)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
return Encode(v->d()->buffer->asReturnedValue());
}
@@ -415,7 +415,7 @@ ReturnedValue TypedArrayPrototype::method_get_byteLength(CallContext *ctx)
Scope scope(ctx);
Scoped<TypedArray> v(scope, ctx->d()->callData->thisObject);
if (!v)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
return Encode(v->d()->byteLength);
}
@@ -425,7 +425,7 @@ ReturnedValue TypedArrayPrototype::method_get_byteOffset(CallContext *ctx)
Scope scope(ctx);
Scoped<TypedArray> v(scope, ctx->d()->callData->thisObject);
if (!v)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
return Encode(v->d()->byteOffset);
}
@@ -435,7 +435,7 @@ ReturnedValue TypedArrayPrototype::method_get_length(CallContext *ctx)
Scope scope(ctx);
Scoped<TypedArray> v(scope, ctx->d()->callData->thisObject);
if (!v)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
return Encode(v->d()->byteLength/v->d()->type->bytesPerElement);
}
@@ -445,17 +445,17 @@ ReturnedValue TypedArrayPrototype::method_set(CallContext *ctx)
Scope scope(ctx);
Scoped<TypedArray> a(scope, ctx->d()->callData->thisObject);
if (!a)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
Scoped<ArrayBuffer> buffer(scope, a->d()->buffer);
if (!buffer)
- ctx->throwTypeError();
+ scope.engine->throwTypeError();
double doffset = ctx->d()->callData->argc >= 2 ? ctx->d()->callData->args[1].toInteger() : 0;
if (scope.engine->hasException)
return Encode::undefined();
if (doffset < 0 || doffset >= UINT_MAX)
- return ctx->throwRangeError(QStringLiteral("TypedArray.set: out of range"));
+ return scope.engine->throwRangeError(QStringLiteral("TypedArray.set: out of range"));
uint offset = (uint)doffset;
uint elementSize = a->d()->type->bytesPerElement;
@@ -464,15 +464,15 @@ ReturnedValue TypedArrayPrototype::method_set(CallContext *ctx)
// src is a regular object
ScopedObject o(scope, ctx->d()->callData->args[0].toObject(ctx));
if (scope.engine->hasException || !o)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
double len = ScopedValue(scope, o->get(scope.engine->id_length))->toNumber();
uint l = (uint)len;
if (scope.engine->hasException || l != len)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
if (offset + l > a->length())
- return ctx->throwRangeError(QStringLiteral("TypedArray.set: out of range"));
+ return scope.engine->throwRangeError(QStringLiteral("TypedArray.set: out of range"));
uint idx = 0;
char *b = buffer->d()->data->data() + a->d()->byteOffset + offset*elementSize;
@@ -491,11 +491,11 @@ ReturnedValue TypedArrayPrototype::method_set(CallContext *ctx)
// src is a typed array
Scoped<ArrayBuffer> srcBuffer(scope, srcTypedArray->d()->buffer);
if (!srcBuffer)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
uint l = srcTypedArray->length();
if (offset + l > a->length())
- return ctx->throwRangeError(QStringLiteral("TypedArray.set: out of range"));
+ return scope.engine->throwRangeError(QStringLiteral("TypedArray.set: out of range"));
char *dest = buffer->d()->data->data() + a->d()->byteOffset + offset*elementSize;
const char *src = srcBuffer->d()->data->data() + srcTypedArray->d()->byteOffset;
@@ -535,11 +535,11 @@ ReturnedValue TypedArrayPrototype::method_subarray(CallContext *ctx)
Scoped<TypedArray> a(scope, ctx->d()->callData->thisObject);
if (!a)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
Scoped<ArrayBuffer> buffer(scope, a->d()->buffer);
if (!buffer)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
int len = a->length();
double b = ctx->d()->callData->argc > 0 ? ctx->d()->callData->args[0].toInteger() : 0;
@@ -561,7 +561,7 @@ ReturnedValue TypedArrayPrototype::method_subarray(CallContext *ctx)
Scoped<FunctionObject> constructor(scope, a->get(scope.engine->id_constructor));
if (!constructor)
- return ctx->throwTypeError();
+ return scope.engine->throwTypeError();
ScopedCallData callData(scope, 3);
callData->args[0] = buffer;
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 63a43966b1..bcb49b30ab 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1416,7 +1416,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_get_object(QV4::CallContext *ctx)
QV4::Scope scope(ctx);
QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>());
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return QV4::QObjectWrapper::wrap(ctx->d()->engine, o->d()->incubator->object());
}
@@ -1426,7 +1426,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_forceCompletion(QV4::CallContext *
QV4::Scope scope(ctx);
QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>());
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
o->d()->incubator->forceCompletion();
@@ -1438,7 +1438,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_get_status(QV4::CallContext *ctx)
QV4::Scope scope(ctx);
QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>());
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return QV4::Encode(o->d()->incubator->status());
}
@@ -1448,7 +1448,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_get_statusChanged(QV4::CallContext
QV4::Scope scope(ctx);
QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>());
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return o->d()->statusChanged.asReturnedValue();
}
@@ -1458,7 +1458,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_set_statusChanged(QV4::CallContext
QV4::Scope scope(ctx);
QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>());
if (!o || ctx->d()->callData->argc < 1)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
o->d()->statusChanged = ctx->d()->callData->args[0];
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index 0816bc05df..f18f6fa5ea 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -291,7 +291,7 @@ void QmlContextWrapper::put(Managed *m, String *name, const ValueRef value)
QString error = QLatin1String("Invalid write to global property \"") + name->toQString() +
QLatin1Char('"');
Scoped<String> e(scope, v4->currentContext()->d()->engine->newString(error));
- v4->currentContext()->throwError(e);
+ v4->throwError(e);
return;
}
@@ -335,7 +335,7 @@ void QmlContextWrapper::put(Managed *m, String *name, const ValueRef value)
if (wrapper->d()->readOnly) {
QString error = QLatin1String("Invalid write to global property \"") + name->toQString() +
QLatin1Char('"');
- v4->currentContext()->throwError(error);
+ v4->throwError(error);
return;
}
diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h
index a29b86fbea..a3fc8e4ed4 100644
--- a/src/qml/qml/qqmllocale_p.h
+++ b/src/qml/qml/qqmllocale_p.h
@@ -137,7 +137,7 @@ struct QQmlLocaleData : public QV4::Object
QV4::Object *o = ctx->d()->callData->thisObject.asObject();
QQmlLocaleData *thisObject = o ? o->as<QQmlLocaleData>() : 0;
if (!thisObject) {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return 0;
}
return &thisObject->d()->locale;
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index d8f282c030..ddd934c840 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -262,7 +262,7 @@ void QmlTypeWrapper::put(Managed *m, String *name, const ValueRef value)
QV4::ScopedObject apiprivate(scope, QJSValuePrivate::get(siinfo->scriptApi(e))->value);
if (!apiprivate) {
QString error = QLatin1String("Cannot assign to read-only property \"") + name->toQString() + QLatin1Char('\"');
- v4->currentContext()->throwError(error);
+ v4->throwError(error);
return;
} else {
apiprivate->put(name, value);
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 8123a297fe..7de15eac7d 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -242,10 +242,10 @@ ReturnedValue QmlValueTypeWrapper::method_toString(CallContext *ctx)
{
Object *o = ctx->d()->callData->thisObject.asObject();
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
QmlValueTypeWrapper *w = o->as<QmlValueTypeWrapper>();
if (!w)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (w->d()->objectType == QmlValueTypeWrapper::Reference) {
QmlValueTypeReference *reference = static_cast<QmlValueTypeReference *>(w);
@@ -355,7 +355,7 @@ void QmlValueTypeWrapper::put(Managed *m, String *name, const ValueRef value)
// assigning a JS function to a non-var-property is not allowed.
QString error = QLatin1String("Cannot assign JavaScript function to value-type property");
Scoped<String> e(scope, r->d()->v8->toString(error));
- v4->currentContext()->throwError(e);
+ v4->throwError(e);
return;
}
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 9e0a1872be..e5c9ee7549 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -66,7 +66,7 @@ using namespace QV4;
#define V4THROW_REFERENCE(string) { \
Scoped<Object> error(scope, ctx->engine()->newReferenceErrorObject(QStringLiteral(string))); \
- return ctx->throwError(error); \
+ return ctx->engine()->throwError(error); \
}
QT_BEGIN_NAMESPACE
@@ -421,7 +421,7 @@ ReturnedValue NodePrototype::method_get_nodeName(CallContext *ctx)
Scope scope(ctx);
Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
QString name;
switch (r->d()->d->type) {
@@ -446,7 +446,7 @@ ReturnedValue NodePrototype::method_get_nodeValue(CallContext *ctx)
Scope scope(ctx);
Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (r->d()->d->type == NodeImpl::Document ||
r->d()->d->type == NodeImpl::DocumentFragment ||
@@ -465,7 +465,7 @@ ReturnedValue NodePrototype::method_get_nodeType(CallContext *ctx)
Scope scope(ctx);
Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return Encode(r->d()->d->type);
}
@@ -475,7 +475,7 @@ ReturnedValue NodePrototype::method_get_parentNode(CallContext *ctx)
Scope scope(ctx);
Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
QV8Engine *engine = ctx->d()->engine->v8Engine;
@@ -490,7 +490,7 @@ ReturnedValue NodePrototype::method_get_childNodes(CallContext *ctx)
Scope scope(ctx);
Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
QV8Engine *engine = ctx->d()->engine->v8Engine;
@@ -502,7 +502,7 @@ ReturnedValue NodePrototype::method_get_firstChild(CallContext *ctx)
Scope scope(ctx);
Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
QV8Engine *engine = ctx->d()->engine->v8Engine;
@@ -517,7 +517,7 @@ ReturnedValue NodePrototype::method_get_lastChild(CallContext *ctx)
Scope scope(ctx);
Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
QV8Engine *engine = ctx->d()->engine->v8Engine;
@@ -532,7 +532,7 @@ ReturnedValue NodePrototype::method_get_previousSibling(CallContext *ctx)
Scope scope(ctx);
Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
QV8Engine *engine = ctx->d()->engine->v8Engine;
@@ -556,7 +556,7 @@ ReturnedValue NodePrototype::method_get_nextSibling(CallContext *ctx)
Scope scope(ctx);
Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
QV8Engine *engine = ctx->d()->engine->v8Engine;
@@ -580,7 +580,7 @@ ReturnedValue NodePrototype::method_get_attributes(CallContext *ctx)
Scope scope(ctx);
Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
QV8Engine *engine = ctx->d()->engine->v8Engine;
@@ -900,7 +900,7 @@ ReturnedValue NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty
if (!r) {
if (hasProperty)
*hasProperty = false;
- return v4->currentContext()->throwTypeError();
+ return v4->throwTypeError();
}
QV8Engine *engine = v4->v8Engine;
@@ -1534,14 +1534,14 @@ void QQmlXMLHttpRequest::dispatchCallbackImpl(const ValueRef me)
QV4::Scope scope(v4);
Scoped<Object> o(scope, me);
if (!o) {
- ctx->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject"));
+ ctx->engine()->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject"));
return;
}
ScopedString s(scope, v4->newString(QStringLiteral("ThisObject")));
Scoped<Object> thisObj(scope, o->get(s.getPointer()));
if (!thisObj) {
- ctx->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject"));
+ ctx->engine()->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject"));
return;
}
@@ -1555,7 +1555,7 @@ void QQmlXMLHttpRequest::dispatchCallbackImpl(const ValueRef me)
s = v4->newString(QStringLiteral("ActivationObject"));
Scoped<Object> activationObject(scope, o->get(s.getPointer()));
if (!activationObject) {
- v4->currentContext()->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ActivationObject"));
+ v4->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ActivationObject"));
return;
}
@@ -1650,7 +1650,7 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject
Scope scope(that->engine());
Scoped<QQmlXMLHttpRequestCtor> ctor(scope, that->as<QQmlXMLHttpRequestCtor>());
if (!ctor)
- return that->engine()->currentContext()->throwTypeError();
+ return that->engine()->throwTypeError();
QV8Engine *engine = that->engine()->v8Engine;
QQmlXMLHttpRequest *r = new QQmlXMLHttpRequest(engine, engine->networkAccessManager());
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index f222d59494..b2cf29b67d 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -1004,7 +1004,7 @@ ReturnedValue QtObject::method_createQmlObject(CallContext *ctx)
if (component.isError()) {
ScopedValue v(scope, Error::create(ctx->d()->engine, component.errors()));
- return ctx->throwError(v);
+ return ctx->engine()->throwError(v);
}
if (!component.isReady())
@@ -1028,7 +1028,7 @@ ReturnedValue QtObject::method_createQmlObject(CallContext *ctx)
if (component.isError()) {
ScopedValue v(scope, Error::create(ctx->d()->engine, component.errors()));
- return ctx->throwError(v);
+ return ctx->engine()->throwError(v);
}
Q_ASSERT(obj);
@@ -1070,7 +1070,7 @@ use \l{QtQml::Qt::createQmlObject()}{Qt.createQmlObject()}.
ReturnedValue QtObject::method_createComponent(CallContext *ctx)
{
if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 3)
- return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments"));
+ return ctx->engine()->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments"));
Scope scope(ctx);
@@ -1098,13 +1098,13 @@ ReturnedValue QtObject::method_createComponent(CallContext *ctx)
if (ctx->d()->callData->args[1].isInteger()) {
int mode = ctx->d()->callData->args[1].integerValue();
if (mode != int(QQmlComponent::PreferSynchronous) && mode != int(QQmlComponent::Asynchronous))
- return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments"));
+ return ctx->engine()->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments"));
compileMode = QQmlComponent::CompilationMode(mode);
consumedCount += 1;
} else {
// The second argument could be the parent only if there are exactly two args
if ((ctx->d()->callData->argc != 2) || !(lastArg->isObject() || lastArg->isNull()))
- return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments"));
+ return ctx->engine()->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments"));
}
if (consumedCount < ctx->d()->callData->argc) {
@@ -1113,11 +1113,11 @@ ReturnedValue QtObject::method_createComponent(CallContext *ctx)
if (qobjectWrapper)
parentArg = qobjectWrapper->object();
if (!parentArg)
- return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid parent object"));
+ return ctx->engine()->throwError(QStringLiteral("Qt.createComponent(): Invalid parent object"));
} else if (lastArg->isNull()) {
parentArg = 0;
} else {
- return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid parent object"));
+ return ctx->engine()->throwError(QStringLiteral("Qt.createComponent(): Invalid parent object"));
}
}
}
@@ -1257,10 +1257,10 @@ ReturnedValue QtObject::method_get_platform(CallContext *ctx)
// ### inefficient. Should be just a value based getter
Object *o = ctx->d()->callData->thisObject.asObject();
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
QtObject *qt = o->as<QtObject>();
if (!qt)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (!qt->d()->platform)
// Only allocate a platform object once
@@ -1274,10 +1274,10 @@ ReturnedValue QtObject::method_get_application(CallContext *ctx)
// ### inefficient. Should be just a value based getter
Object *o = ctx->d()->callData->thisObject.asObject();
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
QtObject *qt = o->as<QtObject>();
if (!qt)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (!qt->d()->application)
// Only allocate an application object once
diff --git a/src/qml/qml/v8/qv4domerrors_p.h b/src/qml/qml/v8/qv4domerrors_p.h
index 59ed744f5e..facf7972ad 100644
--- a/src/qml/qml/v8/qv4domerrors_p.h
+++ b/src/qml/qml/v8/qv4domerrors_p.h
@@ -72,7 +72,7 @@ QT_BEGIN_NAMESPACE
QV4::ScopedValue v(scope, scope.engine->newString(QStringLiteral(string))); \
QV4::Scoped<Object> ex(scope, scope.engine->newErrorObject(v)); \
ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(error))); \
- return ctx->throwError(ex); \
+ return ctx->engine()->throwError(ex); \
}
namespace QV4 {
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index 51e857c8a2..2379689fb3 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -78,10 +78,10 @@ namespace QV4 {
// #define QML_GLOBAL_HANDLE_DEBUGGING
#define V4THROW_ERROR(string) \
- return ctx->throwError(QString::fromUtf8(string));
+ return ctx->engine()->throwError(QString::fromUtf8(string));
#define V4THROW_TYPE(string) \
- return ctx->throwTypeError(QStringLiteral(string));
+ return ctx->engine()->throwTypeError(QStringLiteral(string));
#define V8_DEFINE_EXTENSION(dataclass, datafunction) \
static inline dataclass *datafunction(QV8Engine *engine) \
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index fee1392c44..e150545926 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -75,7 +75,7 @@ struct DelegateModelGroupFunction: QV4::FunctionObject
static QV4::ReturnedValue construct(QV4::Managed *m, QV4::CallData *)
{
- return m->engine()->currentContext()->throwTypeError();
+ return m->engine()->throwTypeError();
}
static QV4::ReturnedValue call(QV4::Managed *that, QV4::CallData *callData)
@@ -85,7 +85,7 @@ struct DelegateModelGroupFunction: QV4::FunctionObject
QV4::Scoped<DelegateModelGroupFunction> f(scope, that, QV4::Scoped<DelegateModelGroupFunction>::Cast);
QV4::Scoped<QQmlDelegateModelItemObject> o(scope, callData->thisObject);
if (!o)
- return v4->currentContext()->throwTypeError(QStringLiteral("Not a valid VisualData object"));
+ return v4->throwTypeError(QStringLiteral("Not a valid VisualData object"));
QV4::ScopedValue v(scope, callData->argument(0));
return f->d()->code(o->d()->item, f->d()->flag, v);
@@ -1781,7 +1781,7 @@ QV4::ReturnedValue QQmlDelegateModelItem::get_model(QV4::CallContext *ctx)
QV4::Scope scope(ctx);
QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
- return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
+ return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object"));
if (!o->d()->item->metaType->model)
return QV4::Encode::undefined();
@@ -1793,7 +1793,7 @@ QV4::ReturnedValue QQmlDelegateModelItem::get_groups(QV4::CallContext *ctx)
QV4::Scope scope(ctx);
QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
- return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
+ return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object"));
QStringList groups;
for (int i = 1; i < o->d()->item->metaType->groupCount; ++i) {
@@ -1809,9 +1809,9 @@ QV4::ReturnedValue QQmlDelegateModelItem::set_groups(QV4::CallContext *ctx)
QV4::Scope scope(ctx);
QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
- return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
+ return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object"));
if (!ctx->d()->callData->argc)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (!o->d()->item->metaType->model)
return QV4::Encode::undefined();
@@ -3229,21 +3229,21 @@ struct QQmlDelegateModelGroupChange : QV4::Object
QV4::Scope scope(ctx);
QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelGroupChange>());
if (!that)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return QV4::Encode(that->d()->change.index);
}
static QV4::ReturnedValue method_get_count(QV4::CallContext *ctx) {
QV4::Scope scope(ctx);
QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelGroupChange>());
if (!that)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return QV4::Encode(that->d()->change.count);
}
static QV4::ReturnedValue method_get_moveId(QV4::CallContext *ctx) {
QV4::Scope scope(ctx);
QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelGroupChange>());
if (!that)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (that->d()->change.moveId < 0)
return QV4::Encode::undefined();
return QV4::Encode(that->d()->change.moveId);
diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp
index b147f56bfa..943947f577 100644
--- a/src/qml/util/qqmladaptormodel.cpp
+++ b/src/qml/util/qqmladaptormodel.cpp
@@ -60,7 +60,7 @@ static QV4::ReturnedValue get_index(QV4::CallContext *ctx)
QV4::Scope scope(ctx);
QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
- return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
+ return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object"));
return QV4::Encode(o->d()->item->index);
}
@@ -192,7 +192,7 @@ public:
QV4::Scope scope(ctx);
QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
- return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
+ return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object"));
const QQmlAdaptorModel *const model = static_cast<QQmlDMCachedModelData *>(o->d()->item)->type->model;
if (o->d()->item->index >= 0 && *model) {
@@ -339,7 +339,7 @@ QV4::ReturnedValue QQmlDMCachedModelData::get_property(QV4::CallContext *ctx, ui
QV4::Scope scope(ctx);
QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
- return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
+ return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object"));
QQmlDMCachedModelData *modelData = static_cast<QQmlDMCachedModelData *>(o->d()->item);
if (o->d()->item->index == -1) {
@@ -359,9 +359,9 @@ QV4::ReturnedValue QQmlDMCachedModelData::set_property(QV4::CallContext *ctx, ui
QV4::Scope scope(ctx);
QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
- return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
+ return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object"));
if (!ctx->d()->callData->argc)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (o->d()->item->index == -1) {
QQmlDMCachedModelData *modelData = static_cast<QQmlDMCachedModelData *>(o->d()->item);
@@ -581,7 +581,7 @@ public:
QV4::Scope scope(ctx);
QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
- return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
+ return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object"));
return scope.engine->v8Engine->fromVariant(static_cast<QQmlDMListAccessorData *>(o->d()->item)->cachedData);
}
@@ -591,9 +591,9 @@ public:
QV4::Scope scope(ctx);
QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
- return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
+ return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object"));
if (!ctx->d()->callData->argc)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
static_cast<QQmlDMListAccessorData *>(o->d()->item)->setModelData(scope.engine->v8Engine->toVariant(ctx->d()->callData->args[0], QVariant::Invalid));
return QV4::Encode::undefined();
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 0101e0edf4..25ac68150d 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -1301,7 +1301,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_globalCompositeOperation(QV4::C
CHECK_CONTEXT_SETTER(r)
if (!ctx->d()->callData->argc)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
QString mode = ctx->d()->callData->args[0].toQString();
QPainter::CompositionMode cm = qt_composite_mode_from_string(mode);
@@ -1853,7 +1853,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_lineJoin(QV4::CallContext *ctx)
CHECK_CONTEXT_SETTER(r)
if (!ctx->d()->callData->argc)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
QString lineJoin = ctx->d()->callData->args[0].toQString();
Qt::PenJoinStyle join;
@@ -3027,7 +3027,7 @@ QV4::ReturnedValue QQuickJSContext2DImageData::method_get_width(QV4::CallContext
QV4::Scope scope(ctx);
QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, ctx->d()->callData->thisObject);
if (!imageData)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
QV4::Scoped<QQuickJSContext2DPixelData> r(scope, imageData->d()->pixelData.as<QQuickJSContext2DPixelData>());
if (!r)
return QV4::Encode(0);
@@ -3043,7 +3043,7 @@ QV4::ReturnedValue QQuickJSContext2DImageData::method_get_height(QV4::CallContex
QV4::Scope scope(ctx);
QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, ctx->d()->callData->thisObject);
if (!imageData)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
QV4::Scoped<QQuickJSContext2DPixelData> r(scope, imageData->d()->pixelData.as<QQuickJSContext2DPixelData>());
if (!r)
return QV4::Encode(0);
@@ -3059,7 +3059,7 @@ QV4::ReturnedValue QQuickJSContext2DImageData::method_get_data(QV4::CallContext
QV4::Scope scope(ctx);
QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, ctx->d()->callData->thisObject);
if (!imageData)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return imageData->d()->pixelData.asReturnedValue();
}
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp
index f50c356c5d..545e63883e 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.cpp
+++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp
@@ -136,7 +136,7 @@ public:
void MyQmlObject::v8function(QQmlV4Function *function)
{
- QV8Engine::getV4(function->engine())->currentContext()->throwError(QStringLiteral("Exception thrown from within QObject slot"));
+ QV8Engine::getV4(function->engine())->throwError(QStringLiteral("Exception thrown from within QObject slot"));
}
static QJSValue script_api(QQmlEngine *engine, QJSEngine *scriptEngine)