LibJS: Convert Object::create() to NonnullGCPtr

This commit is contained in:
Linus Groh 2022-12-13 20:49:50 +00:00
parent f990095728
commit ddc6e139a6
Notes: sideshowbarker 2024-07-17 03:17:23 +09:00
45 changed files with 80 additions and 80 deletions

View file

@ -1564,7 +1564,7 @@ static void generate_wrap_statement(SourceGenerator& generator, DeprecatedString
auto dictionary_generator = scoped_generator.fork();
dictionary_generator.append(R"~~~(
auto* dictionary_object@recursion_depth@ = JS::Object::create(realm, realm.intrinsics().object_prototype());
auto dictionary_object@recursion_depth@ = JS::Object::create(realm, realm.intrinsics().object_prototype());
)~~~");
auto* current_dictionary = &interface.dictionaries.find(type.name())->value;
@ -2467,7 +2467,7 @@ void @prototype_class@::initialize(JS::Realm& realm)
if (interface.has_unscopable_member) {
generator.append(R"~~~(
auto* unscopable_object = JS::Object::create(realm, nullptr);
auto unscopable_object = JS::Object::create(realm, nullptr);
)~~~");
}

View file

@ -1896,7 +1896,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_e
}
}
auto* prototype = Object::create(realm, proto_parent);
auto prototype = Object::create(realm, proto_parent);
VERIFY(prototype);
vm.running_execution_context().lexical_environment = class_environment;
@ -3067,7 +3067,7 @@ Completion ObjectExpression::execute(Interpreter& interpreter) const
auto& realm = *vm.current_realm();
// 1. Let obj be OrdinaryObjectCreate(%Object.prototype%).
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
auto object = Object::create(realm, realm.intrinsics().object_prototype());
// 2. Perform ? PropertyDefinitionEvaluation of PropertyDefinitionList with argument obj.
for (auto& property : m_properties) {

View file

@ -251,7 +251,7 @@ ThrowCompletionOr<void> Append::execute_impl(Bytecode::Interpreter& interpreter)
static Object* iterator_to_object(VM& vm, Iterator iterator)
{
auto& realm = *vm.current_realm();
auto* object = Object::create(realm, nullptr);
auto object = Object::create(realm, nullptr);
object->define_direct_property(vm.names.iterator, iterator.iterator, 0);
object->define_direct_property(vm.names.next, iterator.next_method, 0);
object->define_direct_property(vm.names.done, Value(iterator.done), 0);
@ -342,7 +342,7 @@ ThrowCompletionOr<void> CopyObjectExcludingProperties::execute_impl(Bytecode::In
auto* from_object = TRY(interpreter.reg(m_from_object).to_object(vm));
auto* to_object = Object::create(realm, realm.intrinsics().object_prototype());
auto to_object = Object::create(realm, realm.intrinsics().object_prototype());
HashTable<Value, ValueTraits> excluded_names;
for (size_t i = 0; i < m_excluded_names_count; ++i)
@ -930,7 +930,7 @@ ThrowCompletionOr<void> GetObjectPropertyIterator::execute_impl(Bytecode::Interp
return vm.throw_completion<InternalError>("Invalid state for GetObjectPropertyIterator.next");
auto& iterated_object = iterated_object_value.as_object();
auto* result_object = Object::create(realm, nullptr);
auto result_object = Object::create(realm, nullptr);
while (true) {
if (items.is_empty()) {
result_object->define_direct_property(vm.names.done, JS::Value(true), default_attributes);

View file

@ -1053,7 +1053,7 @@ Object* create_unmapped_arguments_object(VM& vm, Span<Value> arguments)
// 2. Let obj be OrdinaryObjectCreate(%Object.prototype%, « [[ParameterMap]] »).
// 3. Set obj.[[ParameterMap]] to undefined.
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
auto object = Object::create(realm, realm.intrinsics().object_prototype());
object->set_has_parameter_map();
// 4. Perform ! DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Value]]: 𝔽(len), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).

View file

@ -89,7 +89,7 @@ void ArrayPrototype::initialize(Realm& realm)
// 23.1.3.37 Array.prototype [ @@unscopables ], https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
// With array grouping proposal, https://tc39.es/proposal-array-grouping/#sec-array.prototype-@@unscopables
// With change array by copy proposal, https://tc39.es/proposal-change-array-by-copy/#sec-array.prototype-@@unscopables
auto* unscopable_list = Object::create(realm, nullptr);
auto unscopable_list = Object::create(realm, nullptr);
MUST(unscopable_list->create_data_property_or_throw(vm.names.at, Value(true)));
MUST(unscopable_list->create_data_property_or_throw(vm.names.copyWithin, Value(true)));
MUST(unscopable_list->create_data_property_or_throw(vm.names.entries, Value(true)));
@ -791,7 +791,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::group)
}
// 7. Let obj be OrdinaryObjectCreate(null).
auto* object = Object::create(realm, nullptr);
auto object = Object::create(realm, nullptr);
// 8. For each Record { [[Key]], [[Elements]] } g of groups, do
for (auto& group : groups) {

View file

@ -99,7 +99,7 @@ ThrowCompletionOr<Value> GeneratorObject::execute(VM& vm, Completion const& comp
};
auto& realm = *vm.current_realm();
auto* completion_object = Object::create(realm, nullptr);
auto completion_object = Object::create(realm, nullptr);
completion_object->define_direct_property(vm.names.type, Value(to_underlying(completion.type())), default_attributes);
completion_object->define_direct_property(vm.names.value, completion.value().value(), default_attributes);

View file

@ -600,7 +600,7 @@ ThrowCompletionOr<Object*> coerce_options_to_object(VM& vm, Value options)
// 1. If options is undefined, then
if (options.is_undefined()) {
// a. Return OrdinaryObjectCreate(null).
return Object::create(realm, nullptr);
return Object::create(realm, nullptr).ptr();
}
// 2. Return ? ToObject(options).

View file

@ -64,7 +64,7 @@ JS_DEFINE_NATIVE_FUNCTION(CollatorPrototype::resolved_options)
auto* collator = TRY(typed_this_object(vm));
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
auto* options = Object::create(realm, realm.intrinsics().object_prototype());
auto options = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each row of Table 3, except the header row, in table order, do
// a. Let p be the Property value of the current row.

View file

@ -547,13 +547,13 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
auto const& locale = date_time_format.locale();
auto const& data_locale = date_time_format.data_locale();
auto construct_number_format = [&](auto* options) -> ThrowCompletionOr<NumberFormat*> {
auto construct_number_format = [&](auto& options) -> ThrowCompletionOr<NumberFormat*> {
auto* number_format = TRY(construct(vm, *realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, locale), options));
return static_cast<NumberFormat*>(number_format);
};
// 4. Let nfOptions be OrdinaryObjectCreate(null).
auto* number_format_options = Object::create(realm, nullptr);
auto number_format_options = Object::create(realm, nullptr);
// 5. Perform ! CreateDataPropertyOrThrow(nfOptions, "useGrouping", false).
MUST(number_format_options->create_data_property_or_throw(vm.names.useGrouping, Value(false)));
@ -562,7 +562,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
auto* number_format = TRY(construct_number_format(number_format_options));
// 7. Let nf2Options be OrdinaryObjectCreate(null).
auto* number_format_options2 = Object::create(realm, nullptr);
auto number_format_options2 = Object::create(realm, nullptr);
// 8. Perform ! CreateDataPropertyOrThrow(nf2Options, "minimumIntegerDigits", 2).
MUST(number_format_options2->create_data_property_or_throw(vm.names.minimumIntegerDigits, Value(2)));
@ -582,7 +582,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
fractional_second_digits = date_time_format.fractional_second_digits();
// a. Let nf3Options be OrdinaryObjectCreate(null).
auto* number_format_options3 = Object::create(realm, nullptr);
auto number_format_options3 = Object::create(realm, nullptr);
// b. Perform ! CreateDataPropertyOrThrow(nf3Options, "minimumIntegerDigits", fractionalSecondDigits).
MUST(number_format_options3->create_data_property_or_throw(vm.names.minimumIntegerDigits, Value(*fractional_second_digits)));
@ -865,7 +865,7 @@ ThrowCompletionOr<Array*> format_date_time_to_parts(VM& vm, DateTimeFormat& date
// 4. For each Record { [[Type]], [[Value]] } part in parts, do
for (auto& part : parts) {
// a. Let O be OrdinaryObjectCreate(%Object.prototype%).
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
auto object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));
@ -1181,7 +1181,7 @@ ThrowCompletionOr<Array*> format_date_time_range_to_parts(VM& vm, DateTimeFormat
// 4. For each Record { [[Type]], [[Value]], [[Source]] } part in parts, do
for (auto& part : parts) {
// a. Let O be OrdinaryObjectCreate(%ObjectPrototype%).
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
auto object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));

View file

@ -155,7 +155,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options)
auto* date_time_format = TRY(typed_this_object(vm));
// 4. Let options be OrdinaryObjectCreate(%Object.prototype%).
auto* options = Object::create(realm, realm.intrinsics().object_prototype());
auto options = Object::create(realm, realm.intrinsics().object_prototype());
// 5. For each row of Table 5, except the header row, in table order, do
// a. Let p be the Property value of the current row.

View file

@ -131,7 +131,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::resolved_options)
auto* display_names = TRY(typed_this_object(vm));
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
auto* options = Object::create(realm, realm.intrinsics().object_prototype());
auto options = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each row of Table 8, except the header row, in table order, do
// a. Let p be the Property value of the current row.

View file

@ -339,7 +339,7 @@ Vector<PatternPartition> partition_duration_format_pattern(VM& vm, DurationForma
auto value = duration.*value_slot;
// i. Let nfOpts be ! OrdinaryObjectCreate(null).
auto* number_format_options = Object::create(realm, nullptr);
auto number_format_options = Object::create(realm, nullptr);
// j. If unit is "seconds", "milliseconds", or "microseconds", then
if (unit.is_one_of("seconds"sv, "milliseconds"sv, "microseconds"sv)) {
@ -486,7 +486,7 @@ Vector<PatternPartition> partition_duration_format_pattern(VM& vm, DurationForma
}
// 4. Let lfOpts be ! OrdinaryObjectCreate(null).
auto* list_format_options = Object::create(realm, nullptr);
auto list_format_options = Object::create(realm, nullptr);
// 5. Perform ! CreateDataPropertyOrThrow(lfOpts, "type", "unit").
MUST(list_format_options->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, "unit"sv)));

View file

@ -90,7 +90,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format_to_parts)
auto const& part = parts[n];
// a. Let obj be ! OrdinaryObjectCreate(%ObjectPrototype%).
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
auto object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(obj, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));
@ -118,7 +118,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::resolved_options)
auto* duration_format = TRY(typed_this_object(vm));
// 3. Let options be ! OrdinaryObjectCreate(%Object.prototype%).
auto* options = Object::create(realm, realm.intrinsics().object_prototype());
auto options = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each row of Table 2, except the header row, in table order, do
// a. Let p be the Property value of the current row.

View file

@ -217,7 +217,7 @@ Array* format_list_to_parts(VM& vm, ListFormat const& list_format, Vector<Deprec
// 4. For each Record { [[Type]], [[Value]] } part in parts, do
for (auto& part : parts) {
// a. Let O be OrdinaryObjectCreate(%Object.prototype%).
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
auto object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));

View file

@ -76,7 +76,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::resolved_options)
auto* list_format = TRY(typed_this_object(vm));
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
auto* options = Object::create(realm, realm.intrinsics().object_prototype());
auto options = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each row of Table 10, except the header row, in table order, do
// a. Let p be the Property value of the current row.

View file

@ -258,7 +258,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::text_info)
auto* locale_object = TRY(typed_this_object(vm));
// 3. Let info be ! ObjectCreate(%Object.prototype%).
auto* info = Object::create(realm, realm.intrinsics().object_prototype());
auto info = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Let dir be ! CharacterDirectionOfLocale(loc).
auto direction = character_direction_of_locale(*locale_object);
@ -280,7 +280,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::week_info)
[[maybe_unused]] auto* locale_object = TRY(typed_this_object(vm));
// 3. Let info be ! ObjectCreate(%Object.prototype%).
auto* info = Object::create(realm, realm.intrinsics().object_prototype());
auto info = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Let wi be ! WeekInfoOfLocale(loc).
auto week_info = week_info_of_locale(*locale_object);

View file

@ -922,7 +922,7 @@ Array* format_numeric_to_parts(VM& vm, NumberFormat& number_format, Mathematical
// 4. For each Record { [[Type]], [[Value]] } part in parts, do
for (auto& part : parts) {
// a. Let O be OrdinaryObjectCreate(%Object.prototype%).
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
auto object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));
@ -1832,7 +1832,7 @@ ThrowCompletionOr<Array*> format_numeric_range_to_parts(VM& vm, NumberFormat& nu
// 4. For each Record { [[Type]], [[Value]] } part in parts, do
for (auto& part : parts) {
// a. Let O be OrdinaryObjectCreate(%Object.prototype%).
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
auto object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));

View file

@ -145,7 +145,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options)
auto* number_format = TRY(typed_this_object(vm));
// 4. Let options be OrdinaryObjectCreate(%Object.prototype%).
auto* options = Object::create(realm, realm.intrinsics().object_prototype());
auto options = Object::create(realm, realm.intrinsics().object_prototype());
// 5. For each row of Table 11, except the header row, in table order, do
// a. Let p be the Property value of the current row.

View file

@ -86,7 +86,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options)
auto* plural_rules = TRY(typed_this_object(vm));
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
auto* options = Object::create(realm, realm.intrinsics().object_prototype());
auto options = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each row of Table 13, except the header row, in table order, do
// a. Let p be the Property value of the current row.

View file

@ -257,7 +257,7 @@ ThrowCompletionOr<Array*> format_relative_time_to_parts(VM& vm, RelativeTimeForm
// 4. For each Record { [[Type]], [[Value]], [[Unit]] } part in parts, do
for (auto& part : parts) {
// a. Let O be OrdinaryObjectCreate(%Object.prototype%).
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
auto object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));

View file

@ -76,7 +76,7 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::resolved_options)
auto* relative_time_format = TRY(typed_this_object(vm));
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
auto* options = Object::create(realm, realm.intrinsics().object_prototype());
auto options = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each row of Table 15, except the header row, in table order, do
// a. Let p be the Property value of the current row.

View file

@ -62,7 +62,7 @@ Object* create_segment_data_object(VM& vm, Segmenter const& segmenter, Utf16View
VERIFY(start_index < end_index);
// 5. Let result be OrdinaryObjectCreate(%Object.prototype%).
auto* result = Object::create(realm, realm.intrinsics().object_prototype());
auto result = Object::create(realm, realm.intrinsics().object_prototype());
// 6. Let segment be the substring of string from startIndex to endIndex.
auto segment = string.substring_view(start_index, end_index - start_index);

View file

@ -41,7 +41,7 @@ JS_DEFINE_NATIVE_FUNCTION(SegmenterPrototype::resolved_options)
auto* segmenter = TRY(typed_this_object(vm));
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
auto* options = Object::create(realm, realm.intrinsics().object_prototype());
auto options = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each row of Table 16, except the header row, in table order, do
// a. Let p be the Property value of the current row.

View file

@ -189,7 +189,7 @@ Object* create_iterator_result_object(VM& vm, Value value, bool done)
auto& realm = *vm.current_realm();
// 1. Let obj be OrdinaryObjectCreate(%Object.prototype%).
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
auto object = Object::create(realm, realm.intrinsics().object_prototype());
// 2. Perform ! CreateDataPropertyOrThrow(obj, "value", value).
MUST(object->create_data_property_or_throw(vm.names.value, value));

View file

@ -102,7 +102,7 @@ ThrowCompletionOr<DeprecatedString> JSONObject::stringify_impl(VM& vm, Value val
state.gap = DeprecatedString::empty();
}
auto* wrapper = Object::create(realm, realm.intrinsics().object_prototype());
auto wrapper = Object::create(realm, realm.intrinsics().object_prototype());
MUST(wrapper->create_data_property_or_throw(DeprecatedString::empty(), value));
return serialize_json_property(vm, state, DeprecatedString::empty(), wrapper);
}
@ -401,7 +401,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::parse)
return vm.throw_completion<SyntaxError>(ErrorType::JsonMalformed);
Value unfiltered = parse_json_value(vm, json.value());
if (reviver.is_function()) {
auto* root = Object::create(realm, realm.intrinsics().object_prototype());
auto root = Object::create(realm, realm.intrinsics().object_prototype());
auto root_name = DeprecatedString::empty();
MUST(root->create_data_property_or_throw(root_name, unfiltered));
return internalize_json_property(vm, root, root_name, reviver.as_function());
@ -431,7 +431,7 @@ Value JSONObject::parse_json_value(VM& vm, JsonValue const& value)
Object* JSONObject::parse_json_object(VM& vm, JsonObject const& json_object)
{
auto& realm = *vm.current_realm();
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
auto object = Object::create(realm, realm.intrinsics().object_prototype());
json_object.for_each_member([&](auto& key, auto& value) {
object->define_direct_property(key, parse_json_value(vm, value), default_attributes);
});

View file

@ -27,14 +27,14 @@ namespace JS {
static HashMap<Object const*, HashMap<FlyString, Object::IntrinsicAccessor>> s_intrinsics;
// 10.1.12 OrdinaryObjectCreate ( proto [ , additionalInternalSlotsList ] ), https://tc39.es/ecma262/#sec-ordinaryobjectcreate
Object* Object::create(Realm& realm, Object* prototype)
NonnullGCPtr<Object> Object::create(Realm& realm, Object* prototype)
{
if (!prototype)
return realm.heap().allocate<Object>(realm, *realm.intrinsics().empty_object_shape());
return *realm.heap().allocate<Object>(realm, *realm.intrinsics().empty_object_shape());
else if (prototype == realm.intrinsics().object_prototype())
return realm.heap().allocate<Object>(realm, *realm.intrinsics().new_object_shape());
return *realm.heap().allocate<Object>(realm, *realm.intrinsics().new_object_shape());
else
return realm.heap().allocate<Object>(realm, *prototype);
return *realm.heap().allocate<Object>(realm, *prototype);
}
Object::Object(GlobalObjectTag, Realm& realm)

View file

@ -44,7 +44,7 @@ class Object : public Cell {
JS_CELL(Object, Cell);
public:
static Object* create(Realm&, Object* prototype);
static NonnullGCPtr<Object> create(Realm&, Object* prototype);
virtual void initialize(Realm&) override;
virtual ~Object();

View file

@ -73,7 +73,7 @@ ThrowCompletionOr<Object*> ObjectConstructor::construct(FunctionObject& new_targ
return TRY(ordinary_create_from_constructor<Object>(vm, new_target, &Intrinsics::object_prototype));
auto value = vm.argument(0);
if (value.is_nullish())
return Object::create(realm, realm.intrinsics().object_prototype());
return Object::create(realm, realm.intrinsics().object_prototype()).ptr();
return value.to_object(vm);
}
@ -223,7 +223,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::from_entries)
auto& realm = *vm.current_realm();
auto iterable = TRY(require_object_coercible(vm, vm.argument(0)));
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
auto object = Object::create(realm, realm.intrinsics().object_prototype());
(void)TRY(get_iterator_values(vm, iterable, [&](Value iterator_value) -> Optional<Completion> {
if (!iterator_value.is_object())
@ -274,7 +274,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_own_property_descriptors)
auto own_keys = TRY(object->internal_own_property_keys());
// 3. Let descriptors be OrdinaryObjectCreate(%Object.prototype%).
auto* descriptors = Object::create(realm, realm.intrinsics().object_prototype());
auto descriptors = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each element key of ownKeys, do
for (auto& key : own_keys) {
@ -369,7 +369,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::create)
return vm.throw_completion<TypeError>(ErrorType::ObjectPrototypeWrongType);
// 2. Let obj be OrdinaryObjectCreate(O).
auto* object = Object::create(realm, proto.is_null() ? nullptr : &proto.as_object());
auto object = Object::create(realm, proto.is_null() ? nullptr : &proto.as_object());
// 3. If Properties is not undefined, then
if (!properties.is_undefined()) {

View file

@ -101,7 +101,7 @@ ThrowCompletionOr<Value> PromiseAllSettledResolveElementFunction::resolve_elemen
auto& realm = *vm.current_realm();
// 9. Let obj be OrdinaryObjectCreate(%Object.prototype%).
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
auto object = Object::create(realm, realm.intrinsics().object_prototype());
// 10. Perform ! CreateDataPropertyOrThrow(obj, "status", "fulfilled").
MUST(object->create_data_property_or_throw(vm.names.status, PrimitiveString::create(vm, "fulfilled"sv)));
@ -142,7 +142,7 @@ ThrowCompletionOr<Value> PromiseAllSettledRejectElementFunction::resolve_element
auto& realm = *vm.current_realm();
// 9. Let obj be OrdinaryObjectCreate(%Object.prototype%).
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
auto object = Object::create(realm, realm.intrinsics().object_prototype());
// 10. Perform ! CreateDataPropertyOrThrow(obj, "status", "rejected").
MUST(object->create_data_property_or_throw(vm.names.status, PrimitiveString::create(vm, "rejected"sv)));

View file

@ -71,7 +71,7 @@ Value from_property_descriptor(VM& vm, Optional<PropertyDescriptor> const& prope
if (!property_descriptor.has_value())
return js_undefined();
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
auto object = Object::create(realm, realm.intrinsics().object_prototype());
if (property_descriptor->value.has_value())
MUST(object->create_data_property_or_throw(vm.names.value, *property_descriptor->value));
if (property_descriptor->writable.has_value())

View file

@ -87,7 +87,7 @@ JS_DEFINE_NATIVE_FUNCTION(ProxyConstructor::revocable)
auto revoker = NativeFunction::create(realm, move(revoker_closure), 0, "");
// 5. Let result be OrdinaryObjectCreate(%Object.prototype%).
auto* result = Object::create(realm, realm.intrinsics().object_prototype());
auto result = Object::create(realm, realm.intrinsics().object_prototype());
// 6. Perform ! CreateDataPropertyOrThrow(result, "proxy", p).
MUST(result->create_data_property_or_throw(vm.names.proxy, proxy));

View file

@ -284,7 +284,7 @@ static ThrowCompletionOr<Value> regexp_builtin_exec(VM& vm, RegExpObject& regexp
// a. Let groups be undefined.
// b. Let hasGroups be false.
bool has_groups = result.n_named_capture_groups != 0;
Object* groups_object = has_groups ? Object::create(realm, nullptr) : nullptr;
auto groups_object = has_groups ? Object::create(realm, nullptr) : GCPtr<Object> {};
// 32. For each integer i such that i ≥ 1 and i ≤ n, in ascending order, do
for (size_t i = 1; i <= result.n_capture_groups; ++i) {

View file

@ -84,7 +84,7 @@ ThrowCompletionOr<Object*> get_options_object(VM& vm, Value options)
// 1. If options is undefined, then
if (options.is_undefined()) {
// a. Return OrdinaryObjectCreate(null).
return Object::create(realm, nullptr);
return Object::create(realm, nullptr).ptr();
}
// 2. If Type(options) is Object, then
@ -600,7 +600,7 @@ ThrowCompletionOr<Value> to_relative_temporal_object(VM& vm, Object const& optio
auto* fields = TRY(prepare_temporal_fields(vm, value_object, field_names, Vector<StringView> {}));
// f. Let dateOptions be OrdinaryObjectCreate(null).
auto* date_options = Object::create(realm, nullptr);
auto date_options = Object::create(realm, nullptr);
// g. Perform ! CreateDataPropertyOrThrow(dateOptions, "overflow", "constrain").
MUST(date_options->create_data_property_or_throw(vm.names.overflow, PrimitiveString::create(vm, "constrain"sv)));
@ -740,7 +740,7 @@ ThrowCompletionOr<Object*> merge_largest_unit_option(VM& vm, Object const& optio
auto& realm = *vm.current_realm();
// 1. Let merged be OrdinaryObjectCreate(null).
auto* merged = Object::create(realm, nullptr);
auto merged = Object::create(realm, nullptr);
// 2. Let keys be ? EnumerableOwnPropertyNames(options, key).
auto keys = TRY(options.enumerable_own_property_names(Object::PropertyKind::Key));
@ -760,7 +760,7 @@ ThrowCompletionOr<Object*> merge_largest_unit_option(VM& vm, Object const& optio
MUST(merged->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, move(largest_unit))));
// 5. Return merged.
return merged;
return merged.ptr();
}
// 13.19 MaximumTemporalDurationRoundingIncrement ( unit ), https://tc39.es/proposal-temporal/#sec-temporal-maximumtemporaldurationroundingincrement
@ -1745,7 +1745,7 @@ ThrowCompletionOr<Object*> prepare_temporal_fields(VM& vm, Object const& fields,
auto& realm = *vm.current_realm();
// 1. Let result be OrdinaryObjectCreate(null).
auto* result = Object::create(realm, nullptr);
auto result = Object::create(realm, nullptr);
VERIFY(result);
// 2. Let any be false.
@ -1811,7 +1811,7 @@ ThrowCompletionOr<Object*> prepare_temporal_fields(VM& vm, Object const& fields,
}
// 5. Return result.
return result;
return result.ptr();
}
// 13.44 GetDifferenceSettings ( operation, options, unitGroup, disallowedUnits, fallbackSmallestUnit, smallestLargestDefaultUnit ), https://tc39.es/proposal-temporal/#sec-temporal-getdifferencesettings

View file

@ -945,7 +945,7 @@ ThrowCompletionOr<Object*> default_merge_calendar_fields(VM& vm, Object const& f
auto& realm = *vm.current_realm();
// 1. Let merged be OrdinaryObjectCreate(%Object.prototype%).
auto* merged = Object::create(realm, realm.intrinsics().object_prototype());
auto merged = Object::create(realm, realm.intrinsics().object_prototype());
// 2. Let fieldsKeys be ? EnumerableOwnPropertyNames(fields, key).
auto fields_keys = TRY(fields.enumerable_own_property_names(Object::PropertyKind::Key));
@ -1012,7 +1012,7 @@ ThrowCompletionOr<Object*> default_merge_calendar_fields(VM& vm, Object const& f
}
// 7. Return merged.
return merged;
return merged.ptr();
}
// 12.2.38 ToISODayOfYear ( year, month, day ), https://tc39.es/proposal-temporal/#sec-temporal-toisodayofyear

View file

@ -689,7 +689,7 @@ ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM& vm, double
auto* new_relative_to = TRY(calendar_date_add(vm, *calendar, relative_to, *one_year, nullptr, date_add));
// ii. Let untilOptions be OrdinaryObjectCreate(null).
auto* until_options = Object::create(realm, nullptr);
auto until_options = Object::create(realm, nullptr);
// iii. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "month").
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "month"sv)));
@ -925,7 +925,7 @@ ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM& vm, double y
auto* date_until = TRY(Value(&calendar).get_method(vm, vm.names.dateUntil));
// l. Let untilOptions be OrdinaryObjectCreate(null).
auto* until_options = Object::create(realm, nullptr);
auto until_options = Object::create(realm, nullptr);
// m. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "month").
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "month"sv)));
@ -1106,7 +1106,7 @@ ThrowCompletionOr<DurationRecord> add_duration(VM& vm, double years1, double mon
auto date_largest_unit = larger_of_two_temporal_units("day"sv, largest_unit);
// h. Let differenceOptions be OrdinaryObjectCreate(null).
auto* difference_options = Object::create(realm, nullptr);
auto difference_options = Object::create(realm, nullptr);
// i. Perform ! CreateDataPropertyOrThrow(differenceOptions, "largestUnit", dateLargestUnit).
MUST(difference_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, date_largest_unit)));
@ -1309,7 +1309,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(VM& vm, double years, double m
auto* days_later = TRY(calendar_date_add(vm, *calendar, relative_to, *days_duration, nullptr, date_add));
// k. Let untilOptions be OrdinaryObjectCreate(null).
auto* until_options = Object::create(realm, nullptr);
auto until_options = Object::create(realm, nullptr);
// l. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "year").
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "year"sv)));

View file

@ -326,7 +326,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::get_iso_fields)
auto* temporal_date = TRY(typed_this_object(vm));
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
auto* fields = Object::create(realm, realm.intrinsics().object_prototype());
auto fields = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", temporalDate.[[Calendar]]).
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&temporal_date->calendar())));

View file

@ -735,7 +735,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::get_iso_fields)
auto* date_time = TRY(typed_this_object(vm));
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
auto* fields = Object::create(realm, realm.intrinsics().object_prototype());
auto fields = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", dateTime.[[Calendar]]).
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&date_time->calendar())));

View file

@ -241,7 +241,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_plain_date)
merged_fields = TRY(prepare_temporal_fields(vm, *merged_fields, merged_field_names, Vector<StringView> {}));
// 12. Let options be OrdinaryObjectCreate(null).
auto* options = Object::create(realm, nullptr);
auto options = Object::create(realm, nullptr);
// 13. Perform ! CreateDataPropertyOrThrow(options, "overflow", "reject").
MUST(options->create_data_property_or_throw(vm.names.overflow, PrimitiveString::create(vm, vm.names.reject.as_string())));
@ -260,7 +260,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::get_iso_fields)
auto* month_day = TRY(typed_this_object(vm));
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
auto* fields = Object::create(realm, realm.intrinsics().object_prototype());
auto fields = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", monthDay.[[Calendar]]).
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&month_day->calendar())));

View file

@ -425,7 +425,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::get_iso_fields)
auto* temporal_time = TRY(typed_this_object(vm));
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
auto* fields = Object::create(realm, realm.intrinsics().object_prototype());
auto fields = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", temporalTime.[[Calendar]]).
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&temporal_time->calendar())));

View file

@ -345,7 +345,7 @@ ThrowCompletionOr<PlainYearMonth*> add_duration_to_or_subtract_duration_from_pla
auto* duration_to_add = MUST(create_temporal_duration(vm, duration->years(), duration->months(), duration->weeks(), balance_result.days, 0, 0, 0, 0, 0, 0));
// 14. Let optionsCopy be OrdinaryObjectCreate(null).
auto* options_copy = Object::create(realm, nullptr);
auto options_copy = Object::create(realm, nullptr);
// 15. Let entries be ? EnumerableOwnPropertyNames(options, key+value).
auto entries = TRY(options->enumerable_own_property_names(Object::PropertyKind::KeyAndValue));

View file

@ -408,7 +408,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_plain_date)
merged_fields = TRY(prepare_temporal_fields(vm, *merged_fields, merged_field_names, Vector<StringView> {}));
// 12. Let options be OrdinaryObjectCreate(null).
auto* options = Object::create(realm, nullptr);
auto options = Object::create(realm, nullptr);
// 13. Perform ! CreateDataPropertyOrThrow(options, "overflow", "reject").
MUST(options->create_data_property_or_throw(vm.names.overflow, PrimitiveString::create(vm, vm.names.reject.as_string())));
@ -427,7 +427,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::get_iso_fields)
auto* year_month = TRY(typed_this_object(vm));
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
auto* fields = Object::create(realm, realm.intrinsics().object_prototype());
auto fields = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", yearMonth.[[Calendar]]).
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&year_month->calendar())));

View file

@ -1297,7 +1297,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::get_iso_fields)
auto* zoned_date_time = TRY(typed_this_object(vm));
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
auto* fields = Object::create(realm, realm.intrinsics().object_prototype());
auto fields = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone();

View file

@ -332,7 +332,7 @@ ThrowCompletionOr<void> VM::property_binding_initialization(BindingPattern const
VERIFY_NOT_REACHED();
}
auto* rest_object = Object::create(realm, realm.intrinsics().object_prototype());
auto rest_object = Object::create(realm, realm.intrinsics().object_prototype());
VERIFY(rest_object);
TRY(rest_object->copy_data_properties(vm, object, seen_names));

View file

@ -385,7 +385,7 @@ JS::VM& main_thread_vm()
// and ensure_web_constructor() invocations.
// FIXME: Find a nicer way to do this.
JS::DeferGC defer_gc(root_realm->heap());
auto* object = JS::Object::create(*root_realm, nullptr);
auto object = JS::Object::create(*root_realm, nullptr);
root_realm->set_global_object(object, object);
add_window_exposed_interfaces(*object, *root_realm);

View file

@ -351,9 +351,9 @@ static JS::ThrowCompletionOr<JS::Value> load_ini_impl(JS::VM& vm)
return vm.throw_completion<JS::Error>(DeprecatedString::formatted("Failed to open '{}': {}", filename, file_or_error.error()));
auto config_file = MUST(Core::ConfigFile::open(filename, file_or_error.release_value()));
auto* object = JS::Object::create(realm, realm.intrinsics().object_prototype());
auto object = JS::Object::create(realm, realm.intrinsics().object_prototype());
for (auto const& group : config_file->groups()) {
auto* group_object = JS::Object::create(realm, realm.intrinsics().object_prototype());
auto group_object = JS::Object::create(realm, realm.intrinsics().object_prototype());
for (auto const& key : config_file->keys(group)) {
auto entry = config_file->read_entry(group, key);
group_object->define_direct_property(key, JS::PrimitiveString::create(vm, move(entry)), JS::Attribute::Enumerable | JS::Attribute::Configurable | JS::Attribute::Writable);