aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4numberobject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jsruntime/qv4numberobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4numberobject.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp
index 8a09de5349..dd13f493f7 100644
--- a/src/qml/jsruntime/qv4numberobject.cpp
+++ b/src/qml/jsruntime/qv4numberobject.cpp
@@ -107,7 +107,7 @@ inline ReturnedValue thisNumberValue(ExecutionContext *ctx)
return ctx->callData->thisObject.asReturnedValue();
NumberObject *n = ctx->callData->thisObject.asNumberObject();
if (!n)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
return n->value.asReturnedValue();
}
@@ -117,21 +117,21 @@ inline double thisNumber(ExecutionContext *ctx)
return ctx->callData->thisObject.asDouble();
NumberObject *n = ctx->callData->thisObject.asNumberObject();
if (!n)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
return n->value.asDouble();
}
ReturnedValue NumberPrototype::method_toString(SimpleCallContext *ctx)
{
double num = thisNumber(ctx);
+ if (ctx->engine->hasException)
+ return Encode::undefined();
if (ctx->callData->argc && !ctx->callData->args[0].isUndefined()) {
int radix = ctx->callData->args[0].toInt32();
- if (radix < 2 || radix > 36) {
- ctx->throwError(QString::fromLatin1("Number.prototype.toString: %0 is not a valid radix")
+ if (radix < 2 || radix > 36)
+ return ctx->throwError(QString::fromLatin1("Number.prototype.toString: %0 is not a valid radix")
.arg(radix));
- return Encode::undefined();
- }
if (std::isnan(num)) {
return ctx->engine->newString(QStringLiteral("NaN"))->asReturnedValue();
@@ -177,6 +177,8 @@ ReturnedValue NumberPrototype::method_toLocaleString(SimpleCallContext *ctx)
{
Scope scope(ctx);
ScopedValue v(scope, thisNumberValue(ctx));
+ if (ctx->engine->hasException)
+ return Encode::undefined();
ScopedString str(scope, v->toString(ctx));
return str.asReturnedValue();
@@ -190,6 +192,8 @@ ReturnedValue NumberPrototype::method_valueOf(SimpleCallContext *ctx)
ReturnedValue NumberPrototype::method_toFixed(SimpleCallContext *ctx)
{
double v = thisNumber(ctx);
+ if (ctx->engine->hasException)
+ return Encode::undefined();
double fdigits = 0;
@@ -200,7 +204,7 @@ ReturnedValue NumberPrototype::method_toFixed(SimpleCallContext *ctx)
fdigits = 0;
if (fdigits < 0 || fdigits > 20)
- ctx->throwRangeError(ctx->callData->thisObject);
+ return ctx->throwRangeError(ctx->callData->thisObject);
QString str;
if (std::isnan(v))
@@ -218,6 +222,8 @@ ReturnedValue NumberPrototype::method_toExponential(SimpleCallContext *ctx)
{
Scope scope(ctx);
double d = thisNumber(ctx);
+ if (ctx->engine->hasException)
+ return Encode::undefined();
int fdigits = -1;
@@ -225,7 +231,7 @@ ReturnedValue NumberPrototype::method_toExponential(SimpleCallContext *ctx)
int fdigits = ctx->callData->args[0].toInt32();
if (fdigits < 0 || fdigits > 20) {
ScopedString error(scope, ctx->engine->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range")));
- ctx->throwRangeError(error);
+ return ctx->throwRangeError(error);
}
}
@@ -241,6 +247,8 @@ ReturnedValue NumberPrototype::method_toPrecision(SimpleCallContext *ctx)
{
Scope scope(ctx);
ScopedValue v(scope, thisNumberValue(ctx));
+ if (ctx->engine->hasException)
+ return Encode::undefined();
if (!ctx->callData->argc || ctx->callData->args[0].isUndefined())
return __qmljs_to_string(v, ctx);
@@ -248,7 +256,7 @@ ReturnedValue NumberPrototype::method_toPrecision(SimpleCallContext *ctx)
double precision = ctx->callData->args[0].toInt32();
if (precision < 1 || precision > 21) {
ScopedString error(scope, ctx->engine->newString(QStringLiteral("Number.prototype.toPrecision: precision out of range")));
- ctx->throwRangeError(error);
+ return ctx->throwRangeError(error);
}
char str[100];