mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:57:44 +00:00
LibJS: Convert create_data_property_or_throw() to ThrowCompletionOr
This commit is contained in:
parent
bb2499cd7a
commit
364dd42fc8
30 changed files with 148 additions and 167 deletions
|
@ -1082,7 +1082,7 @@ ThrowCompletionOr<Object*> prepare_temporal_fields(GlobalObject& global_object,
|
|||
}
|
||||
|
||||
// d. Perform ! CreateDataPropertyOrThrow(result, property, value).
|
||||
result->create_data_property_or_throw(property, value);
|
||||
MUST(result->create_data_property_or_throw(property, value));
|
||||
}
|
||||
|
||||
// 4. Return result.
|
||||
|
|
|
@ -957,7 +957,7 @@ ThrowCompletionOr<Object*> default_merge_fields(GlobalObject& global_object, Obj
|
|||
// ii. If propValue is not undefined, then
|
||||
if (!prop_value.is_undefined()) {
|
||||
// 1. Perform ! CreateDataPropertyOrThrow(merged, nextKey, propValue).
|
||||
merged->create_data_property_or_throw(property_name, prop_value);
|
||||
MUST(merged->create_data_property_or_throw(property_name, prop_value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -980,7 +980,7 @@ ThrowCompletionOr<Object*> default_merge_fields(GlobalObject& global_object, Obj
|
|||
// b. If propValue is not undefined, then
|
||||
if (!prop_value.is_undefined()) {
|
||||
// i. Perform ! CreateDataPropertyOrThrow(merged, nextKey, propValue).
|
||||
merged->create_data_property_or_throw(property_name, prop_value);
|
||||
MUST(merged->create_data_property_or_throw(property_name, prop_value));
|
||||
}
|
||||
|
||||
// See comment above.
|
||||
|
@ -995,7 +995,7 @@ ThrowCompletionOr<Object*> default_merge_fields(GlobalObject& global_object, Obj
|
|||
// b. If month is not undefined, then
|
||||
if (!month.is_undefined()) {
|
||||
// i. Perform ! CreateDataPropertyOrThrow(merged, "month", month).
|
||||
merged->create_data_property_or_throw(vm.names.month, month);
|
||||
MUST(merged->create_data_property_or_throw(vm.names.month, month));
|
||||
}
|
||||
|
||||
// c. Let monthCode be ? Get(fields, "monthCode").
|
||||
|
@ -1004,7 +1004,7 @@ ThrowCompletionOr<Object*> default_merge_fields(GlobalObject& global_object, Obj
|
|||
// d. If monthCode is not undefined, then
|
||||
if (!month_code.is_undefined()) {
|
||||
// i. Perform ! CreateDataPropertyOrThrow(merged, "monthCode", monthCode).
|
||||
merged->create_data_property_or_throw(vm.names.monthCode, month_code);
|
||||
MUST(merged->create_data_property_or_throw(vm.names.monthCode, month_code));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -356,16 +356,16 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::get_iso_fields)
|
|||
auto* fields = Object::create(global_object, global_object.object_prototype());
|
||||
|
||||
// 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", temporalDate.[[Calendar]]).
|
||||
fields->create_data_property_or_throw(vm.names.calendar, Value(&temporal_date->calendar()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&temporal_date->calendar())));
|
||||
|
||||
// 5. Perform ! CreateDataPropertyOrThrow(fields, "isoDay", 𝔽(temporalDate.[[ISODay]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoDay, Value(temporal_date->iso_day()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoDay, Value(temporal_date->iso_day())));
|
||||
|
||||
// 6. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", 𝔽(temporalDate.[[ISOMonth]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoMonth, Value(temporal_date->iso_month()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoMonth, Value(temporal_date->iso_month())));
|
||||
|
||||
// 7. Perform ! CreateDataPropertyOrThrow(fields, "isoYear", 𝔽(temporalDate.[[ISOYear]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoYear, Value(temporal_date->iso_year()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoYear, Value(temporal_date->iso_year())));
|
||||
|
||||
// 8. Return fields.
|
||||
return fields;
|
||||
|
|
|
@ -553,34 +553,34 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::get_iso_fields)
|
|||
auto* fields = Object::create(global_object, global_object.object_prototype());
|
||||
|
||||
// 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", dateTime.[[Calendar]]).
|
||||
fields->create_data_property_or_throw(vm.names.calendar, Value(&date_time->calendar()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&date_time->calendar())));
|
||||
|
||||
// 5. Perform ! CreateDataPropertyOrThrow(fields, "isoDay", 𝔽(dateTime.[[ISODay]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoDay, Value(date_time->iso_day()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoDay, Value(date_time->iso_day())));
|
||||
|
||||
// 6. Perform ! CreateDataPropertyOrThrow(fields, "isoHour", 𝔽(dateTime.[[ISOHour]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoHour, Value(date_time->iso_hour()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoHour, Value(date_time->iso_hour())));
|
||||
|
||||
// 7. Perform ! CreateDataPropertyOrThrow(fields, "isoMicrosecond", 𝔽(dateTime.[[ISOMicrosecond]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoMicrosecond, Value(date_time->iso_microsecond()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoMicrosecond, Value(date_time->iso_microsecond())));
|
||||
|
||||
// 8. Perform ! CreateDataPropertyOrThrow(fields, "isoMillisecond", 𝔽(dateTime.[[ISOMillisecond]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoMillisecond, Value(date_time->iso_millisecond()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoMillisecond, Value(date_time->iso_millisecond())));
|
||||
|
||||
// 9. Perform ! CreateDataPropertyOrThrow(fields, "isoMinute", 𝔽(dateTime.[[ISOMinute]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoMinute, Value(date_time->iso_minute()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoMinute, Value(date_time->iso_minute())));
|
||||
|
||||
// 10. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", 𝔽(dateTime.[[ISOMonth]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoMonth, Value(date_time->iso_month()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoMonth, Value(date_time->iso_month())));
|
||||
|
||||
// 11. Perform ! CreateDataPropertyOrThrow(fields, "isoNanosecond", 𝔽(dateTime.[[ISONanosecond]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoNanosecond, Value(date_time->iso_nanosecond()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoNanosecond, Value(date_time->iso_nanosecond())));
|
||||
|
||||
// 12. Perform ! CreateDataPropertyOrThrow(fields, "isoSecond", 𝔽(dateTime.[[ISOSecond]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoSecond, Value(date_time->iso_second()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoSecond, Value(date_time->iso_second())));
|
||||
|
||||
// 13. Perform ! CreateDataPropertyOrThrow(fields, "isoYear", 𝔽(dateTime.[[ISOYear]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoYear, Value(date_time->iso_year()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoYear, Value(date_time->iso_year())));
|
||||
|
||||
// 14. Return fields.
|
||||
return fields;
|
||||
|
|
|
@ -111,7 +111,7 @@ ThrowCompletionOr<PlainMonthDay*> to_temporal_month_day(GlobalObject& global_obj
|
|||
// i. If calendarAbsent is true, and month is not undefined, and monthCode is undefined and year is undefined, then
|
||||
if (calendar_absent && !month.is_undefined() && month_code.is_undefined() && year.is_undefined()) {
|
||||
// i. Perform ! CreateDataPropertyOrThrow(fields, "year", 𝔽(referenceISOYear)).
|
||||
fields->create_data_property_or_throw(vm.names.year, Value(reference_iso_year));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.year, Value(reference_iso_year)));
|
||||
}
|
||||
|
||||
// j. Return ? MonthDayFromFields(calendar, fields, options).
|
||||
|
|
|
@ -181,16 +181,16 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::get_iso_fields)
|
|||
auto* fields = Object::create(global_object, global_object.object_prototype());
|
||||
|
||||
// 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", monthDay.[[Calendar]]).
|
||||
fields->create_data_property_or_throw(vm.names.calendar, Value(&month_day->calendar()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&month_day->calendar())));
|
||||
|
||||
// 5. Perform ! CreateDataPropertyOrThrow(fields, "isoDay", 𝔽(monthDay.[[ISODay]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoDay, Value(month_day->iso_day()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoDay, Value(month_day->iso_day())));
|
||||
|
||||
// 6. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", 𝔽(monthDay.[[ISOMonth]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoMonth, Value(month_day->iso_month()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoMonth, Value(month_day->iso_month())));
|
||||
|
||||
// 7. Perform ! CreateDataPropertyOrThrow(fields, "isoYear", 𝔽(monthDay.[[ISOYear]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoYear, Value(month_day->iso_year()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoYear, Value(month_day->iso_year())));
|
||||
|
||||
// 8. Return fields.
|
||||
return fields;
|
||||
|
|
|
@ -303,25 +303,25 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::get_iso_fields)
|
|||
auto* fields = Object::create(global_object, global_object.object_prototype());
|
||||
|
||||
// 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", temporalTime.[[Calendar]]).
|
||||
fields->create_data_property_or_throw(vm.names.calendar, Value(&temporal_time->calendar()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&temporal_time->calendar())));
|
||||
|
||||
// 5. Perform ! CreateDataPropertyOrThrow(fields, "isoHour", 𝔽(temporalTime.[[ISOHour]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoHour, Value(temporal_time->iso_hour()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoHour, Value(temporal_time->iso_hour())));
|
||||
|
||||
// 6. Perform ! CreateDataPropertyOrThrow(fields, "isoMicrosecond", 𝔽(temporalTime.[[ISOMicrosecond]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoMicrosecond, Value(temporal_time->iso_microsecond()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoMicrosecond, Value(temporal_time->iso_microsecond())));
|
||||
|
||||
// 7. Perform ! CreateDataPropertyOrThrow(fields, "isoMillisecond", 𝔽(temporalTime.[[ISOMillisecond]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoMillisecond, Value(temporal_time->iso_millisecond()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoMillisecond, Value(temporal_time->iso_millisecond())));
|
||||
|
||||
// 8. Perform ! CreateDataPropertyOrThrow(fields, "isoMinute", 𝔽(temporalTime.[[ISOMinute]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoMinute, Value(temporal_time->iso_minute()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoMinute, Value(temporal_time->iso_minute())));
|
||||
|
||||
// 9. Perform ! CreateDataPropertyOrThrow(fields, "isoNanosecond", 𝔽(temporalTime.[[ISONanosecond]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoNanosecond, Value(temporal_time->iso_nanosecond()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoNanosecond, Value(temporal_time->iso_nanosecond())));
|
||||
|
||||
// 10. Perform ! CreateDataPropertyOrThrow(fields, "isoSecond", 𝔽(temporalTime.[[ISOSecond]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoSecond, Value(temporal_time->iso_second()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoSecond, Value(temporal_time->iso_second())));
|
||||
|
||||
// 11. Return fields.
|
||||
return fields;
|
||||
|
|
|
@ -302,16 +302,16 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::get_iso_fields)
|
|||
auto* fields = Object::create(global_object, global_object.object_prototype());
|
||||
|
||||
// 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", yearMonth.[[Calendar]]).
|
||||
fields->create_data_property_or_throw(vm.names.calendar, Value(&year_month->calendar()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&year_month->calendar())));
|
||||
|
||||
// 5. Perform ! CreateDataPropertyOrThrow(fields, "isoDay", 𝔽(yearMonth.[[ISODay]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoDay, Value(year_month->iso_day()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoDay, Value(year_month->iso_day())));
|
||||
|
||||
// 6. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", 𝔽(yearMonth.[[ISOMonth]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoMonth, Value(year_month->iso_month()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoMonth, Value(year_month->iso_month())));
|
||||
|
||||
// 7. Perform ! CreateDataPropertyOrThrow(fields, "isoYear", 𝔽(yearMonth.[[ISOYear]])).
|
||||
fields->create_data_property_or_throw(vm.names.isoYear, Value(year_month->iso_year()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoYear, Value(year_month->iso_year())));
|
||||
|
||||
// 8. Return fields.
|
||||
return fields;
|
||||
|
|
|
@ -887,40 +887,40 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::get_iso_fields)
|
|||
auto offset = TRY_OR_DISCARD(builtin_time_zone_get_offset_string_for(global_object, &time_zone, *instant));
|
||||
|
||||
// 9. Perform ! CreateDataPropertyOrThrow(fields, "calendar", calendar).
|
||||
fields->create_data_property_or_throw(vm.names.calendar, Value(&calendar));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&calendar)));
|
||||
|
||||
// 10. Perform ! CreateDataPropertyOrThrow(fields, "isoDay", dateTime.[[ISODay]]).
|
||||
fields->create_data_property_or_throw(vm.names.isoDay, Value(date_time->iso_day()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoDay, Value(date_time->iso_day())));
|
||||
|
||||
// 11. Perform ! CreateDataPropertyOrThrow(fields, "isoHour", dateTime.[[ISOHour]]).
|
||||
fields->create_data_property_or_throw(vm.names.isoHour, Value(date_time->iso_hour()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoHour, Value(date_time->iso_hour())));
|
||||
|
||||
// 12. Perform ! CreateDataPropertyOrThrow(fields, "isoMicrosecond", dateTime.[[ISOMicrosecond]]).
|
||||
fields->create_data_property_or_throw(vm.names.isoMicrosecond, Value(date_time->iso_microsecond()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoMicrosecond, Value(date_time->iso_microsecond())));
|
||||
|
||||
// 13. Perform ! CreateDataPropertyOrThrow(fields, "isoMillisecond", dateTime.[[ISOMillisecond]]).
|
||||
fields->create_data_property_or_throw(vm.names.isoMillisecond, Value(date_time->iso_millisecond()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoMillisecond, Value(date_time->iso_millisecond())));
|
||||
|
||||
// 14. Perform ! CreateDataPropertyOrThrow(fields, "isoMinute", dateTime.[[ISOMinute]]).
|
||||
fields->create_data_property_or_throw(vm.names.isoMinute, Value(date_time->iso_minute()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoMinute, Value(date_time->iso_minute())));
|
||||
|
||||
// 15. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", dateTime.[[ISOMonth]]).
|
||||
fields->create_data_property_or_throw(vm.names.isoMonth, Value(date_time->iso_month()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoMonth, Value(date_time->iso_month())));
|
||||
|
||||
// 16. Perform ! CreateDataPropertyOrThrow(fields, "isoNanosecond", dateTime.[[ISONanosecond]]).
|
||||
fields->create_data_property_or_throw(vm.names.isoNanosecond, Value(date_time->iso_nanosecond()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoNanosecond, Value(date_time->iso_nanosecond())));
|
||||
|
||||
// 17. Perform ! CreateDataPropertyOrThrow(fields, "isoSecond", dateTime.[[ISOSecond]]).
|
||||
fields->create_data_property_or_throw(vm.names.isoSecond, Value(date_time->iso_second()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoSecond, Value(date_time->iso_second())));
|
||||
|
||||
// 18. Perform ! CreateDataPropertyOrThrow(fields, "isoYear", dateTime.[[ISOYear]]).
|
||||
fields->create_data_property_or_throw(vm.names.isoYear, Value(date_time->iso_year()));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.isoYear, Value(date_time->iso_year())));
|
||||
|
||||
// 19. Perform ! CreateDataPropertyOrThrow(fields, "offset", offset).
|
||||
fields->create_data_property_or_throw(vm.names.offset, js_string(vm, offset));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.offset, js_string(vm, offset)));
|
||||
|
||||
// 20. Perform ! CreateDataPropertyOrThrow(fields, "timeZone", timeZone).
|
||||
fields->create_data_property_or_throw(vm.names.timeZone, Value(&time_zone));
|
||||
MUST(fields->create_data_property_or_throw(vm.names.timeZone, Value(&time_zone)));
|
||||
|
||||
// 21. Return fields.
|
||||
return fields;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue