]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/ErrorInstance.h
JavaScriptCore-1218.34.tar.gz
[apple/javascriptcore.git] / runtime / ErrorInstance.h
index 9f53b5154a345d923a430a944ee901a5e23d33bf..26a8b31ea9dacae1d7b1e1cc14e998879aebc3ea 100644 (file)
 
 namespace JSC {
 
-    class ErrorInstance : public JSObject {
+    class ErrorInstance : public JSNonFinalObject {
     public:
-        explicit ErrorInstance(NonNullPassRefPtr<Structure>);
+        typedef JSNonFinalObject Base;
 
-        virtual const ClassInfo* classInfo() const { return &info; }
-        static const ClassInfo info;
+        static const ClassInfo s_info;
+
+        static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+        {
+            return Structure::create(vm, globalObject, prototype, TypeInfo(ErrorInstanceType, StructureFlags), &s_info);
+        }
+
+        static ErrorInstance* create(VM& vm, Structure* structure, const String& message)
+        {
+            ErrorInstance* instance = new (NotNull, allocateCell<ErrorInstance>(vm.heap)) ErrorInstance(vm, structure);
+            instance->finishCreation(vm, message);
+            return instance;
+        }
+
+        static ErrorInstance* create(ExecState* exec, Structure* structure, JSValue message)
+        {
+            return create(exec->vm(), structure, message.isUndefined() ? String() : message.toString(exec)->value(exec));
+        }
+
+        bool appendSourceToMessage() { return m_appendSourceToMessage; }
+        void setAppendSourceToMessage() { m_appendSourceToMessage = true; }
+        void clearAppendSourceToMessage() { m_appendSourceToMessage = false; }
+
+    protected:
+        explicit ErrorInstance(VM&, Structure*);
+
+        void finishCreation(VM& vm, const String& message)
+        {
+            Base::finishCreation(vm);
+            ASSERT(inherits(&s_info));
+            if (!message.isNull())
+                putDirect(vm, vm.propertyNames->message, jsString(&vm, message), DontEnum);
+        }
+
+        bool m_appendSourceToMessage;
     };
 
 } // namespace JSC