X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/9dae56ea45a0f5f8136a5c93d6f3a7f99399ca73..14957cd040308e3eeec43d26bae5d76da13fcd85:/runtime/InternalFunction.cpp?ds=inline diff --git a/runtime/InternalFunction.cpp b/runtime/InternalFunction.cpp index 6714cf5..c3b07f8 100644 --- a/runtime/InternalFunction.cpp +++ b/runtime/InternalFunction.cpp @@ -24,28 +24,53 @@ #include "InternalFunction.h" #include "FunctionPrototype.h" +#include "JSGlobalObject.h" #include "JSString.h" namespace JSC { +// Ensure the compiler generates a vtable for InternalFunction! +void InternalFunction::vtableAnchor() {} + ASSERT_CLASS_FITS_IN_CELL(InternalFunction); -const ClassInfo InternalFunction::info = { "Function", 0, 0, 0 }; +const ClassInfo InternalFunction::s_info = { "Function", &JSObjectWithGlobalObject::s_info, 0, 0 }; + +InternalFunction::InternalFunction(VPtrStealingHackType) + : JSObjectWithGlobalObject(VPtrStealingHack) +{ +} + +InternalFunction::InternalFunction(JSGlobalData* globalData, JSGlobalObject* globalObject, Structure* structure, const Identifier& name) + : JSObjectWithGlobalObject(globalObject, structure) +{ + ASSERT(inherits(&s_info)); + putDirect(*globalData, globalData->propertyNames->name, jsString(globalData, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum); +} -const ClassInfo* InternalFunction::classInfo() const +const UString& InternalFunction::name(ExecState* exec) { - return &info; + return asString(getDirect(exec->globalData(), exec->globalData().propertyNames->name))->tryGetValue(); } -InternalFunction::InternalFunction(JSGlobalData* globalData, PassRefPtr structure, const Identifier& name) - : JSObject(structure) +const UString InternalFunction::displayName(ExecState* exec) { - putDirect(globalData->propertyNames->name, jsString(globalData, name.ustring()), DontDelete | ReadOnly | DontEnum); + JSValue displayName = getDirect(exec->globalData(), exec->globalData().propertyNames->displayName); + + if (displayName && isJSString(&exec->globalData(), displayName)) + return asString(displayName)->tryGetValue(); + + return UString(); } -const UString& InternalFunction::name(JSGlobalData* globalData) +const UString InternalFunction::calculatedDisplayName(ExecState* exec) { - return asString(getDirect(globalData->propertyNames->name))->value(); + const UString explicitName = displayName(exec); + + if (!explicitName.isEmpty()) + return explicitName; + + return name(exec); } } // namespace JSC