#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<ErrorInstance*>(exception)->setAppendSourceToMessage();
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<ErrorInstance*>(exception)->setAppendSourceToMessage();
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<ErrorInstance*>(exception)->setAppendSourceToMessage();
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<ErrorInstance*>(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)
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