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