mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
LibJS: Remove unnecessary value_or() from get()
Object::get() never returns an empty value anymore, as per the spec, so having a value_or() fallback is no longer needed.
This commit is contained in:
parent
57f7e6e775
commit
9555ca99a0
Notes:
sideshowbarker
2024-07-18 10:25:40 +09:00
Author: https://github.com/linusg
Commit: 9555ca99a0
Pull-request: https://github.com/SerenityOS/serenity/pull/8442
Reviewed-by: https://github.com/IdanHo ✅
19 changed files with 56 additions and 56 deletions
|
@ -884,7 +884,7 @@ Value ClassExpression::execute(Interpreter& interpreter, GlobalObject& global_ob
|
|||
|
||||
Object* super_constructor_prototype = nullptr;
|
||||
if (!super_constructor.is_null()) {
|
||||
auto super_constructor_prototype_value = super_constructor.as_object().get(vm.names.prototype).value_or(js_undefined());
|
||||
auto super_constructor_prototype_value = super_constructor.as_object().get(vm.names.prototype);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
if (!super_constructor_prototype_value.is_object() && !super_constructor_prototype_value.is_null()) {
|
||||
|
|
|
@ -228,7 +228,7 @@ void SetVariable::execute_impl(Bytecode::Interpreter& interpreter) const
|
|||
void GetById::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
if (auto* object = interpreter.accumulator().to_object(interpreter.global_object()))
|
||||
interpreter.accumulator() = object->get(interpreter.current_executable().get_string(m_property)).value_or(js_undefined());
|
||||
interpreter.accumulator() = object->get(interpreter.current_executable().get_string(m_property));
|
||||
}
|
||||
|
||||
void PutById::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
|
@ -417,7 +417,7 @@ void GetByValue::execute_impl(Bytecode::Interpreter& interpreter) const
|
|||
auto property_key = interpreter.accumulator().to_property_key(interpreter.global_object());
|
||||
if (interpreter.vm().exception())
|
||||
return;
|
||||
interpreter.accumulator() = object->get(property_key).value_or(js_undefined());
|
||||
interpreter.accumulator() = object->get(property_key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ Value require_object_coercible(GlobalObject& global_object, Value value)
|
|||
size_t length_of_array_like(GlobalObject& global_object, Object const& object)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto result = object.get(vm.names.length).value_or(js_undefined());
|
||||
auto result = object.get(vm.names.length);
|
||||
if (vm.exception())
|
||||
return INVALID;
|
||||
return result.to_length(global_object);
|
||||
|
@ -71,7 +71,7 @@ MarkedValueList create_list_from_array_like(GlobalObject& global_object, Value v
|
|||
auto list = MarkedValueList { heap };
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
auto index_name = String::number(i);
|
||||
auto next = array_like.get(index_name).value_or(js_undefined());
|
||||
auto next = array_like.get(index_name);
|
||||
if (vm.exception())
|
||||
return MarkedValueList { heap };
|
||||
if (check_value) {
|
||||
|
@ -90,7 +90,7 @@ MarkedValueList create_list_from_array_like(GlobalObject& global_object, Value v
|
|||
FunctionObject* species_constructor(GlobalObject& global_object, Object const& object, FunctionObject& default_constructor)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto constructor = object.get(vm.names.constructor).value_or(js_undefined());
|
||||
auto constructor = object.get(vm.names.constructor);
|
||||
if (vm.exception())
|
||||
return nullptr;
|
||||
if (constructor.is_undefined())
|
||||
|
@ -99,7 +99,7 @@ FunctionObject* species_constructor(GlobalObject& global_object, Object const& o
|
|||
vm.throw_exception<TypeError>(global_object, ErrorType::NotAConstructor, constructor.to_string_without_side_effects());
|
||||
return nullptr;
|
||||
}
|
||||
auto species = constructor.as_object().get(*vm.well_known_symbol_species()).value_or(js_undefined());
|
||||
auto species = constructor.as_object().get(*vm.well_known_symbol_species());
|
||||
if (species.is_nullish())
|
||||
return &default_constructor;
|
||||
if (species.is_constructor())
|
||||
|
|
|
@ -108,7 +108,7 @@ static Object* array_species_create(GlobalObject& global_object, Object& origina
|
|||
return array;
|
||||
}
|
||||
|
||||
auto constructor = original_array.get(vm.names.constructor).value_or(js_undefined());
|
||||
auto constructor = original_array.get(vm.names.constructor);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (constructor.is_constructor()) {
|
||||
|
@ -123,7 +123,7 @@ static Object* array_species_create(GlobalObject& global_object, Object& origina
|
|||
}
|
||||
|
||||
if (constructor.is_object()) {
|
||||
constructor = constructor.as_object().get(*vm.well_known_symbol_species()).value_or(js_undefined());
|
||||
constructor = constructor.as_object().get(*vm.well_known_symbol_species());
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (constructor.is_null())
|
||||
|
@ -396,7 +396,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::unshift)
|
|||
if (vm.exception())
|
||||
return {};
|
||||
if (from_present) {
|
||||
auto from_value = this_object->get(from).value_or(js_undefined());
|
||||
auto from_value = this_object->get(from);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
this_object->define_property(to, from_value);
|
||||
|
@ -442,7 +442,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::pop)
|
|||
return js_undefined();
|
||||
}
|
||||
auto index = length - 1;
|
||||
auto element = this_object->get(index).value_or(js_undefined());
|
||||
auto element = this_object->get(index);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
this_object->delete_property_or_throw(index);
|
||||
|
@ -469,7 +469,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::shift)
|
|||
return {};
|
||||
return js_undefined();
|
||||
}
|
||||
auto first = this_object->get(0).value_or(js_undefined());
|
||||
auto first = this_object->get(0);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
|
@ -480,7 +480,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::shift)
|
|||
if (vm.exception())
|
||||
return {};
|
||||
if (from_present) {
|
||||
auto from_value = this_object->get(from).value_or(js_undefined());
|
||||
auto from_value = this_object->get(from);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
this_object->define_property(to, from_value);
|
||||
|
@ -540,7 +540,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_locale_string)
|
|||
for (size_t i = 0; i < length; ++i) {
|
||||
if (i > 0)
|
||||
builder.append(separator);
|
||||
auto value = this_object->get(i).value_or(js_undefined());
|
||||
auto value = this_object->get(i);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (value.is_nullish())
|
||||
|
@ -589,7 +589,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::join)
|
|||
for (size_t i = 0; i < length; ++i) {
|
||||
if (i > 0)
|
||||
builder.append(separator);
|
||||
auto value = this_object->get(i).value_or(js_undefined());
|
||||
auto value = this_object->get(i);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (value.is_nullish())
|
||||
|
@ -625,7 +625,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::concat)
|
|||
if (vm.exception())
|
||||
return false;
|
||||
|
||||
auto spreadable = object->get(*vm.well_known_symbol_is_concat_spreadable()).value_or(js_undefined());
|
||||
auto spreadable = object->get(*vm.well_known_symbol_is_concat_spreadable());
|
||||
if (vm.exception())
|
||||
return false;
|
||||
|
||||
|
@ -1075,7 +1075,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reverse)
|
|||
return {};
|
||||
Value lower_value;
|
||||
if (lower_exists) {
|
||||
lower_value = this_object->get(lower).value_or(js_undefined());
|
||||
lower_value = this_object->get(lower);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
}
|
||||
|
@ -1085,7 +1085,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reverse)
|
|||
return {};
|
||||
Value upper_value;
|
||||
if (upper_exists) {
|
||||
upper_value = this_object->get(upper).value_or(js_undefined());
|
||||
upper_value = this_object->get(upper);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
}
|
||||
|
@ -1386,7 +1386,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::includes)
|
|||
}
|
||||
auto value_to_find = vm.argument(0);
|
||||
for (i32 i = from_index; i < length; ++i) {
|
||||
auto element = this_object->get(i).value_or(js_undefined());
|
||||
auto element = this_object->get(i);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (same_value_zero(element, value_to_find))
|
||||
|
@ -1818,7 +1818,7 @@ static size_t flatten_into_array(GlobalObject& global_object, Object& new_array,
|
|||
|
||||
if (!value_exists)
|
||||
continue;
|
||||
auto value = array.get(j).value_or(js_undefined());
|
||||
auto value = array.get(j);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
|
@ -1981,7 +1981,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::copy_within)
|
|||
return {};
|
||||
|
||||
if (from_present) {
|
||||
auto from_value = this_object->get(from_i).value_or(js_undefined());
|
||||
auto from_value = this_object->get(from_i);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
this_object->put(to_i, from_value);
|
||||
|
@ -2024,7 +2024,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::at)
|
|||
}
|
||||
if (index.has_overflow() || index.value() >= length)
|
||||
return js_undefined();
|
||||
return this_object->get(index.value()).value_or(js_undefined());
|
||||
return this_object->get(index.value());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ void Error::install_error_cause(Value options)
|
|||
auto& options_object = options.as_object();
|
||||
if (!options_object.has_property(vm.names.cause))
|
||||
return;
|
||||
auto cause = options_object.get(vm.names.cause).value_or(js_undefined());
|
||||
auto cause = options_object.get(vm.names.cause);
|
||||
if (vm.exception())
|
||||
return;
|
||||
define_property(vm.names.cause, cause, Attribute::Writable | Attribute::Configurable);
|
||||
|
|
|
@ -40,7 +40,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string)
|
|||
auto& this_object = this_value.as_object();
|
||||
|
||||
String name = "Error";
|
||||
auto name_property = this_object.get(vm.names.name).value_or(js_undefined());
|
||||
auto name_property = this_object.get(vm.names.name);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (!name_property.is_undefined()) {
|
||||
|
@ -50,7 +50,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string)
|
|||
}
|
||||
|
||||
String message = "";
|
||||
auto message_property = this_object.get(vm.names.message).value_or(js_undefined());
|
||||
auto message_property = this_object.get(vm.names.message);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (!message_property.is_undefined()) {
|
||||
|
|
|
@ -74,7 +74,7 @@ Object* iterator_next(Object& iterator, Value value)
|
|||
bool iterator_complete(GlobalObject& global_object, Object& iterator_result)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto done = iterator_result.get(vm.names.done).value_or(js_undefined());
|
||||
auto done = iterator_result.get(vm.names.done);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
return done.to_boolean();
|
||||
|
@ -84,7 +84,7 @@ bool iterator_complete(GlobalObject& global_object, Object& iterator_result)
|
|||
Value iterator_value(GlobalObject& global_object, Object& iterator_result)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto value = iterator_result.get(vm.names.value).value_or(js_undefined());
|
||||
auto value = iterator_result.get(vm.names.value);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
return value;
|
||||
|
|
|
@ -146,7 +146,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::stringify)
|
|||
String JSONObject::serialize_json_property(GlobalObject& global_object, StringifyState& state, const PropertyName& key, Object* holder)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto value = holder->get(key).value_or(js_undefined());
|
||||
auto value = holder->get(key);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (value.is_object() || value.is_bigint()) {
|
||||
|
@ -479,7 +479,7 @@ Array* JSONObject::parse_json_array(GlobalObject& global_object, const JsonArray
|
|||
Value JSONObject::internalize_json_property(GlobalObject& global_object, Object* holder, PropertyName const& name, FunctionObject& reviver)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto value = holder->get(name).value_or(js_undefined());
|
||||
auto value = holder->get(name);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (value.is_object()) {
|
||||
|
|
|
@ -70,10 +70,10 @@ Value MapConstructor::construct(FunctionObject& new_target)
|
|||
vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject, String::formatted("Iterator value {}", iterator_value.to_string_without_side_effects()));
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
auto key = iterator_value.as_object().get(0).value_or(js_undefined());
|
||||
auto key = iterator_value.as_object().get(0);
|
||||
if (vm.exception())
|
||||
return IterationDecision::Break;
|
||||
auto value = iterator_value.as_object().get(1).value_or(js_undefined());
|
||||
auto value = iterator_value.as_object().get(1);
|
||||
if (vm.exception())
|
||||
return IterationDecision::Break;
|
||||
(void)vm.call(adder.as_function(), Value(map), key, value);
|
||||
|
|
|
@ -1216,7 +1216,7 @@ Value Object::ordinary_to_primitive(Value::PreferredType preferred_type) const
|
|||
Value Object::invoke_internal(const StringOrSymbol& property_name, Optional<MarkedValueList> arguments)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto property = get(property_name).value_or(js_undefined());
|
||||
auto property = get(property_name);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (!property.is_function()) {
|
||||
|
|
|
@ -254,10 +254,10 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::from_entries)
|
|||
vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject, String::formatted("Iterator value {}", iterator_value.to_string_without_side_effects()));
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
auto key = iterator_value.as_object().get(0).value_or(js_undefined());
|
||||
auto key = iterator_value.as_object().get(0);
|
||||
if (vm.exception())
|
||||
return IterationDecision::Break;
|
||||
auto value = iterator_value.as_object().get(1).value_or(js_undefined());
|
||||
auto value = iterator_value.as_object().get(1);
|
||||
if (vm.exception())
|
||||
return IterationDecision::Break;
|
||||
auto property_key = key.to_property_key(global_object);
|
||||
|
|
|
@ -22,7 +22,7 @@ Object* promise_resolve(GlobalObject& global_object, Object& constructor, Value
|
|||
{
|
||||
auto& vm = global_object.vm();
|
||||
if (value.is_object() && is<Promise>(value.as_object())) {
|
||||
auto value_constructor = value.as_object().get(vm.names.constructor).value_or(js_undefined());
|
||||
auto value_constructor = value.as_object().get(vm.names.constructor);
|
||||
if (vm.exception())
|
||||
return nullptr;
|
||||
if (same_value(value_constructor, &constructor))
|
||||
|
|
|
@ -94,7 +94,7 @@ Value Reference::get_value(GlobalObject& global_object, bool throw_if_undefined)
|
|||
auto* base_obj = m_base_value.to_object(global_object);
|
||||
if (!base_obj)
|
||||
return {};
|
||||
return base_obj->get(m_name).value_or(js_undefined());
|
||||
return base_obj->get(m_name);
|
||||
}
|
||||
|
||||
VERIFY(m_base_type == BaseType::Environment);
|
||||
|
|
|
@ -109,11 +109,11 @@ JS_DEFINE_NATIVE_GETTER(RegExpPrototype::flags)
|
|||
|
||||
StringBuilder builder(8);
|
||||
|
||||
#define __JS_ENUMERATE(flagName, flag_name, flag_char, ECMAScriptFlagName) \
|
||||
auto flag_##flag_name = this_object->get(vm.names.flagName).value_or(js_undefined()); \
|
||||
if (vm.exception()) \
|
||||
return {}; \
|
||||
if (flag_##flag_name.to_boolean()) \
|
||||
#define __JS_ENUMERATE(flagName, flag_name, flag_char, ECMAScriptFlagName) \
|
||||
auto flag_##flag_name = this_object->get(vm.names.flagName); \
|
||||
if (vm.exception()) \
|
||||
return {}; \
|
||||
if (flag_##flag_name.to_boolean()) \
|
||||
builder.append(#flag_char);
|
||||
JS_ENUMERATE_REGEXP_FLAGS
|
||||
#undef __JS_ENUMERATE
|
||||
|
@ -231,14 +231,14 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::to_string)
|
|||
if (!this_object)
|
||||
return {};
|
||||
|
||||
auto source_attr = this_object->get(vm.names.source).value_or(js_undefined());
|
||||
auto source_attr = this_object->get(vm.names.source);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto pattern = source_attr.to_string(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
auto flags_attr = this_object->get(vm.names.flags).value_or(js_undefined());
|
||||
auto flags_attr = this_object->get(vm.names.flags);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto flags = flags_attr.to_string(global_object);
|
||||
|
@ -257,7 +257,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match)
|
|||
auto s = vm.argument(0).to_string(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto global_value = rx->get(vm.names.global).value_or(js_undefined());
|
||||
auto global_value = rx->get(vm.names.global);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
bool global = global_value.to_boolean();
|
||||
|
@ -286,7 +286,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
auto global_value = rx->get(vm.names.global).value_or(js_undefined());
|
||||
auto global_value = rx->get(vm.names.global);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
|
@ -338,7 +338,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|||
size_t result_length = length_of_array_like(global_object, result);
|
||||
size_t n_captures = result_length == 0 ? 0 : result_length - 1;
|
||||
|
||||
auto matched_value = result.get(0).value_or(js_undefined());
|
||||
auto matched_value = result.get(0);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
|
@ -346,7 +346,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
auto position_value = result.get(vm.names.index).value_or(js_undefined());
|
||||
auto position_value = result.get(vm.names.index);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
|
@ -358,7 +358,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|||
|
||||
MarkedValueList captures(vm.heap());
|
||||
for (size_t n = 1; n <= n_captures; ++n) {
|
||||
auto capture = result.get(n).value_or(js_undefined());
|
||||
auto capture = result.get(n);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
|
@ -375,7 +375,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|||
captures.append(move(capture));
|
||||
}
|
||||
|
||||
auto named_captures = result.get(vm.names.groups).value_or(js_undefined());
|
||||
auto named_captures = result.get(vm.names.groups);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw)
|
|||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
auto raw_value = cooked->get(vm.names.raw).value_or(js_undefined());
|
||||
auto raw_value = cooked->get(vm.names.raw);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
|
|
|
@ -755,7 +755,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match_all)
|
|||
if (vm.exception())
|
||||
return {};
|
||||
if (is_regexp) {
|
||||
auto flags = regexp.as_object().get("flags").value_or(js_undefined());
|
||||
auto flags = regexp.as_object().get("flags");
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto flags_object = require_object_coercible(global_object, flags);
|
||||
|
|
|
@ -230,7 +230,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::join)
|
|||
for (size_t i = 0; i < length; ++i) {
|
||||
if (i > 0)
|
||||
builder.append(separator);
|
||||
auto value = typed_array->get(i).value_or(js_undefined());
|
||||
auto value = typed_array->get(i);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (value.is_nullish())
|
||||
|
|
|
@ -228,7 +228,7 @@ void VM::assign(const NonnullRefPtr<BindingPattern>& target, Value value, Global
|
|||
if (exception())
|
||||
return;
|
||||
|
||||
if (!done_property.is_empty() && done_property.to_boolean())
|
||||
if (done_property.to_boolean())
|
||||
break;
|
||||
|
||||
auto next_value = next_object->get(names.value);
|
||||
|
@ -247,7 +247,7 @@ void VM::assign(const NonnullRefPtr<BindingPattern>& target, Value value, Global
|
|||
if (exception())
|
||||
return;
|
||||
|
||||
if (!done_property.is_empty() && done_property.to_boolean()) {
|
||||
if (done_property.to_boolean()) {
|
||||
iterator = nullptr;
|
||||
value = js_undefined();
|
||||
} else {
|
||||
|
|
|
@ -68,10 +68,10 @@ Value WeakMapConstructor::construct(FunctionObject& new_target)
|
|||
vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject, String::formatted("Iterator value {}", iterator_value.to_string_without_side_effects()));
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
auto key = iterator_value.as_object().get(0).value_or(js_undefined());
|
||||
auto key = iterator_value.as_object().get(0);
|
||||
if (vm.exception())
|
||||
return IterationDecision::Break;
|
||||
auto value = iterator_value.as_object().get(1).value_or(js_undefined());
|
||||
auto value = iterator_value.as_object().get(1);
|
||||
if (vm.exception())
|
||||
return IterationDecision::Break;
|
||||
(void)vm.call(adder.as_function(), Value(weak_map), key, value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue