X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174..4be4e30906bcb8ee30b4d189205cb70bad6707ce:/runtime/ExceptionHelpers.cpp?ds=sidebyside diff --git a/runtime/ExceptionHelpers.cpp b/runtime/ExceptionHelpers.cpp index ce63ae9..816e8e3 100644 --- a/runtime/ExceptionHelpers.cpp +++ b/runtime/ExceptionHelpers.cpp @@ -37,37 +37,10 @@ #include "JSNotAnObject.h" #include "Interpreter.h" #include "Nodes.h" -#include "UStringConcatenate.h" +#include "Operations.h" namespace JSC { -ASSERT_HAS_TRIVIAL_DESTRUCTOR(InterruptedExecutionError); - -const ClassInfo InterruptedExecutionError::s_info = { "InterruptedExecutionError", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(InterruptedExecutionError) }; - -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 InterruptedExecutionError::create(*globalData); -} - -bool isInterruptedExecutionException(JSObject* object) -{ - return object->inherits(&InterruptedExecutionError::s_info); -} - -bool isInterruptedExecutionException(JSValue value) -{ - return value.inherits(&InterruptedExecutionError::s_info); -} - - ASSERT_HAS_TRIVIAL_DESTRUCTOR(TerminatedExecutionError); const ClassInfo TerminatedExecutionError::s_info = { "TerminatedExecutionError", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(TerminatedExecutionError) }; @@ -75,13 +48,13 @@ const ClassInfo TerminatedExecutionError::s_info = { "TerminatedExecutionError", 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()); + return jsNontrivialString(exec, String(ASCIILiteral("JavaScript execution terminated."))); + return JSValue(QNaN); } -JSObject* createTerminatedExecutionException(JSGlobalData* globalData) +JSObject* createTerminatedExecutionException(VM* vm) { - return TerminatedExecutionError::create(*globalData); + return TerminatedExecutionError::create(*vm); } bool isTerminatedExecutionException(JSObject* object) @@ -97,23 +70,23 @@ bool isTerminatedExecutionException(JSValue value) JSObject* createStackOverflowError(ExecState* exec) { - return createRangeError(exec, "Maximum call stack size exceeded."); + return createRangeError(exec, ASCIILiteral("Maximum call stack size exceeded.")); } JSObject* createStackOverflowError(JSGlobalObject* globalObject) { - return createRangeError(globalObject, "Maximum call stack size exceeded."); + return createRangeError(globalObject, ASCIILiteral("Maximum call stack size exceeded.")); } JSObject* createUndefinedVariableError(ExecState* exec, const Identifier& ident) { - UString message(makeUString("Can't find variable: ", ident.ustring())); + String message(makeString("Can't find variable: ", ident.string())); return createReferenceError(exec, message); } JSObject* createInvalidParamError(ExecState* exec, const char* op, JSValue value) { - UString errorMessage = makeUString("'", value.toString(exec)->value(exec), "' is not a valid argument for '", op, "'"); + String errorMessage = makeString("'", value.toString(exec)->value(exec), "' is not a valid argument for '", op, "'"); JSObject* exception = createTypeError(exec, errorMessage); ASSERT(exception->isErrorInstance()); static_cast(exception)->setAppendSourceToMessage(); @@ -122,7 +95,7 @@ JSObject* createInvalidParamError(ExecState* exec, const char* op, JSValue value JSObject* createNotAConstructorError(ExecState* exec, JSValue value) { - UString errorMessage = makeUString("'", value.toString(exec)->value(exec), "' is not a constructor"); + String errorMessage = makeString("'", value.toString(exec)->value(exec), "' is not a constructor"); JSObject* exception = createTypeError(exec, errorMessage); ASSERT(exception->isErrorInstance()); static_cast(exception)->setAppendSourceToMessage(); @@ -131,7 +104,7 @@ JSObject* createNotAConstructorError(ExecState* exec, JSValue value) JSObject* createNotAFunctionError(ExecState* exec, JSValue value) { - UString errorMessage = makeUString("'", value.toString(exec)->value(exec), "' is not a function"); + String errorMessage = makeString("'", value.toString(exec)->value(exec), "' is not a function"); JSObject* exception = createTypeError(exec, errorMessage); ASSERT(exception->isErrorInstance()); static_cast(exception)->setAppendSourceToMessage(); @@ -140,21 +113,21 @@ JSObject* createNotAFunctionError(ExecState* exec, JSValue value) JSObject* createNotAnObjectError(ExecState* exec, JSValue value) { - UString errorMessage = makeUString("'", value.toString(exec)->value(exec), "' is not an object"); + String errorMessage = makeString("'", value.toString(exec)->value(exec), "' is not an object"); JSObject* exception = createTypeError(exec, errorMessage); ASSERT(exception->isErrorInstance()); static_cast(exception)->setAppendSourceToMessage(); return exception; } -JSObject* createErrorForInvalidGlobalAssignment(ExecState* exec, const UString& propertyName) +JSObject* createErrorForInvalidGlobalAssignment(ExecState* exec, const String& propertyName) { - return createReferenceError(exec, makeUString("Strict mode forbids implicit creation of global property '", propertyName, "'")); + return createReferenceError(exec, makeString("Strict mode forbids implicit creation of global property '", propertyName, "'")); } JSObject* createOutOfMemoryError(JSGlobalObject* globalObject) { - return createError(globalObject, "Out of memory"); + return createError(globalObject, ASCIILiteral("Out of memory")); } JSObject* throwOutOfMemoryError(ExecState* exec) @@ -164,7 +137,14 @@ JSObject* throwOutOfMemoryError(ExecState* exec) JSObject* throwStackOverflowError(ExecState* exec) { + Interpreter::ErrorHandlingMode mode(exec); return throwError(exec, createStackOverflowError(exec)); } +JSObject* throwTerminatedExecutionException(ExecState* exec) +{ + Interpreter::ErrorHandlingMode mode(exec); + return throwError(exec, createTerminatedExecutionException(&exec->vm())); +} + } // namespace JSC