]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/InternalFunction.cpp
JavaScriptCore-1218.33.tar.gz
[apple/javascriptcore.git] / runtime / InternalFunction.cpp
index 6714cf5426855025da380b636d3e0c5b5af60d60..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 String InternalFunction::displayName(ExecState* exec)
+{
+    JSValue displayName = getDirect(exec->vm(), exec->vm().propertyNames->displayName);
+    
+    if (displayName && isJSString(displayName))
+        return asString(displayName)->tryGetValue();
+    
+    return String();
+}
+
+CallType InternalFunction::getCallData(JSCell*, CallData&)
+{
+    RELEASE_ASSERT_NOT_REACHED();
+    return CallTypeNone;
+}
+
+const String InternalFunction::calculatedDisplayName(ExecState* exec)
+{
+    const String explicitName = displayName(exec);
+    
+    if (!explicitName.isEmpty())
+        return explicitName;
+    
+    return name(exec);
 }
 
 } // namespace JSC