JSValue iteratorNext(ExecState* exec, IterationRecord iterationRecord, JSValue argument) { VM& vm = exec->vm(); auto scope = DECLARE_THROW_SCOPE(vm); JSValue iterator = iterationRecord.iterator; JSValue nextFunction = iterationRecord.nextMethod; CallData nextFunctionCallData; CallType nextFunctionCallType = getCallData(vm, nextFunction, nextFunctionCallData); if (nextFunctionCallType == CallType::None) return throwTypeError(exec, scope); MarkedArgumentBuffer nextFunctionArguments; if (!argument.isEmpty()) nextFunctionArguments.append(argument); ASSERT(!nextFunctionArguments.hasOverflowed()); JSValue result = call(exec, nextFunction, nextFunctionCallType, nextFunctionCallData, iterator, nextFunctionArguments); RETURN_IF_EXCEPTION(scope, JSValue()); if (!result.isObject()) return throwTypeError(exec, scope, "Iterator result interface is not an object."_s); return result; }
SpeculatedType speculationFromValue(JSValue value) { if (value.isEmpty()) return SpecEmpty; if (value.isInt32()) return SpecInt32; if (value.isDouble()) { double number = value.asNumber(); if (number == number) { int64_t asInt64 = static_cast<int64_t>(number); if (asInt64 == number && (asInt64 || !std::signbit(number)) && asInt64 < (static_cast<int64_t>(1) << 47) && asInt64 >= -(static_cast<int64_t>(1) << 47)) { return SpecInt48AsDouble; } return SpecNonIntAsDouble; } return SpecDoubleNaN; } if (value.isCell()) return speculationFromCell(value.asCell()); if (value.isBoolean()) return SpecBoolean; ASSERT(value.isUndefinedOrNull()); return SpecOther; }
void setJSTestInterfaceConstructorSupplementalStaticAttr(ExecState* exec, JSObject*, JSValue value) { UNUSED_PARAM(exec); const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec)); if (exec->hadException()) return; TestSupplemental::setSupplementalStaticAttr(nativeValue); }
void setJSTestInterfaceConstructorImplementsStaticAttr(ExecState* exec, JSObject* /* baseObject */, EncodedJSValue, EncodedJSValue encodedValue) { JSValue value = JSValue::decode(encodedValue); UNUSED_PARAM(exec); const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec)); if (exec->hadException()) return; TestInterface::setImplementsStaticAttr(nativeValue); }
void setJSTestInterfaceImplementsStr2(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); JSTestInterface* castedThis = jsCast<JSTestInterface*>(thisObject); TestInterface& impl = castedThis->impl(); const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec)); if (exec->hadException()) return; impl.setImplementsStr2(nativeValue); }
void setJSTestTypedefsStringAttrWithGetterException(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(thisObject); TestTypedefs& impl = castedThis->impl(); const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec)); if (exec->hadException()) return; impl.setStringAttrWithGetterException(nativeValue); }
void setJSTestInterfaceSupplementalStr2(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); JSTestInterface* castedThis = jsCast<JSTestInterface*>(thisObject); TestInterface* impl = static_cast<TestInterface*>(castedThis->impl()); const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec)); if (exec->hadException()) return; TestSupplemental::setSupplementalStr2(impl, nativeValue); }
void JSTextTrack::setLanguage(ExecState* exec, JSValue value) { UNUSED_PARAM(exec); #if ENABLE(MEDIA_SOURCE) const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec)); if (exec->hadException()) return; impl().setLanguage(nativeValue); #else UNUSED_PARAM(value); return; #endif }
JSValue JSHistory::state(ExecState *exec) const { History* history = static_cast<History*>(impl()); JSValue cachedValue = m_state.get(); if (!cachedValue.isEmpty() && !history->stateChanged()) return cachedValue; RefPtr<SerializedScriptValue> serialized = history->state(); JSValue result = serialized ? serialized->deserialize(exec, globalObject(), 0) : jsNull(); const_cast<JSHistory*>(this)->m_state.set(exec->vm(), this, result); return result; }
void setJSTestTypedefsStringAttrWithGetterException(ExecState* exec, EncodedJSValue thisValue, EncodedJSValue encodedValue) { JSValue value = JSValue::decode(encodedValue); UNUSED_PARAM(exec); JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue)); if (!castedThis) { throwVMTypeError(exec); return; } TestTypedefs& impl = castedThis->impl(); const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec)); if (exec->hadException()) return; impl.setStringAttrWithGetterException(nativeValue); }
void setJSTestInterfaceSupplementalStr2(ExecState* exec, JSObject* /* baseObject */, EncodedJSValue thisValue, EncodedJSValue encodedValue) { JSValue value = JSValue::decode(encodedValue); UNUSED_PARAM(exec); JSTestInterface* castedThis = jsDynamicCast<JSTestInterface*>(JSValue::decode(thisValue)); if (!castedThis) { throwVMTypeError(exec); return; } TestInterface& impl = castedThis->impl(); const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec)); if (exec->hadException()) return; TestSupplemental::setSupplementalStr2(&impl, nativeValue); }
void setJSDOMSettableTokenListValue(ExecState* exec, EncodedJSValue thisValue, EncodedJSValue encodedValue) { JSValue value = JSValue::decode(encodedValue); UNUSED_PARAM(exec); JSDOMSettableTokenList* castedThis = jsDynamicCast<JSDOMSettableTokenList*>(JSValue::decode(thisValue)); if (!castedThis) { throwVMTypeError(exec); return; } DOMSettableTokenList& impl = castedThis->impl(); const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec)); if (exec->hadException()) return; impl.setValue(nativeValue); }
JSValue JSPopStateEvent::state(ExecState* exec) const { JSValue cachedValue = m_state.get(); if (!cachedValue.isEmpty()) { // We cannot use a cached object if we are in a different world than the one it was created in. if (!cachedValue.isObject() || &worldForDOMObject(cachedValue.getObject()) == ¤tWorld(exec)) return cachedValue; ASSERT_NOT_REACHED(); } PopStateEvent& event = impl(); if (!event.state().hasNoValue()) { // We need to make sure a PopStateEvent does not leak objects in its state property across isolated DOM worlds. // Ideally, we would check that the worlds have different privileges but that's not possible yet. JSValue state = event.state().jsValue(); if (state.isObject() && &worldForDOMObject(state.getObject()) != ¤tWorld(exec)) { if (RefPtr<SerializedScriptValue> serializedValue = event.trySerializeState(exec)) state = serializedValue->deserialize(exec, globalObject(), nullptr); else state = jsNull(); } return cacheState(exec, const_cast<JSPopStateEvent*>(this), state); } History* history = event.history(); if (!history || !event.serializedState()) return cacheState(exec, const_cast<JSPopStateEvent*>(this), jsNull()); // There's no cached value from a previous invocation, nor a state value was provided by the // event, but there is a history object, so first we need to see if the state object has been // deserialized through the history object already. // The current history state object might've changed in the meantime, so we need to take care // of using the correct one, and always share the same deserialization with history.state. bool isSameState = history->isSameAsCurrentState(event.serializedState().get()); JSValue result; if (isSameState) { JSHistory* jsHistory = jsCast<JSHistory*>(toJS(exec, globalObject(), history).asCell()); result = jsHistory->state(exec); } else result = event.serializedState()->deserialize(exec, globalObject(), 0); return cacheState(exec, const_cast<JSPopStateEvent*>(this), result); }
void setJSAudioNodeChannelInterpretation(ExecState* exec, EncodedJSValue thisValue, EncodedJSValue encodedValue) { JSValue value = JSValue::decode(encodedValue); UNUSED_PARAM(exec); JSAudioNode* castedThis = jsDynamicCast<JSAudioNode*>(JSValue::decode(thisValue)); if (!castedThis) { throwVMTypeError(exec); return; } AudioNode& impl = castedThis->impl(); ExceptionCode ec = 0; const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec)); if (exec->hadException()) return; impl.setChannelInterpretation(nativeValue, ec); setDOMException(exec, ec); }
void setJSTestTypedefsStringAttrWithGetterException(ExecState* exec, JSObject* baseObject, EncodedJSValue thisValue, EncodedJSValue encodedValue) { JSValue value = JSValue::decode(encodedValue); UNUSED_PARAM(baseObject); JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue)); if (UNLIKELY(!castedThis)) { if (jsDynamicCast<JSTestTypedefsPrototype*>(JSValue::decode(thisValue))) reportDeprecatedSetterError(*exec, "TestTypedefs", "stringAttrWithGetterException"); else throwSetterTypeError(*exec, "TestTypedefs", "stringAttrWithGetterException"); return; } auto& impl = castedThis->impl(); const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec)); if (UNLIKELY(exec->hadException())) return; impl.setStringAttrWithGetterException(nativeValue); }
void setJSTestNondeterministicNondeterministicExceptionAttr(ExecState* exec, JSObject* baseObject, EncodedJSValue thisValue, EncodedJSValue encodedValue) { JSValue value = JSValue::decode(encodedValue); UNUSED_PARAM(baseObject); JSTestNondeterministic* castedThis = jsDynamicCast<JSTestNondeterministic*>(JSValue::decode(thisValue)); if (UNLIKELY(!castedThis)) { if (jsDynamicCast<JSTestNondeterministicPrototype*>(JSValue::decode(thisValue))) reportDeprecatedSetterError(*exec, "TestNondeterministic", "nondeterministicExceptionAttr"); else throwSetterTypeError(*exec, "TestNondeterministic", "nondeterministicExceptionAttr"); return; } TestNondeterministic& impl = castedThis->impl(); const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec)); if (UNLIKELY(exec->hadException())) return; impl.setNondeterministicExceptionAttr(nativeValue); }
void setJSWaveShaperNodeOversample(ExecState* exec, EncodedJSValue thisValue, EncodedJSValue encodedValue) { JSValue value = JSValue::decode(encodedValue); UNUSED_PARAM(exec); JSWaveShaperNode* castedThis = jsDynamicCast<JSWaveShaperNode*>(JSValue::decode(thisValue)); if (!castedThis) { throwVMTypeError(exec); return; } WaveShaperNode& impl = castedThis->impl(); ExceptionCode ec = 0; const String nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec)); if (exec->hadException()) return; if (nativeValue != "none" && nativeValue != "2x" && nativeValue != "4x") return; impl.setOversample(nativeValue, ec); setDOMException(exec, ec); }
PredictedType predictionFromValue(JSValue value) { if (value.isEmpty()) return PredictEmpty; if (value.isInt32()) return PredictInt32; if (value.isDouble()) { double number = value.asNumber(); if (number == number) return PredictDoubleReal; return PredictDoubleNaN; } if (value.isCell()) return predictionFromCell(value.asCell()); if (value.isBoolean()) return PredictBoolean; ASSERT(value.isUndefinedOrNull()); return PredictOther; }
SpeculatedType speculationFromValue(JSValue value) { if (value.isEmpty()) return SpecEmpty; if (value.isInt32()) return SpecInt32; if (value.isDouble()) { double number = value.asNumber(); if (number != number) return SpecDoubleNaN; if (value.isMachineInt()) return SpecInt52AsDouble; return SpecNonIntAsDouble; } if (value.isCell()) return speculationFromCell(value.asCell()); if (value.isBoolean()) return SpecBoolean; ASSERT(value.isUndefinedOrNull()); return SpecOther; }
JSValue iteratorNext(ExecState* exec, JSValue iterator, JSValue value) { JSValue nextFunction = iterator.get(exec, exec->vm().propertyNames->next); if (exec->hadException()) return jsUndefined(); CallData nextFunctionCallData; CallType nextFunctionCallType = getCallData(nextFunction, nextFunctionCallData); if (nextFunctionCallType == CallType::None) return throwTypeError(exec); MarkedArgumentBuffer nextFunctionArguments; if (!value.isEmpty()) nextFunctionArguments.append(value); JSValue result = call(exec, nextFunction, nextFunctionCallType, nextFunctionCallData, iterator, nextFunctionArguments); if (exec->hadException()) return jsUndefined(); if (!result.isObject()) return throwTypeError(exec, ASCIILiteral("Iterator result interface is not an object.")); return result; }
JSValue iteratorNext(ExecState* exec, JSValue iterator, JSValue value) { VM& vm = exec->vm(); auto scope = DECLARE_THROW_SCOPE(vm); JSValue nextFunction = iterator.get(exec, vm.propertyNames->next); RETURN_IF_EXCEPTION(scope, JSValue()); CallData nextFunctionCallData; CallType nextFunctionCallType = getCallData(nextFunction, nextFunctionCallData); if (nextFunctionCallType == CallType::None) return throwTypeError(exec, scope); MarkedArgumentBuffer nextFunctionArguments; if (!value.isEmpty()) nextFunctionArguments.append(value); JSValue result = call(exec, nextFunction, nextFunctionCallType, nextFunctionCallData, iterator, nextFunctionArguments); RETURN_IF_EXCEPTION(scope, JSValue()); if (!result.isObject()) return throwTypeError(exec, scope, ASCIILiteral("Iterator result interface is not an object.")); return result; }
void setJSTestInterfaceSupplementalStr2(ExecState* exec, JSObject* thisObject, JSValue value) { JSTestInterface* castedThis = static_cast<JSTestInterface*>(thisObject); TestInterface* impl = static_cast<TestInterface*>(castedThis->impl()); TestSupplemental::setSupplementalStr2(impl, ustringToString(value.isEmpty() ? UString() : value.toString(exec)->value(exec))); }