diff options
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 72 |
1 files changed, 15 insertions, 57 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 8faf2a74b6..55baef06db 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -443,16 +443,8 @@ ReturnedValue ScriptFunction::construct(Managed *that, CallData *callData) callData->thisObject = obj.asReturnedValue(); ExecutionContext *ctx = context->newCallContext(f.getPointer(), callData); - ScopedValue result(scope); - SAVE_JS_STACK(f->scope); - try { - result = f->function->code(ctx, f->function->codeData); - } catch (...) { - context->rethrowException(); - } - CHECK_JS_STACK(f->scope); - ctx->engine->popContext(); - + ExecutionContextSaver ctxSaver(context); + ScopedValue result(scope, f->function->code(ctx, f->function->codeData)); if (result->isObject()) return result.asReturnedValue(); return obj.asReturnedValue(); @@ -474,16 +466,8 @@ ReturnedValue ScriptFunction::call(Managed *that, CallData *callData) } } - ScopedValue result(scope); - SAVE_JS_STACK(f->scope); - try { - result = f->function->code(ctx, f->function->codeData); - } catch (...) { - context->rethrowException(); - } - CHECK_JS_STACK(f->scope); - ctx->engine->popContext(); - return result.asReturnedValue(); + ExecutionContextSaver ctxSaver(context); + return f->function->code(ctx, f->function->codeData); } DEFINE_MANAGED_VTABLE(SimpleScriptFunction); @@ -540,16 +524,12 @@ ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData) callData->thisObject = obj; ExecutionContext *ctx = context->newCallContext(stackSpace, scope.alloc(f->varCount), f.getPointer(), callData); - try { - Scoped<Object> result(scope, f->function->code(ctx, f->function->codeData)); - ctx->engine->popContext(); + ExecutionContextSaver ctxSaver(context); + Scoped<Object> result(scope, f->function->code(ctx, f->function->codeData)); - if (!result) - return obj.asReturnedValue(); - return result.asReturnedValue(); - } catch (...) { - context->rethrowException(); - } + if (!result) + return obj.asReturnedValue(); + return result.asReturnedValue(); } ReturnedValue SimpleScriptFunction::call(Managed *that, CallData *callData) @@ -570,16 +550,8 @@ ReturnedValue SimpleScriptFunction::call(Managed *that, CallData *callData) } } - ScopedValue result(scope); - SAVE_JS_STACK(f->scope); - try { - result = f->function->code(ctx, f->function->codeData); - } catch (...) { - context->rethrowException(); - } - CHECK_JS_STACK(f->scope); - ctx->engine->popContext(); - return result.asReturnedValue(); + ExecutionContextSaver ctxSaver(context); + return f->function->code(ctx, f->function->codeData); } @@ -613,15 +585,8 @@ ReturnedValue BuiltinFunction::call(Managed *that, CallData *callData) ctx.callData = callData; v4->pushContext(&ctx); - ScopedValue result(scope); - try { - result = f->code(&ctx); - } catch (...) { - context->rethrowException(); - } - - context->engine->popContext(); - return result.asReturnedValue(); + ExecutionContextSaver ctxSaver(context); + return f->code(&ctx); } ReturnedValue IndexedBuiltinFunction::call(Managed *that, CallData *callData) @@ -637,15 +602,8 @@ ReturnedValue IndexedBuiltinFunction::call(Managed *that, CallData *callData) ctx.callData = callData; v4->pushContext(&ctx); - ScopedValue result(scope); - try { - result = f->code(&ctx, f->index); - } catch (...) { - context->rethrowException(); - } - - context->engine->popContext(); - return result.asReturnedValue(); + ExecutionContextSaver ctxSaver(context); + return f->code(&ctx, f->index); } DEFINE_MANAGED_VTABLE(IndexedBuiltinFunction); |