LibJS: Convert RegExpObject::create() to NonnullGCPtr

This commit is contained in:
Linus Groh 2022-12-13 20:49:50 +00:00
parent bfb8d83535
commit cad40ec953
3 changed files with 7 additions and 7 deletions

View file

@ -3541,7 +3541,7 @@ Completion RegExpLiteral::execute(Interpreter& interpreter) const
// 3. Return ! RegExpCreate(pattern, flags).
Regex<ECMA262> regex(parsed_regex(), parsed_pattern(), parsed_flags());
// NOTE: We bypass RegExpCreate and subsequently RegExpAlloc as an optimization to use the already parsed values.
auto* regexp_object = RegExpObject::create(realm, move(regex), move(pattern), move(flags));
auto regexp_object = RegExpObject::create(realm, move(regex), move(pattern), move(flags));
// RegExpAlloc has these two steps from the 'Legacy RegExp features' proposal.
regexp_object->set_realm(*vm.current_realm());
// We don't need to check 'If SameValue(newTarget, thisRealm.[[Intrinsics]].[[%RegExp%]]) is true'

View file

@ -124,14 +124,14 @@ ThrowCompletionOr<DeprecatedString> parse_regex_pattern(VM& vm, StringView patte
return result.release_value();
}
RegExpObject* RegExpObject::create(Realm& realm)
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm)
{
return realm.heap().allocate<RegExpObject>(realm, *realm.intrinsics().regexp_prototype());
return *realm.heap().allocate<RegExpObject>(realm, *realm.intrinsics().regexp_prototype());
}
RegExpObject* RegExpObject::create(Realm& realm, Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags)
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm, Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags)
{
return realm.heap().allocate<RegExpObject>(realm, move(regex), move(pattern), move(flags), *realm.intrinsics().regexp_prototype());
return *realm.heap().allocate<RegExpObject>(realm, move(regex), move(pattern), move(flags), *realm.intrinsics().regexp_prototype());
}
RegExpObject::RegExpObject(Object& prototype)

View file

@ -36,8 +36,8 @@ public:
| regex::ECMAScriptFlags::BrowserExtended
};
static RegExpObject* create(Realm&);
static RegExpObject* create(Realm&, Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags);
static NonnullGCPtr<RegExpObject> create(Realm&);
static NonnullGCPtr<RegExpObject> create(Realm&, Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags);
ThrowCompletionOr<NonnullGCPtr<RegExpObject>> regexp_initialize(VM&, Value pattern, Value flags);
DeprecatedString escape_regexp_pattern() const;