]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/ErrorInstance.cpp
JavaScriptCore-903.5.tar.gz
[apple/javascriptcore.git] / runtime / ErrorInstance.cpp
index 1cdb87a5a9169c925ffc67e4b47efa50184351aa..ed95ba4a1778def2a4aae986e40e2b0f82154791 100644 (file)
 
 namespace JSC {
 
-const ClassInfo ErrorInstance::info = { "Error", 0, 0, 0 };
+const ClassInfo ErrorInstance::s_info = { "Error", &JSNonFinalObject::s_info, 0, 0 };
 
-ErrorInstance::ErrorInstance(NonNullPassRefPtr<Structure> structure)
-    : JSObject(structure)
+ErrorInstance::ErrorInstance(JSGlobalData* globalData, Structure* structure)
+    : JSNonFinalObject(*globalData, structure)
+    , m_appendSourceToMessage(false)
 {
+    ASSERT(inherits(&s_info));
+    putDirect(*globalData, globalData->propertyNames->message, jsString(globalData, ""));
+}
+
+ErrorInstance::ErrorInstance(JSGlobalData* globalData, Structure* structure, const UString& message)
+    : JSNonFinalObject(*globalData, structure)
+    , m_appendSourceToMessage(false)
+{
+    ASSERT(inherits(&s_info));
+    putDirect(*globalData, globalData->propertyNames->message, jsString(globalData, message));
+}
+
+ErrorInstance* ErrorInstance::create(JSGlobalData* globalData, Structure* structure, const UString& message)
+{
+    return new (globalData) ErrorInstance(globalData, structure, message);
+}
+
+ErrorInstance* ErrorInstance::create(ExecState* exec, Structure* structure, JSValue message)
+{
+    if (message.isUndefined())
+        return new (exec) ErrorInstance(&exec->globalData(), structure);
+    return new (exec) ErrorInstance(&exec->globalData(), structure, message.toString(exec));
 }
 
 } // namespace JSC