X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/14957cd040308e3eeec43d26bae5d76da13fcd85..4be4e30906bcb8ee30b4d189205cb70bad6707ce:/runtime/ExceptionHelpers.cpp diff --git a/runtime/ExceptionHelpers.cpp b/runtime/ExceptionHelpers.cpp index 1d74315..816e8e3 100644 --- a/runtime/ExceptionHelpers.cpp +++ b/runtime/ExceptionHelpers.cpp @@ -37,63 +37,56 @@ #include "JSNotAnObject.h" #include "Interpreter.h" #include "Nodes.h" -#include "UStringConcatenate.h" +#include "Operations.h" namespace JSC { -class InterruptedExecutionError : public JSNonFinalObject { -public: - InterruptedExecutionError(JSGlobalData* globalData) - : JSNonFinalObject(*globalData, globalData->interruptedExecutionErrorStructure.get()) - { - } +ASSERT_HAS_TRIVIAL_DESTRUCTOR(TerminatedExecutionError); - virtual ComplType exceptionType() const { return Interrupted; } +const ClassInfo TerminatedExecutionError::s_info = { "TerminatedExecutionError", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(TerminatedExecutionError) }; - virtual UString toString(ExecState*) const { return "JavaScript execution exceeded timeout."; } -}; - -JSObject* createInterruptedExecutionException(JSGlobalData* globalData) +JSValue TerminatedExecutionError::defaultValue(const JSObject*, ExecState* exec, PreferredPrimitiveType hint) { - return new (globalData) InterruptedExecutionError(globalData); + if (hint == PreferString) + return jsNontrivialString(exec, String(ASCIILiteral("JavaScript execution terminated."))); + return JSValue(QNaN); } -class TerminatedExecutionError : public JSNonFinalObject { -public: - TerminatedExecutionError(JSGlobalData* globalData) - : JSNonFinalObject(*globalData, globalData->terminatedExecutionErrorStructure.get()) - { - } - - virtual ComplType exceptionType() const { return Terminated; } +JSObject* createTerminatedExecutionException(VM* vm) +{ + return TerminatedExecutionError::create(*vm); +} - virtual UString toString(ExecState*) const { return "JavaScript execution terminated."; } -}; +bool isTerminatedExecutionException(JSObject* object) +{ + return object->inherits(&TerminatedExecutionError::s_info); +} -JSObject* createTerminatedExecutionException(JSGlobalData* globalData) +bool isTerminatedExecutionException(JSValue value) { - return new (globalData) TerminatedExecutionError(globalData); + return value.inherits(&TerminatedExecutionError::s_info); } + 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), "' 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(); @@ -102,7 +95,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"); + String errorMessage = makeString("'", value.toString(exec)->value(exec), "' is not a constructor"); JSObject* exception = createTypeError(exec, errorMessage); ASSERT(exception->isErrorInstance()); static_cast(exception)->setAppendSourceToMessage(); @@ -111,7 +104,7 @@ JSObject* createNotAConstructorError(ExecState* exec, JSValue value) JSObject* createNotAFunctionError(ExecState* exec, JSValue value) { - UString errorMessage = makeUString("'", value.toString(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(); @@ -120,21 +113,21 @@ JSObject* createNotAFunctionError(ExecState* exec, JSValue value) JSObject* createNotAnObjectError(ExecState* exec, JSValue value) { - UString errorMessage = makeUString("'", value.toString(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) @@ -144,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