mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 03:32:45 +00:00 
			
		
		
		
	LibJS: Port iterator_step() to GCPtr
This commit is contained in:
		
							parent
							
								
									e54536421a
								
							
						
					
					
						commit
						aff1ec6014
					
				
					 12 changed files with 19 additions and 19 deletions
				
			
		|  | @ -1521,7 +1521,7 @@ void IDL::ParameterizedType::generate_sequence_from_iterable(SourceGenerator& ge | |||
| 
 | ||||
|     sequence_generator.append(R"~~~( | ||||
|     for (;;) { | ||||
|         auto* next@recursion_depth@ = TRY(JS::iterator_step(vm, iterator@recursion_depth@)); | ||||
|         auto next@recursion_depth@ = TRY(JS::iterator_step(vm, iterator@recursion_depth@)); | ||||
|         if (!next@recursion_depth@) | ||||
|             break; | ||||
| 
 | ||||
|  |  | |||
|  | @ -191,7 +191,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from) | |||
|             auto property_key = PropertyKey { k }; | ||||
| 
 | ||||
|             // iii. Let next be ? IteratorStep(iteratorRecord).
 | ||||
|             auto* next = TRY(iterator_step(vm, iterator)); | ||||
|             auto next = TRY(iterator_step(vm, iterator)); | ||||
| 
 | ||||
|             // iv. If next is false, then
 | ||||
|             if (!next) { | ||||
|  |  | |||
|  | @ -254,7 +254,7 @@ ThrowCompletionOr<Vector<String>> string_list_from_iterable(VM& vm, Value iterab | |||
|     Vector<String> list; | ||||
| 
 | ||||
|     // 4. Let next be true.
 | ||||
|     Object* next = nullptr; | ||||
|     GCPtr<Object> next; | ||||
| 
 | ||||
|     // 5. Repeat, while next is not false,
 | ||||
|     do { | ||||
|  |  | |||
|  | @ -104,7 +104,7 @@ ThrowCompletionOr<Value> iterator_value(VM& vm, Object& iterator_result) | |||
| } | ||||
| 
 | ||||
| // 7.4.6 IteratorStep ( iteratorRecord ), https://tc39.es/ecma262/#sec-iteratorstep
 | ||||
| ThrowCompletionOr<Object*> iterator_step(VM& vm, Iterator const& iterator_record) | ||||
| ThrowCompletionOr<GCPtr<Object>> iterator_step(VM& vm, Iterator const& iterator_record) | ||||
| { | ||||
|     // 1. Let result be ? IteratorNext(iteratorRecord).
 | ||||
|     auto result = TRY(iterator_next(vm, iterator_record)); | ||||
|  | @ -117,7 +117,7 @@ ThrowCompletionOr<Object*> iterator_step(VM& vm, Iterator const& iterator_record | |||
|         return nullptr; | ||||
| 
 | ||||
|     // 4. Return result.
 | ||||
|     return result.ptr(); | ||||
|     return result; | ||||
| } | ||||
| 
 | ||||
| // 7.4.7 IteratorClose ( iteratorRecord, completion ), https://tc39.es/ecma262/#sec-iteratorclose
 | ||||
|  | @ -222,7 +222,7 @@ Completion get_iterator_values(VM& vm, Value iterable, IteratorValueCallback cal | |||
|     auto iterator_record = TRY(get_iterator(vm, iterable, IteratorHint::Sync, move(method))); | ||||
| 
 | ||||
|     while (true) { | ||||
|         auto* next_object = TRY(iterator_step(vm, iterator_record)); | ||||
|         auto next_object = TRY(iterator_step(vm, iterator_record)); | ||||
|         if (!next_object) | ||||
|             return {}; | ||||
| 
 | ||||
|  |  | |||
|  | @ -24,7 +24,7 @@ enum class IteratorHint { | |||
| 
 | ||||
| ThrowCompletionOr<Iterator> get_iterator(VM&, Value, IteratorHint = IteratorHint::Sync, Optional<Value> method = {}); | ||||
| ThrowCompletionOr<NonnullGCPtr<Object>> iterator_next(VM&, Iterator const&, Optional<Value> = {}); | ||||
| ThrowCompletionOr<Object*> iterator_step(VM&, Iterator const&); | ||||
| ThrowCompletionOr<GCPtr<Object>> iterator_step(VM&, Iterator const&); | ||||
| ThrowCompletionOr<bool> iterator_complete(VM&, Object& iterator_result); | ||||
| ThrowCompletionOr<Value> iterator_value(VM&, Object& iterator_result); | ||||
| Completion iterator_close(VM&, Iterator const&, Completion); | ||||
|  |  | |||
|  | @ -64,7 +64,7 @@ static ThrowCompletionOr<Value> perform_promise_common(VM& vm, Iterator& iterato | |||
|             iterator_record.done = true; | ||||
|             return next_or_error.release_error(); | ||||
|         } | ||||
|         auto* next = next_or_error.release_value(); | ||||
|         auto next = next_or_error.release_value(); | ||||
| 
 | ||||
|         // d. If next is false, then
 | ||||
|         if (!next) { | ||||
|  |  | |||
|  | @ -290,7 +290,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::union_) | |||
|     // 7. Repeat, while next is not false,
 | ||||
|     while (next) { | ||||
|         // a. Set next to ? IteratorStep(keysIter).
 | ||||
|         auto* iterator_result = TRY(iterator_step(vm, keys_iterator)); | ||||
|         auto iterator_result = TRY(iterator_step(vm, keys_iterator)); | ||||
|         next = iterator_result; | ||||
| 
 | ||||
|         // b. If next is not false, then
 | ||||
|  | @ -358,7 +358,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::intersection) | |||
|         // c. Repeat, while next is not false,
 | ||||
|         while (next) { | ||||
|             // i. Set next to ? IteratorStep(keysIter).
 | ||||
|             auto* iterator_result = TRY(iterator_step(vm, keys_iterator)); | ||||
|             auto iterator_result = TRY(iterator_step(vm, keys_iterator)); | ||||
|             next = iterator_result; | ||||
| 
 | ||||
|             // ii. If next is not false, then
 | ||||
|  | @ -436,7 +436,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::difference) | |||
|         // c. Repeat, while next is not false,
 | ||||
|         while (next) { | ||||
|             // i. Set next to ? IteratorStep(keysIter).
 | ||||
|             auto* iterator_result = TRY(iterator_step(vm, keys_iterator)); | ||||
|             auto iterator_result = TRY(iterator_step(vm, keys_iterator)); | ||||
|             next = iterator_result; | ||||
| 
 | ||||
|             // ii. If next is not false, then
 | ||||
|  | @ -486,7 +486,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::symmetric_difference) | |||
|     // 7. Repeat, while next is not false,
 | ||||
|     while (next) { | ||||
|         // a. Set next to ? IteratorStep(keysIter).
 | ||||
|         auto* iterator_result = TRY(iterator_step(vm, keys_iterator)); | ||||
|         auto iterator_result = TRY(iterator_step(vm, keys_iterator)); | ||||
|         next = iterator_result; | ||||
| 
 | ||||
|         // b. If next is not false, then
 | ||||
|  | @ -576,7 +576,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::is_superset_of) | |||
|     // 8. Repeat, while next is not false,
 | ||||
|     while (next) { | ||||
|         // a. Set next to ? IteratorStep(keysIter).
 | ||||
|         auto* iterator_result = TRY(iterator_step(vm, keys_iterator)); | ||||
|         auto iterator_result = TRY(iterator_step(vm, keys_iterator)); | ||||
|         next = iterator_result; | ||||
| 
 | ||||
|         // b. If next is not false, then
 | ||||
|  | @ -630,7 +630,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::is_disjoint_from) | |||
|         // c. Repeat, while next is not false,
 | ||||
|         while (next) { | ||||
|             // i. Set next to ? IteratorStep(keysIter).
 | ||||
|             auto* iterator_result = TRY(iterator_step(vm, keys_iterator)); | ||||
|             auto iterator_result = TRY(iterator_step(vm, keys_iterator)); | ||||
|             next = iterator_result; | ||||
| 
 | ||||
|             // ii. If next is not false, then
 | ||||
|  |  | |||
|  | @ -52,7 +52,7 @@ ThrowCompletionOr<MarkedVector<Value>> iterable_to_list_of_type(VM& vm, Value it | |||
|     // 4. Repeat, while next is not false,
 | ||||
|     while (next) { | ||||
|         // a. Set next to ? IteratorStep(iteratorRecord).
 | ||||
|         auto* iterator_result = TRY(iterator_step(vm, iterator_record)); | ||||
|         auto iterator_result = TRY(iterator_step(vm, iterator_record)); | ||||
|         next = iterator_result; | ||||
| 
 | ||||
|         // b. If next is not false, then
 | ||||
|  |  | |||
|  | @ -543,7 +543,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::fields) | |||
|     // 7. Repeat, while next is not false,
 | ||||
|     while (true) { | ||||
|         // a. Set next to ? IteratorStep(iteratorRecord).
 | ||||
|         auto* next = TRY(iterator_step(vm, iterator_record)); | ||||
|         auto next = TRY(iterator_step(vm, iterator_record)); | ||||
| 
 | ||||
|         // b. If next is not false, then
 | ||||
|         if (!next) | ||||
|  |  | |||
|  | @ -526,7 +526,7 @@ ThrowCompletionOr<MarkedVector<Instant*>> get_possible_instants_for(VM& vm, Valu | |||
|     auto list = MarkedVector<Instant*> { vm.heap() }; | ||||
| 
 | ||||
|     // 5. Let next be true.
 | ||||
|     Object* next = nullptr; | ||||
|     GCPtr<Object> next; | ||||
| 
 | ||||
|     // 6. Repeat, while next is not false,
 | ||||
|     do { | ||||
|  |  | |||
|  | @ -468,7 +468,7 @@ ThrowCompletionOr<void> VM::iterator_binding_initialization(BindingPattern const | |||
|             // 3. Let n be 0.
 | ||||
|             // 4. Repeat,
 | ||||
|             while (true) { | ||||
|                 ThrowCompletionOr<Object*> next { nullptr }; | ||||
|                 ThrowCompletionOr<GCPtr<Object>> next { nullptr }; | ||||
| 
 | ||||
|                 // a. If iteratorRecord.[[Done]] is false, then
 | ||||
|                 if (!iterator_record.done) { | ||||
|  |  | |||
|  | @ -74,7 +74,7 @@ static JS::ThrowCompletionOr<Vector<String>> convert_value_to_sequence_of_string | |||
|     // 3. Repeat
 | ||||
|     for (;;) { | ||||
|         // 1. Let next be ? IteratorStep(iter).
 | ||||
|         auto* next = TRY(JS::iterator_step(vm, iterator)); | ||||
|         auto next = TRY(JS::iterator_step(vm, iterator)); | ||||
| 
 | ||||
|         // 2. If next is false, then return an IDL sequence value of type sequence<T> of length i, where the value of the element at index j is Sj.
 | ||||
|         if (!next) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Linus Groh
						Linus Groh