X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/1df5f87f1309a8daa30dabdee855f48ae40d14ab..6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174:/runtime/ExceptionHelpers.cpp diff --git a/runtime/ExceptionHelpers.cpp b/runtime/ExceptionHelpers.cpp index 1d74315..ce63ae9 100644 --- a/runtime/ExceptionHelpers.cpp +++ b/runtime/ExceptionHelpers.cpp @@ -41,40 +41,60 @@ namespace JSC { -class InterruptedExecutionError : public JSNonFinalObject { -public: - InterruptedExecutionError(JSGlobalData* globalData) - : JSNonFinalObject(*globalData, globalData->interruptedExecutionErrorStructure.get()) - { - } +ASSERT_HAS_TRIVIAL_DESTRUCTOR(InterruptedExecutionError); - virtual ComplType exceptionType() const { return Interrupted; } +const ClassInfo InterruptedExecutionError::s_info = { "InterruptedExecutionError", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(InterruptedExecutionError) }; - virtual UString toString(ExecState*) const { return "JavaScript execution exceeded timeout."; } -}; +JSValue InterruptedExecutionError::defaultValue(const JSObject*, ExecState* exec, PreferredPrimitiveType hint) +{ + if (hint == PreferString) + return jsNontrivialString(exec, "JavaScript execution exceeded timeout."); + return JSValue(std::numeric_limits::quiet_NaN()); +} JSObject* createInterruptedExecutionException(JSGlobalData* globalData) { - return new (globalData) InterruptedExecutionError(globalData); + return InterruptedExecutionError::create(*globalData); +} + +bool isInterruptedExecutionException(JSObject* object) +{ + return object->inherits(&InterruptedExecutionError::s_info); } -class TerminatedExecutionError : public JSNonFinalObject { -public: - TerminatedExecutionError(JSGlobalData* globalData) - : JSNonFinalObject(*globalData, globalData->terminatedExecutionErrorStructure.get()) - { - } +bool isInterruptedExecutionException(JSValue value) +{ + return value.inherits(&InterruptedExecutionError::s_info); +} + + +ASSERT_HAS_TRIVIAL_DESTRUCTOR(TerminatedExecutionError); - virtual ComplType exceptionType() const { return Terminated; } +const ClassInfo TerminatedExecutionError::s_info = { "TerminatedExecutionError", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(TerminatedExecutionError) }; - virtual UString toString(ExecState*) const { return "JavaScript execution terminated."; } -}; +JSValue TerminatedExecutionError::defaultValue(const JSObject*, ExecState* exec, PreferredPrimitiveType hint) +{ + if (hint == PreferString) + return jsNontrivialString(exec, "JavaScript execution terminated."); + return JSValue(std::numeric_limits::quiet_NaN()); +} JSObject* createTerminatedExecutionException(JSGlobalData* globalData) { - return new (globalData) TerminatedExecutionError(globalData); + return TerminatedExecutionError::create(*globalData); +} + +bool isTerminatedExecutionException(JSObject* object) +{ + return object->inherits(&TerminatedExecutionError::s_info); } +bool isTerminatedExecutionException(JSValue value) +{ + return value.inherits(&TerminatedExecutionError::s_info); +} + + JSObject* createStackOverflowError(ExecState* exec) { return createRangeError(exec, "Maximum call stack size exceeded."); @@ -93,7 +113,7 @@ JSObject* createUndefinedVariableError(ExecState* exec, const Identifier& ident) JSObject* createInvalidParamError(ExecState* exec, const char* op, JSValue value) { - UString errorMessage = makeUString("'", value.toString(exec), "' is not a valid argument for '", op, "'"); + UString errorMessage = makeUString("'", value.toString(exec)->value(exec), "' is not a valid argument for '", op, "'"); JSObject* exception = createTypeError(exec, errorMessage); ASSERT(exception->isErrorInstance()); static_cast(exception)->setAppendSourceToMessage(); @@ -102,7 +122,7 @@ JSObject* createInvalidParamError(ExecState* exec, const char* op, JSValue value JSObject* createNotAConstructorError(ExecState* exec, JSValue value) { - UString errorMessage = makeUString("'", value.toString(exec), "' is not a constructor"); + UString errorMessage = makeUString("'", value.toString(exec)->value(exec), "' is not a constructor"); JSObject* exception = createTypeError(exec, errorMessage); ASSERT(exception->isErrorInstance()); static_cast(exception)->setAppendSourceToMessage(); @@ -111,7 +131,7 @@ JSObject* createNotAConstructorError(ExecState* exec, JSValue value) JSObject* createNotAFunctionError(ExecState* exec, JSValue value) { - UString errorMessage = makeUString("'", value.toString(exec), "' is not a function"); + UString errorMessage = makeUString("'", value.toString(exec)->value(exec), "' is not a function"); JSObject* exception = createTypeError(exec, errorMessage); ASSERT(exception->isErrorInstance()); static_cast(exception)->setAppendSourceToMessage(); @@ -120,7 +140,7 @@ JSObject* createNotAFunctionError(ExecState* exec, JSValue value) JSObject* createNotAnObjectError(ExecState* exec, JSValue value) { - UString errorMessage = makeUString("'", value.toString(exec), "' is not an object"); + UString errorMessage = makeUString("'", value.toString(exec)->value(exec), "' is not an object"); JSObject* exception = createTypeError(exec, errorMessage); ASSERT(exception->isErrorInstance()); static_cast(exception)->setAppendSourceToMessage();