InternalFunction.cpp [plain text]
#include "config.h"
#include "InternalFunction.h"
#include "FunctionPrototype.h"
#include "JSGlobalObject.h"
#include "JSString.h"
namespace JSC {
void InternalFunction::vtableAnchor() {}
ASSERT_CLASS_FITS_IN_CELL(InternalFunction);
const ClassInfo InternalFunction::s_info = { "Function", &JSNonFinalObject::s_info, 0, 0, CREATE_METHOD_TABLE(InternalFunction) };
InternalFunction::InternalFunction(VPtrStealingHackType)
: JSNonFinalObject(VPtrStealingHack)
{
}
InternalFunction::InternalFunction(JSGlobalObject* globalObject, Structure* structure)
: JSNonFinalObject(globalObject->globalData(), structure)
{
}
void InternalFunction::finishCreation(JSGlobalData& globalData, const Identifier& name)
{
Base::finishCreation(globalData);
ASSERT(inherits(&s_info));
ASSERT(methodTable()->getCallData != InternalFunction::s_info.methodTable.getCallData);
putDirect(globalData, globalData.propertyNames->name, jsString(&globalData, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
}
const UString& InternalFunction::name(ExecState* exec)
{
return asString(getDirect(exec->globalData(), exec->globalData().propertyNames->name))->tryGetValue();
}
const UString InternalFunction::displayName(ExecState* exec)
{
JSValue displayName = getDirect(exec->globalData(), exec->globalData().propertyNames->displayName);
if (displayName && isJSString(&exec->globalData(), displayName))
return asString(displayName)->tryGetValue();
return UString();
}
CallType InternalFunction::getCallData(JSCell*, CallData&)
{
ASSERT_NOT_REACHED();
return CallTypeNone;
}
const UString InternalFunction::calculatedDisplayName(ExecState* exec)
{
const UString explicitName = displayName(exec);
if (!explicitName.isEmpty())
return explicitName;
return name(exec);
}
}