Beispiel #1
0
EncodedJSValue JSC_HOST_CALL protoFuncWeakMapHas(CallFrame* callFrame)
{
    WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue());
    if (!map)
        return JSValue::encode(jsUndefined());
    JSValue key = callFrame->argument(0);
    return JSValue::encode(jsBoolean(key.isObject() && map->contains(asObject(key))));
}
Beispiel #2
0
EncodedJSValue JSC_HOST_CALL protoFuncWeakMapClear(CallFrame* callFrame)
{
    WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue());
    if (!map)
        return JSValue::encode(jsUndefined());
    map->clear();
    return JSValue::encode(jsUndefined());
}
Beispiel #3
0
EncodedJSValue JSC_HOST_CALL protoFuncWeakMapGet(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("A WeakMap cannot have a non-object key")));
    return JSValue::encode(map->get(asObject(key)));
}
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());
}
Beispiel #5
0
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());
}