Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
Editorial: use new IteratorStepValue AO (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot authored Apr 5, 2024
1 parent f1427ec commit b4ccc31
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 50 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"check-format": "emu-format --check spec.html"
},
"devDependencies": {
"@tc39/ecma262-biblio": "2.1.2407",
"@tc39/ecma262-biblio": "2.1.2678",
"ecmarkup": "^15.0.0"
}
}
70 changes: 29 additions & 41 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,8 @@ <h1>Iterator.prototype.map ( _mapper_ )</h1>
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _mapper_ and performs the following steps when called:
1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *undefined*.
1. Let _value_ be ? IteratorValue(_next_).
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return *undefined*.
1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_mapped_, _iterated_).
1. Let _completion_ be Completion(Yield(_mapped_)).
Expand All @@ -375,9 +374,8 @@ <h1>Iterator.prototype.filter ( _predicate_ )</h1>
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _predicate_ and performs the following steps when called:
1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *undefined*.
1. Let _value_ be ? IteratorValue(_next_).
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return *undefined*.
1. Let _selected_ be Completion(Call(_predicate_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_selected_, _iterated_).
1. If ToBoolean(_selected_) is *true*, then
Expand Down Expand Up @@ -408,9 +406,9 @@ <h1>Iterator.prototype.take ( _limit_ )</h1>
1. Return ? IteratorClose(_iterated_, NormalCompletion(*undefined*)).
1. If _remaining_ is not +∞, then
1. Set _remaining_ to _remaining_ - 1.
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *undefined*.
1. Let _completion_ be Completion(Yield(? IteratorValue(_next_))).
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return *undefined*.
1. Let _completion_ be Completion(Yield(_value_)).
1. IfAbruptCloseIterator(_completion_, _iterated_).
1. Let _result_ be CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%, « [[UnderlyingIterator]] »).
1. Set _result_.[[UnderlyingIterator]] to _iterated_.
Expand All @@ -437,9 +435,9 @@ <h1>Iterator.prototype.drop ( _limit_ )</h1>
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *undefined*.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *undefined*.
1. Let _completion_ be Completion(Yield(? IteratorValue(_next_))).
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return *undefined*.
1. Let _completion_ be Completion(Yield(_value_)).
1. IfAbruptCloseIterator(_completion_, _iterated_).
1. Let _result_ be CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%, « [[UnderlyingIterator]] »).
1. Set _result_.[[UnderlyingIterator]] to _iterated_.
Expand All @@ -458,22 +456,19 @@ <h1>Iterator.prototype.flatMap ( _mapper_ )</h1>
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _mapper_ and performs the following steps when called:
1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *undefined*.
1. Let _value_ be ? IteratorValue(_next_).
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return *undefined*.
1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_mapped_, _iterated_).
1. Let _innerIterator_ be Completion(GetIteratorFlattenable(_mapped_, ~reject-strings~)).
1. IfAbruptCloseIterator(_innerIterator_, _iterated_).
1. Let _innerAlive_ be *true*.
1. Repeat, while _innerAlive_ is *true*,
1. Let _innerNext_ be Completion(IteratorStep(_innerIterator_)).
1. IfAbruptCloseIterator(_innerNext_, _iterated_).
1. If _innerNext_ is *false*, then
1. Let _innerValue_ be Completion(IteratorStepValue(_innerIterator_)).
1. IfAbruptCloseIterator(_innerValue_, _iterated_).
1. If _innerValue_ is ~done~, then
1. Set _innerAlive_ to *false*.
1. Else,
1. Let _innerValue_ be Completion(IteratorValue(_innerNext_)).
1. IfAbruptCloseIterator(_innerValue_, _iterated_).
1. Let _completion_ be Completion(Yield(_innerValue_)).
1. If _completion_ is an abrupt completion, then
1. Let _backupCompletion_ be Completion(IteratorClose(_innerIterator_, _completion_)).
Expand All @@ -495,17 +490,15 @@ <h1>Iterator.prototype.reduce ( _reducer_ [ , _initialValue_ ] )</h1>
1. If IsCallable(_reducer_) is *false*, throw a *TypeError* exception.
1. Let _iterated_ be ? GetIteratorDirect(_O_).
1. If _initialValue_ is not present, then
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, throw a *TypeError* exception.
1. Let _accumulator_ be ? IteratorValue(_next_).
1. Let _accumulator_ be ? IteratorStepValue(_iterated_).
1. If _accumulator_ is ~done~, throw a *TypeError* exception.
1. Let _counter_ be 1.
1. Else,
1. Let _accumulator_ be _initialValue_.
1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return _accumulator_.
1. Let _value_ be ? IteratorValue(_next_).
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return _accumulator_.
1. Let _result_ be Completion(Call(_reducer_, *undefined*, « _accumulator_, _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_result_, _iterated_).
1. Set _accumulator_ to _result_.[[Value]].
Expand All @@ -522,9 +515,8 @@ <h1>Iterator.prototype.toArray ( )</h1>
1. Let _iterated_ be ? GetIteratorDirect(_O_).
1. Let _items_ be a new empty List.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return CreateArrayFromList(_items_).
1. Let _value_ be ? IteratorValue(_next_).
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return CreateArrayFromList(_items_).
1. Append _value_ to _items_.
</emu-alg>
</emu-clause>
Expand All @@ -539,9 +531,8 @@ <h1>Iterator.prototype.forEach ( _fn_ )</h1>
1. Let _iterated_ be ? GetIteratorDirect(_O_).
1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *undefined*.
1. Let _value_ be ? IteratorValue(_next_).
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return *undefined*.
1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_result_, _iterated_).
1. Set _counter_ to _counter_ + 1.
Expand All @@ -558,9 +549,8 @@ <h1>Iterator.prototype.some ( _predicate_ )</h1>
1. Let _iterated_ be ? GetIteratorDirect(_O_).
1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *false*.
1. Let _value_ be ? IteratorValue(_next_).
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return *false*.
1. Let _result_ be Completion(Call(_predicate_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_result_, _iterated_).
1. If ToBoolean(_result_) is *true*, return ? IteratorClose(_iterated_, NormalCompletion(*true*)).
Expand All @@ -578,9 +568,8 @@ <h1>Iterator.prototype.every ( _predicate_ )</h1>
1. Let _iterated_ be ? GetIteratorDirect(_O_).
1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *true*.
1. Let _value_ be ? IteratorValue(_next_).
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return *true*.
1. Let _result_ be Completion(Call(_predicate_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_result_, _iterated_).
1. If ToBoolean(_result_) is *false*, return ? IteratorClose(_iterated_, NormalCompletion(*false*)).
Expand All @@ -598,9 +587,8 @@ <h1>Iterator.prototype.find ( _predicate_ )</h1>
1. Let _iterated_ be ? GetIteratorDirect(_O_).
1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *undefined*.
1. Let _value_ be ? IteratorValue(_next_).
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return *undefined*.
1. Let _result_ be Completion(Call(_predicate_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_result_, _iterated_).
1. If ToBoolean(_result_) is *true*, return ? IteratorClose(_iterated_, NormalCompletion(_value_)).
Expand Down

0 comments on commit b4ccc31

Please sign in to comment.