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(); \
}
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(); \
}
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();
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();
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());
}
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());
}
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);\
}\
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)));\
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);\
}\
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(); \
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);\
}\
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(); \
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 ());\
}\
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(); \
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)
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
}
if (ctx->d()->strictMode && !result)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return result;
}
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());
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();
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)
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;
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);
}
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()) ?
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);
return;
if (!(comparefn->isUndefined() || comparefn->asObject())) {
- context->throwTypeError();
+ context->engine()->throwTypeError();
return;
}
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);
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);
}
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
ScopedCallData callData(scope, 3);
callData->args[2] = instance;
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);
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);
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);
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);
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
uint k = 0;
ScopedValue acc(scope);
++k;
}
if (!kPresent)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
}
ScopedCallData callData(scope, 4);
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);
}
--k;
}
if (!kPresent)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
}
ScopedCallData callData(scope, 4);
Scope scope(ctx);
Scoped<BooleanObject> thisObject(scope, ctx->d()->callData->thisObject);
if (!thisObject)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
result = thisObject->value().booleanValue();
}
Scope scope(ctx);
Scoped<BooleanObject> thisObject(scope, ctx->d()->callData->thisObject);
if (!thisObject)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return thisObject->value().asReturnedValue();
}
}
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;
}
}
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);
}
}
ScopedValue n(scope, name);
- return throwReferenceError(n);
+ return engine()->throwReferenceError(n);
}
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);
-}
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);
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;
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;
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());
}
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);
}
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);
}
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]);
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();
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();
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;
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;
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();
if (DateObject *thisObject = ctx->d()->callData->thisObject.asDateObject())
return thisObject->date().asDouble();
else {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return 0;
}
}
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));
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();
{
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();
{
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();
{
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();
{
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();
{
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();
{
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();
{
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();
{
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();
{
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();
{
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();
{
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();
{
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))
{
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();
{
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))
{
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();
{
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);
FunctionObject *toIso = v->asFunctionObject();
if (!toIso)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
ScopedCallData callData(scope, 0);
callData->thisObject = ctx->d()->callData->thisObject;
static ReturnedValue throwTypeError(CallContext *ctx)
{
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
}
const int MinimumStackSize = 256; // in kbytes
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()
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.
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;
#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
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);
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) {
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;
ReturnedValue FunctionObject::construct(Managed *that, CallData *)
{
- that->internalClass()->engine->currentContext()->throwTypeError();
+ that->internalClass()->engine->throwTypeError();
return Encode::undefined();
}
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);
{
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();
}
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));
if (!arr) {
len = 0;
if (!arg->isNullOrUndefined())
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
} else {
len = arr->getLength();
}
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) {
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;
ReturnedValue BuiltinFunction::construct(Managed *f, CallData *)
{
- return f->internalClass()->engine->currentContext()->throwTypeError();
+ return f->internalClass()->engine->throwTypeError();
}
ReturnedValue BuiltinFunction::call(Managed *that, CallData *callData)
static ReturnedValue construct(Managed *m, CallData *)
{
- return m->engine()->currentContext()->throwTypeError();
+ return m->engine()->throwTypeError();
}
static ReturnedValue call(Managed *that, CallData *callData);
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();
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();
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();
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();
QString Stringify::JO(Object *o)
{
if (stack.contains(o)) {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return QString();
}
QString Stringify::JA(ArrayObject *a)
{
if (stack.contains(a)) {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return QString();
}
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();
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);
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;
}
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)
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();
}
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();
}
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)) {
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))
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);
}
}
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];
reject:
if (engine()->currentContext()->d()->strictMode)
- engine()->currentContext()->throwTypeError();
+ engine()->throwTypeError();
}
void Object::defineDefaultProperty(const QString &name, ValueRef value)
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)
bool ok;
uint l = value->asArrayLength(&ok);
if (!ok) {
- engine()->currentContext()->throwRangeError(value);
+ engine()->throwRangeError(value);
return;
}
ok = setArrayLength(l);
QString message = QStringLiteral("Cannot assign to read-only property \"");
message += name->toQString();
message += QLatin1Char('\"');
- engine()->currentContext()->throwTypeError(message);
+ engine()->throwTypeError(message);
}
}
reject:
if (engine()->currentContext()->d()->strictMode)
- engine()->currentContext()->throwTypeError();
+ engine()->throwTypeError();
}
// Section 8.12.7
return true;
}
if (engine()->currentContext()->d()->strictMode)
- engine()->currentContext()->throwTypeError();
+ engine()->throwTypeError();
return false;
}
return true;
if (engine()->currentContext()->d()->strictMode)
- engine()->currentContext()->throwTypeError();
+ engine()->throwTypeError();
return false;
}
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);
return __defineOwnProperty__(ctx, memberIndex, name, p, attrs);
reject:
if (ctx->d()->strictMode)
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return false;
}
return defineOwnProperty2(ctx, index, p, attrs);
reject:
if (ctx->d()->strictMode)
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return false;
}
return __defineOwnProperty__(ctx, index, 0, p, attrs);
reject:
if (ctx->d()->strictMode)
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return false;
}
return true;
reject:
if (ctx->d()->strictMode)
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return false;
}
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();
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();
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();
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());
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)
return Encode::undefined();
if (!O->__defineOwnProperty__(ctx, name.getPointer(), pd, attrs))
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return O.asReturnedValue();
}
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)
else
ok = O->__defineOwnProperty__(ctx, index, n, nattrs);
if (!ok)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
}
return O.asReturnedValue();
Scope scope(ctx);
Scoped<Object> o(scope, ctx->argument(0));
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
o->setExtensible(false);
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();
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();
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);
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);
Scope scope(ctx);
Scoped<Object> o(scope, ctx->argument(0));
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return Encode((bool)o->isExtensible());
}
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());
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);
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)
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)
Scope scope(ctx);
ScopedObject o(scope, ctx->d()->callData->thisObject.asObject());
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
return o->prototype()->asReturnedValue();
}
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);
}
}
if (!ok)
- return ctx->throwTypeError(QStringLiteral("Cyclic __proto__ value"));
+ return ctx->engine()->throwTypeError(QStringLiteral("Cyclic __proto__ value"));
return Encode::undefined();
}
Scope scope(ctx);
ScopedObject o(scope, v);
if (!o) {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return;
}
if (f || get->isUndefined()) {
desc->value = get;
} else {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return;
}
attrs->setType(PropertyAttributes::Accessor);
if (f || set->isUndefined()) {
desc->set = set;
} else {
- ctx->throwTypeError();
+ ctx->engine()->throwTypeError();
return;
}
attrs->setType(PropertyAttributes::Accessor);
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());
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);
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;
}
error += QLatin1String("[unknown property type]");
else
error += QLatin1String(QMetaType::typeName(property->propType));
- ctx->throwError(error);
+ ctx->engine()->throwError(error);
return;
}
} else {
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
QLatin1String(valueType) +
QLatin1String(" to ") +
QLatin1String(targetTypeName);
- ctx->throwError(error);
+ ctx->engine()->throwError(error);
return;
}
}
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);
}
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()) {
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);
candidate = RelatedMethod(object, candidate, dummy);
}
- return QV8Engine::getV4(engine)->currentContext()->throwError(error);
+ return QV8Engine::getV4(engine)->throwError(error);
}
}
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)
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()));
}
} 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));
}
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);
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();
}
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));
FunctionObject *f = right->asFunctionObject();
if (!f)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
if (f->subtype() == FunctionObject::BoundFunction)
f = static_cast<BoundFunction *>(f)->target();
Object *o = QV4::Value::fromReturnedValue(f->protoProperty()).asObject();
if (!o)
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
while (v) {
v = v->prototype();
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())
return r->asReturnedValue();
}
- return ctx->throwTypeError();
+ return ctx->engine()->throwTypeError();
}
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);
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);
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);
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);
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)) {
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));
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);
Value v;
v = l->getter(l, callData->thisObject);
if (!v.isObject())
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return v.objectValue()->call(callData);
}
ScopedObject o(scope, baseObject->get(s.getPointer()));
if (!o)
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return o->call(callData);
}
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);
}
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);
}
Object *f = func->asObject();
if (!f)
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return f->construct(callData);
}
{
Object *f = func->asObject();
if (!f)
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return f->construct(callData);
}
Scoped<Object> f(scope, thisObject->get(name));
if (!f)
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return f->construct(callData);
}
Value v;
v = l->getter(l, callData->thisObject);
if (!v.isObject())
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return v.objectValue()->construct(callData);
}
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)
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);
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);
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);
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
if (!vmFunction) {
// ### FIX file/line number
Scoped<Object> error(valueScope, v4->newSyntaxErrorObject(QStringLiteral("Syntax error")));
- v4->currentContext()->throwError(error);
+ v4->throwError(error);
}
}
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)
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. */
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();
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;
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();
StringObject *o = context->d()->callData->thisObject.asStringObject();
if (!o)
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
return o->d()->value.asReturnedValue();
}
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));
if (!rx)
// ### CHECK
- return context->throwTypeError();
+ return context->engine()->throwTypeError();
bool global = rx->global();
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)
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;
}
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));
reject:
if (scope.engine->currentContext()->d()->strictMode)
- scope.engine->currentContext()->throwTypeError();
+ scope.engine->throwTypeError();
}
void TypedArrayPrototype::init(ExecutionEngine *engine, TypedArrayCtor *ctor)
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());
}
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);
}
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);
}
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);
}
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;
// 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;
// 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;
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;
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;
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());
}
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();
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());
}
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();
}
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];
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;
}
if (wrapper->d()->readOnly) {
QString error = QLatin1String("Invalid write to global property \"") + name->toQString() +
QLatin1Char('"');
- v4->currentContext()->throwError(error);
+ v4->throwError(error);
return;
}
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;
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);
{
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);
// 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;
}
#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
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) {
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 ||
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);
}
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;
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;
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;
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;
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;
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;
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;
if (!r) {
if (hasProperty)
*hasProperty = false;
- return v4->currentContext()->throwTypeError();
+ return v4->throwTypeError();
}
QV8Engine *engine = v4->v8Engine;
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;
}
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;
}
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());
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())
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);
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);
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) {
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"));
}
}
}
// ### 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
// ### 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
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 {
// #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) \
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)
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);
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();
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) {
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();
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);
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);
}
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) {
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) {
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);
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);
}
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();
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);
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;
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);
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);
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();
}
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)