mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the namespace change, we now have the following names: * JS::NonnullGCPtr -> GC::Ref * JS::GCPtr -> GC::Ptr * JS::HeapFunction -> GC::Function * JS::CellImpl -> GC::Cell * JS::Handle -> GC::Root
This commit is contained in:
parent
ce23efc5f6
commit
f87041bf3a
Notes:
github-actions[bot]
2024-11-15 13:50:17 +00:00
Author: https://github.com/shannonbooth
Commit: f87041bf3a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2345
1722 changed files with 9939 additions and 9906 deletions
|
@ -16,15 +16,15 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(Iterator);
|
||||
JS_DEFINE_ALLOCATOR(IteratorRecord);
|
||||
GC_DEFINE_ALLOCATOR(Iterator);
|
||||
GC_DEFINE_ALLOCATOR(IteratorRecord);
|
||||
|
||||
NonnullGCPtr<Iterator> Iterator::create(Realm& realm, Object& prototype, NonnullGCPtr<IteratorRecord> iterated)
|
||||
GC::Ref<Iterator> Iterator::create(Realm& realm, Object& prototype, GC::Ref<IteratorRecord> iterated)
|
||||
{
|
||||
return realm.create<Iterator>(prototype, move(iterated));
|
||||
}
|
||||
|
||||
Iterator::Iterator(Object& prototype, NonnullGCPtr<IteratorRecord> iterated)
|
||||
Iterator::Iterator(Object& prototype, GC::Ref<IteratorRecord> iterated)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_iterated(move(iterated))
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ Iterator::Iterator(Object& prototype)
|
|||
}
|
||||
|
||||
// 7.4.2 GetIteratorDirect ( obj ), https://tc39.es/ecma262/#sec-getiteratordirect
|
||||
ThrowCompletionOr<NonnullGCPtr<IteratorRecord>> get_iterator_direct(VM& vm, Object& object)
|
||||
ThrowCompletionOr<GC::Ref<IteratorRecord>> get_iterator_direct(VM& vm, Object& object)
|
||||
{
|
||||
// 1. Let nextMethod be ? Get(obj, "next").
|
||||
auto next_method = TRY(object.get(vm.names.next));
|
||||
|
@ -48,7 +48,7 @@ ThrowCompletionOr<NonnullGCPtr<IteratorRecord>> get_iterator_direct(VM& vm, Obje
|
|||
}
|
||||
|
||||
// 7.4.3 GetIteratorFromMethod ( obj, method ), https://tc39.es/ecma262/#sec-getiteratorfrommethod
|
||||
ThrowCompletionOr<NonnullGCPtr<IteratorRecord>> get_iterator_from_method(VM& vm, Value object, NonnullGCPtr<FunctionObject> method)
|
||||
ThrowCompletionOr<GC::Ref<IteratorRecord>> get_iterator_from_method(VM& vm, Value object, GC::Ref<FunctionObject> method)
|
||||
{
|
||||
// 1. Let iterator be ? Call(method, obj).
|
||||
auto iterator = TRY(call(vm, *method, object));
|
||||
|
@ -69,9 +69,9 @@ ThrowCompletionOr<NonnullGCPtr<IteratorRecord>> get_iterator_from_method(VM& vm,
|
|||
}
|
||||
|
||||
// 7.4.4 GetIterator ( obj, kind ), https://tc39.es/ecma262/#sec-getiterator
|
||||
ThrowCompletionOr<NonnullGCPtr<IteratorRecord>> get_iterator(VM& vm, Value object, IteratorHint kind)
|
||||
ThrowCompletionOr<GC::Ref<IteratorRecord>> get_iterator(VM& vm, Value object, IteratorHint kind)
|
||||
{
|
||||
JS::GCPtr<FunctionObject> method;
|
||||
GC::Ptr<FunctionObject> method;
|
||||
|
||||
// 1. If kind is async, then
|
||||
if (kind == IteratorHint::Async) {
|
||||
|
@ -109,7 +109,7 @@ ThrowCompletionOr<NonnullGCPtr<IteratorRecord>> get_iterator(VM& vm, Value objec
|
|||
}
|
||||
|
||||
// 7.4.5 GetIteratorFlattenable ( obj, primitiveHandling ), https://tc39.es/ecma262/#sec-getiteratorflattenable
|
||||
ThrowCompletionOr<NonnullGCPtr<IteratorRecord>> get_iterator_flattenable(VM& vm, Value object, PrimitiveHandling primitive_handling)
|
||||
ThrowCompletionOr<GC::Ref<IteratorRecord>> get_iterator_flattenable(VM& vm, Value object, PrimitiveHandling primitive_handling)
|
||||
{
|
||||
// 1. If obj is not an Object, then
|
||||
if (!object.is_object()) {
|
||||
|
@ -150,7 +150,7 @@ ThrowCompletionOr<NonnullGCPtr<IteratorRecord>> get_iterator_flattenable(VM& vm,
|
|||
}
|
||||
|
||||
// 7.4.6 IteratorNext ( iteratorRecord [ , value ] ), https://tc39.es/ecma262/#sec-iteratornext
|
||||
ThrowCompletionOr<NonnullGCPtr<Object>> iterator_next(VM& vm, IteratorRecord& iterator_record, Optional<Value> value)
|
||||
ThrowCompletionOr<GC::Ref<Object>> iterator_next(VM& vm, IteratorRecord& iterator_record, Optional<Value> value)
|
||||
{
|
||||
auto result = [&]() {
|
||||
// 1. If value is not present, then
|
||||
|
@ -205,7 +205,7 @@ ThrowCompletionOr<Value> iterator_value(VM& vm, Object& iterator_result)
|
|||
}
|
||||
|
||||
// 7.4.9 IteratorStep ( iteratorRecord ), https://tc39.es/ecma262/#sec-iteratorstep
|
||||
ThrowCompletionOr<GCPtr<Object>> iterator_step(VM& vm, IteratorRecord& iterator_record)
|
||||
ThrowCompletionOr<GC::Ptr<Object>> iterator_step(VM& vm, IteratorRecord& iterator_record)
|
||||
{
|
||||
// 1. Let result be ? IteratorNext(iteratorRecord).
|
||||
auto result = TRY(iterator_next(vm, iterator_record));
|
||||
|
@ -327,7 +327,7 @@ Completion async_iterator_close(VM& vm, IteratorRecord const& iterator_record, C
|
|||
}
|
||||
|
||||
// 7.4.14 CreateIteratorResultObject ( value, done ), https://tc39.es/ecma262/#sec-createiterresultobject
|
||||
NonnullGCPtr<Object> create_iterator_result_object(VM& vm, Value value, bool done)
|
||||
GC::Ref<Object> create_iterator_result_object(VM& vm, Value value, bool done)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -345,10 +345,10 @@ NonnullGCPtr<Object> create_iterator_result_object(VM& vm, Value value, bool don
|
|||
}
|
||||
|
||||
// 7.4.16 IteratorToList ( iteratorRecord ), https://tc39.es/ecma262/#sec-iteratortolist
|
||||
ThrowCompletionOr<MarkedVector<Value>> iterator_to_list(VM& vm, IteratorRecord& iterator_record)
|
||||
ThrowCompletionOr<GC::MarkedVector<Value>> iterator_to_list(VM& vm, IteratorRecord& iterator_record)
|
||||
{
|
||||
// 1. Let values be a new empty List.
|
||||
MarkedVector<Value> values(vm.heap());
|
||||
GC::MarkedVector<Value> values(vm.heap());
|
||||
|
||||
// 2. Repeat,
|
||||
while (true) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue