EncodedJSValue JSC_HOST_CALL protoFuncWeakMapSet(CallFrame* callFrame) { WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue()); if (!map) return JSValue::encode(jsUndefined()); JSValue key = callFrame->argument(0); if (!key.isObject()) return JSValue::encode(throwTypeError(callFrame, WTF::ASCIILiteral("Attempted to set a non-object key in a WeakMap"))); map->set(callFrame->vm(), asObject(key), callFrame->argument(1)); return JSValue::encode(callFrame->thisValue()); }
EncodedJSValue JSC_HOST_CALL protoFuncWeakMapSet(CallFrame* callFrame) { VM& vm = callFrame->vm(); auto scope = DECLARE_THROW_SCOPE(vm); WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue()); ASSERT(!!scope.exception() == !map); if (!map) return JSValue::encode(jsUndefined()); JSValue key = callFrame->argument(0); if (!key.isObject()) return JSValue::encode(throwTypeError(callFrame, scope, WTF::ASCIILiteral("Attempted to set a non-object key in a WeakMap"))); map->set(vm, asObject(key), callFrame->argument(1)); return JSValue::encode(callFrame->thisValue()); }