#ifndef ErrorInstance_h
#define ErrorInstance_h
+#include "Interpreter.h"
#include "JSObject.h"
+#include "SourceProvider.h"
namespace JSC {
class ErrorInstance : public JSNonFinalObject {
public:
- static const ClassInfo s_info;
+ typedef JSNonFinalObject Base;
- static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
+ DECLARE_INFO;
+
+ static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
+ return Structure::create(vm, globalObject, prototype, TypeInfo(ErrorInstanceType, StructureFlags), info());
}
- static ErrorInstance* create(JSGlobalData*, Structure*, const UString&);
- static ErrorInstance* create(ExecState*, Structure*, JSValue message);
+ static ErrorInstance* create(VM& vm, Structure* structure, const String& message, Vector<StackFrame> stackTrace = Vector<StackFrame>())
+ {
+ ErrorInstance* instance = new (NotNull, allocateCell<ErrorInstance>(vm.heap)) ErrorInstance(vm, structure);
+ instance->finishCreation(vm, message, stackTrace);
+ return instance;
+ }
+ static ErrorInstance* create(ExecState* exec, Structure* structure, JSValue message, Vector<StackFrame> stackTrace = Vector<StackFrame>())
+ {
+ return create(exec->vm(), structure, message.isUndefined() ? String() : message.toString(exec)->value(exec), stackTrace);
+ }
bool appendSourceToMessage() { return m_appendSourceToMessage; }
void setAppendSourceToMessage() { m_appendSourceToMessage = true; }
void clearAppendSourceToMessage() { m_appendSourceToMessage = false; }
- virtual bool isErrorInstance() const { return true; }
-
protected:
- explicit ErrorInstance(JSGlobalData*, Structure*);
- explicit ErrorInstance(JSGlobalData*, Structure*, const UString&);
+ explicit ErrorInstance(VM&, Structure*);
+
+ void finishCreation(VM&, const String&, Vector<StackFrame> = Vector<StackFrame>());
bool m_appendSourceToMessage;
};