diff options
author | Simon Hausmann <[email protected]> | 2013-10-01 16:19:28 +0200 |
---|---|---|
committer | The Qt Project <[email protected]> | 2013-10-03 09:24:41 +0200 |
commit | 7d9780b6308e15dcd4adcb65d7b516666c285f54 (patch) | |
tree | 94c598d4aba187293dace67011dbcaf8347ef8b7 /src/qml/jsruntime/qv4engine.cpp | |
parent | 8abf7f5876a48c0879bce628597533c7b6eca9a0 (diff) |
Cleanup exception handling
The code in the Exception class operates entirely on the engine's data,
so move it into ExecutionEngine instead. This eliminates the need for
a QV4::Exception class and catches and old code that tries to still do
catch (Exception &) instead of catch (...)
Change-Id: Ie608bec6af652038aca6c9423c225a4d7eb13b39
Reviewed-by: Lars Knoll <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index ba7241b081..41eb6fe5ec 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -67,7 +67,6 @@ #include "qv4qobjectwrapper_p.h" #include "qv4qmlextensions_p.h" #include "qv4stacktrace_p.h" -#include "qv4exception_p.h" #ifdef V4_ENABLE_JIT #include "qv4isel_masm_p.h" @@ -809,4 +808,62 @@ QmlExtensions *ExecutionEngine::qmlExtensions() return m_qmlExtensions; } +void ExecutionEngine::throwException(const ValueRef value) +{ + Q_ASSERT(!hasException); + hasException = true; + exceptionValue = value; + QV4::Scope scope(this); + QV4::Scoped<ErrorObject> error(scope, value); + if (!!error) + exceptionStackTrace = error->stackTrace; + else + exceptionStackTrace = stackTrace(); + + if (debugger) + debugger->aboutToThrow(value); + + UnwindHelper::prepareForUnwind(current); + throwInternal(); +} + +void ExecutionEngine::rethrowException(ExecutionContext *intermediateCatchingContext) +{ + if (hasException) { + while (current != intermediateCatchingContext) + popContext(); + } + rethrowInternal(); +} + +ReturnedValue ExecutionEngine::catchException(ExecutionContext *catchingContext, StackTrace *trace) +{ + if (!hasException) + rethrowInternal(); + while (current != catchingContext) + popContext(); + if (trace) + *trace = exceptionStackTrace; + exceptionStackTrace.clear(); + hasException = false; + ReturnedValue res = exceptionValue.asReturnedValue(); + exceptionValue = Encode::undefined(); + return res; +} + +#if !defined(V4_CXX_ABI_EXCEPTION) +struct DummyException +{}; + +void ExecutionEngine::throwInternal() +{ + throw DummyException(); +} + +void ExecutionEngine::rethrowInternal() +{ + throw; +} +#endif + QT_END_NAMESPACE |