diff options
Diffstat (limited to 'Source/JavaScriptCore/runtime/JSBoundFunction.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/JSBoundFunction.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/Source/JavaScriptCore/runtime/JSBoundFunction.cpp b/Source/JavaScriptCore/runtime/JSBoundFunction.cpp index f22827a37..febe9897d 100644 --- a/Source/JavaScriptCore/runtime/JSBoundFunction.cpp +++ b/Source/JavaScriptCore/runtime/JSBoundFunction.cpp @@ -28,11 +28,11 @@ #include "GetterSetter.h" #include "JSGlobalObject.h" -#include "Operations.h" +#include "JSCInlines.h" namespace JSC { -const ClassInfo JSBoundFunction::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSBoundFunction) }; +const ClassInfo JSBoundFunction::s_info = { "Function", &Base::s_info, 0, CREATE_METHOD_TABLE(JSBoundFunction) }; EncodedJSValue JSC_HOST_CALL boundFunctionCall(ExecState* exec) { @@ -74,23 +74,31 @@ EncodedJSValue JSC_HOST_CALL boundFunctionConstruct(ExecState* exec) return JSValue::encode(construct(exec, targetFunction, constructType, constructData, args)); } +EncodedJSValue JSC_HOST_CALL isBoundFunction(ExecState* exec) +{ + return JSValue::encode(JSValue(static_cast<bool>(jsDynamicCast<JSBoundFunction*>(exec->uncheckedArgument(0))))); +} + +EncodedJSValue JSC_HOST_CALL hasInstanceBoundFunction(ExecState* exec) +{ + JSBoundFunction* boundObject = jsCast<JSBoundFunction*>(exec->uncheckedArgument(0)); + JSValue value = exec->uncheckedArgument(1); + + return JSValue::encode(jsBoolean(boundObject->targetFunction()->hasInstance(exec, value))); +} + JSBoundFunction* JSBoundFunction::create(VM& vm, JSGlobalObject* globalObject, JSObject* targetFunction, JSValue boundThis, JSValue boundArgs, int length, const String& name) { ConstructData constructData; ConstructType constructType = JSC::getConstructData(targetFunction, constructData); bool canConstruct = constructType != ConstructTypeNone; - NativeExecutable* executable = vm.getHostFunction(boundFunctionCall, canConstruct ? boundFunctionConstruct : callHostFunctionAsConstructor); + NativeExecutable* executable = vm.getHostFunction(boundFunctionCall, canConstruct ? boundFunctionConstruct : callHostFunctionAsConstructor, ASCIILiteral("Function.prototype.bind result")); JSBoundFunction* function = new (NotNull, allocateCell<JSBoundFunction>(vm.heap)) JSBoundFunction(vm, globalObject, globalObject->boundFunctionStructure(), targetFunction, boundThis, boundArgs); - function->finishCreation(vm, executable, length, name); + function->finishCreation(vm, executable, length, makeString("bound ", name)); return function; } -void JSBoundFunction::destroy(JSCell* cell) -{ - static_cast<JSBoundFunction*>(cell)->JSBoundFunction::~JSBoundFunction(); -} - bool JSBoundFunction::customHasInstance(JSObject* object, ExecState* exec, JSValue value) { return jsCast<JSBoundFunction*>(object)->m_targetFunction->hasInstance(exec, value); @@ -117,8 +125,6 @@ void JSBoundFunction::visitChildren(JSCell* cell, SlotVisitor& visitor) { JSBoundFunction* thisObject = jsCast<JSBoundFunction*>(cell); ASSERT_GC_OBJECT_INHERITS(thisObject, info()); - COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag); - ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren()); Base::visitChildren(thisObject, visitor); visitor.append(&thisObject->m_targetFunction); @@ -126,4 +132,9 @@ void JSBoundFunction::visitChildren(JSCell* cell, SlotVisitor& visitor) visitor.append(&thisObject->m_boundArgs); } +String JSBoundFunction::toStringName(ExecState* exec) +{ + return m_targetFunction->get(exec, exec->vm().propertyNames->name).toWTFString(exec); +} + } // namespace JSC |