#pragma once
#include "ExceptionScope.h"
namespace JSC {
class ExecState;
class JSObject;
#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
class ThrowScope : public ExceptionScope {
public:
JS_EXPORT_PRIVATE ThrowScope(VM&, ExceptionEventLocation);
JS_EXPORT_PRIVATE ~ThrowScope();
ThrowScope(const ThrowScope&) = delete;
ThrowScope(ThrowScope&&) = default;
JS_EXPORT_PRIVATE void throwException(ExecState*, Exception*);
JS_EXPORT_PRIVATE JSValue throwException(ExecState*, JSValue);
JS_EXPORT_PRIVATE JSObject* throwException(ExecState*, JSObject*);
void release() { m_isReleased = true; }
JS_EXPORT_PRIVATE void printIfNeedCheck(const char* functionName, const char* file, unsigned line);
private:
void simulateThrow();
bool m_isReleased { false };
};
#define DECLARE_THROW_SCOPE(vm__) \
JSC::ThrowScope((vm__), JSC::ExceptionEventLocation(__FUNCTION__, __FILE__, __LINE__))
#define throwScopePrintIfNeedCheck(scope__) \
scope__.printIfNeedCheck(__FUNCTION__, __FILE__, __LINE__)
#else // not ENABLE(EXCEPTION_SCOPE_VERIFICATION)
class ThrowScope : public ExceptionScope {
public:
ALWAYS_INLINE ThrowScope(VM& vm)
: ExceptionScope(vm)
{ }
ThrowScope(const ThrowScope&) = delete;
ThrowScope(ThrowScope&&) = default;
ALWAYS_INLINE void throwException(ExecState* exec, Exception* exception) { m_vm.throwException(exec, exception); }
ALWAYS_INLINE JSValue throwException(ExecState* exec, JSValue value) { return m_vm.throwException(exec, value); }
ALWAYS_INLINE JSObject* throwException(ExecState* exec, JSObject* obj) { return m_vm.throwException(exec, obj); }
ALWAYS_INLINE void release() { }
};
#define DECLARE_THROW_SCOPE(vm__) \
JSC::ThrowScope((vm__))
#endif // ENABLE(EXCEPTION_SCOPE_VERIFICATION)
ALWAYS_INLINE void throwException(ExecState* exec, ThrowScope& scope, Exception* exception)
{
scope.throwException(exec, exception);
}
ALWAYS_INLINE JSValue throwException(ExecState* exec, ThrowScope& scope, JSValue value)
{
return scope.throwException(exec, value);
}
ALWAYS_INLINE JSObject* throwException(ExecState* exec, ThrowScope& scope, JSObject* obj)
{
return scope.throwException(exec, obj);
}
}