aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4regexpobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-10-21 09:57:58 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-29 10:38:59 +0100
commitaf22149dd8daf593182fec978f15dc1667c9cf8d (patch)
tree17334ae83a3015fd6ca535fb9d2e97b40e1da825 /src/qml/jsruntime/qv4regexpobject.cpp
parent2b996ca17fbc36029af3900933b6fcc1418afb6a (diff)
Avoid side effects when en exception has been thrown.
We don't want to check for exceptions after every single line on our runtime methods. A better way to handle this is to add the check in all methods that have direct side effects (as e.g. writing to a property of the JS stack). We also need to return whereever we throw an exception. To simplify the code, ExecutionContext::throwXxx methods now return a ReturnedValue (always undefined) for convenience. Change-Id: Ide6c804f819c731a3f14c6c43121d08029c9fb90 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4regexpobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index 6eaa8c387d..8bcddcce0a 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -249,7 +249,7 @@ ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData)
Scoped<RegExpObject> re(scope, r);
if (re) {
if (!f->isUndefined())
- ctx->throwTypeError();
+ return ctx->throwTypeError();
Scoped<RegExp> newRe(scope, re->value);
return Encode(ctx->engine->newRegExpObject(newRe, re->global));
@@ -273,14 +273,14 @@ ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData)
} else if (str.at(i) == QChar('m') && !multiLine) {
multiLine = true;
} else {
- ctx->throwSyntaxError(0);
+ return ctx->throwSyntaxError(0);
}
}
}
Scoped<RegExp> regexp(scope, RegExp::create(ctx->engine, pattern, ignoreCase, multiLine));
if (!regexp->isValid())
- ctx->throwSyntaxError(0);
+ return ctx->throwSyntaxError(0);
return Encode(ctx->engine->newRegExpObject(regexp, global));
}
@@ -314,7 +314,7 @@ ReturnedValue RegExpPrototype::method_exec(SimpleCallContext *ctx)
Scope scope(ctx);
Scoped<RegExpObject> r(scope, ctx->callData->thisObject.as<RegExpObject>());
if (!r)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
ScopedValue arg(scope, ctx->argument(0));
arg = __qmljs_to_string(arg, ctx);
@@ -366,7 +366,7 @@ ReturnedValue RegExpPrototype::method_toString(SimpleCallContext *ctx)
Scope scope(ctx);
Scoped<RegExpObject> r(scope, ctx->callData->thisObject.as<RegExpObject>());
if (!r)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
return ctx->engine->newString(r->toString())->asReturnedValue();
}
@@ -376,7 +376,7 @@ ReturnedValue RegExpPrototype::method_compile(SimpleCallContext *ctx)
Scope scope(ctx);
Scoped<RegExpObject> r(scope, ctx->callData->thisObject.as<RegExpObject>());
if (!r)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
ScopedCallData callData(scope, ctx->callData->argc);
memcpy(callData->args, ctx->callData->args, ctx->callData->argc*sizeof(SafeValue));