]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/InternalFunction.cpp
JavaScriptCore-1218.34.tar.gz
[apple/javascriptcore.git] / runtime / InternalFunction.cpp
index b5c95715592edd5a298439d5a91b5beccd617541..071babc469875ae84c74a55fcb6c2b166f3951d0 100644 (file)
 #include "InternalFunction.h"
 
 #include "FunctionPrototype.h"
+#include "JSGlobalObject.h"
 #include "JSString.h"
+#include "Operations.h"
 
 namespace JSC {
 
-ASSERT_CLASS_FITS_IN_CELL(InternalFunction);
+ASSERT_HAS_TRIVIAL_DESTRUCTOR(InternalFunction);
 
-const ClassInfo InternalFunction::info = { "Function", 0, 0, 0 };
+const ClassInfo InternalFunction::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(InternalFunction) };
 
-const ClassInfo* InternalFunction::classInfo() const
+InternalFunction::InternalFunction(JSGlobalObject* globalObject, Structure* structure)
+    : JSDestructibleObject(globalObject->vm(), structure)
 {
-    return &info;
 }
 
-InternalFunction::InternalFunction(JSGlobalData* globalData, PassRefPtr<Structure> structure, const Identifier& name)
-    : JSObject(structure)
+void InternalFunction::finishCreation(VM& vm, const String& name)
 {
-    putDirect(globalData->propertyNames->name, jsString(globalData, name.ustring()), DontDelete | ReadOnly | DontEnum);
+    Base::finishCreation(vm);
+    ASSERT(inherits(&s_info));
+    ASSERT(methodTable()->getCallData != InternalFunction::s_info.methodTable.getCallData);
+    putDirect(vm, vm.propertyNames->name, jsString(&vm, name), DontDelete | ReadOnly | DontEnum);
 }
 
-const UString& InternalFunction::name(JSGlobalData* globalData)
+const String& InternalFunction::name(ExecState* exec)
 {
-    return asString(getDirect(globalData->propertyNames->name))->value();
+    return asString(getDirect(exec->vm(), exec->vm().propertyNames->name))->tryGetValue();
 }
 
-const UString InternalFunction::displayName(JSGlobalData* globalData)
+const String InternalFunction::displayName(ExecState* exec)
 {
-    JSValue displayName = getDirect(globalData->propertyNames->displayName);
+    JSValue displayName = getDirect(exec->vm(), exec->vm().propertyNames->displayName);
     
-    if (displayName && isJSString(globalData, displayName))
-        return asString(displayName)->value();
+    if (displayName && isJSString(displayName))
+        return asString(displayName)->tryGetValue();
     
-    return UString::null();
+    return String();
 }
 
-const UString InternalFunction::calculatedDisplayName(JSGlobalData* globalData)
+CallType InternalFunction::getCallData(JSCell*, CallData&)
 {
-    const UString explicitName = displayName(globalData);
+    RELEASE_ASSERT_NOT_REACHED();
+    return CallTypeNone;
+}
+
+const String InternalFunction::calculatedDisplayName(ExecState* exec)
+{
+    const String explicitName = displayName(exec);
     
     if (!explicitName.isEmpty())
         return explicitName;
     
-    return name(globalData);
+    return name(exec);
 }
 
 } // namespace JSC