]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/ErrorInstance.h
JavaScriptCore-7600.1.4.16.1.tar.gz
[apple/javascriptcore.git] / runtime / ErrorInstance.h
index 6f9d262ea72364c6f5375de0264c9ce9caed494d..91dd7ef0ae63c57f514de9135e082a27c21ea22c 100644 (file)
 #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