#ifndef ErrorInstance_h
#define ErrorInstance_h
+#include "Interpreter.h"
#include "JSObject.h"
+#include "SourceProvider.h"
namespace JSC {
- class ErrorInstance : public JSObject {
+ class ErrorInstance : public JSNonFinalObject {
public:
- explicit ErrorInstance(PassRefPtr<Structure>);
+ typedef JSNonFinalObject Base;
- virtual const ClassInfo* classInfo() const { return &info; }
- static const ClassInfo info;
+ DECLARE_INFO;
+
+ static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+ {
+ return Structure::create(vm, globalObject, prototype, TypeInfo(ErrorInstanceType, StructureFlags), info());
+ }
+
+ 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; }
+
+ protected:
+ explicit ErrorInstance(VM&, Structure*);
+
+ void finishCreation(VM&, const String&, Vector<StackFrame> = Vector<StackFrame>());
+
+ bool m_appendSourceToMessage;
};
} // namespace JSC