X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/9dae56ea45a0f5f8136a5c93d6f3a7f99399ca73..12899fa232562c774004a3a9d7d3149944dec712:/runtime/InternalFunction.cpp diff --git a/runtime/InternalFunction.cpp b/runtime/InternalFunction.cpp index 6714cf5..071babc 100644 --- a/runtime/InternalFunction.cpp +++ b/runtime/InternalFunction.cpp @@ -24,28 +24,58 @@ #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, 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