Skip to content

Commit

Permalink
Fix GeneratorYield callsites to create an iter object
Browse files Browse the repository at this point in the history
  • Loading branch information
syg committed Jan 6, 2022
1 parent 0211cd8 commit 0fc1e8b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -7167,7 +7167,7 @@ <h1>
<emu-alg>
1. Let _closure_ be a new Abstract Closure with no parameters that captures _list_ and performs the following steps when called:
1. For each element _E_ of _list_, do
1. Perform ? GeneratorYield(_E_).
1. Perform ? GeneratorYield(! CreateIterResultObject(_E_, *false*)).
1. Return *undefined*.
1. Let _iterator_ be ! CreateIteratorFromClosure(_closure_, ~empty~, %IteratorPrototype%).
1. Return Record { [[Iterator]]: _iterator_, [[NextMethod]]: %GeneratorFunction.prototype.prototype.next%, [[Done]]: *false* }.
Expand Down Expand Up @@ -34274,7 +34274,7 @@ <h1>String.prototype [ @@iterator ] ( )</h1>
1. Let _nextIndex_ be _position_ + _cp_.[[CodeUnitCount]].
1. Let _resultString_ be the substring of _s_ from _position_ to _nextIndex_.
1. Set _position_ to _nextIndex_.
1. Perform ? GeneratorYield(_resultString_).
1. Perform ? GeneratorYield(! CreateIterResultObject(_resultString_, *false*)).
1. Return *undefined*.
1. Return ! CreateIteratorFromClosure(_closure_, *"%StringIteratorPrototype%"*, %StringIteratorPrototype%).
</emu-alg>
Expand Down Expand Up @@ -36541,14 +36541,14 @@ <h1>
1. Let _match_ be ? RegExpExec(_R_, _S_).
1. If _match_ is *null*, return *undefined*.
1. If _global_ is *false*, then
1. Perform ? GeneratorYield(_match_).
1. Perform ? GeneratorYield(! CreateIterResultObject(_match_, *false*)).
1. Return *undefined*.
1. Let _matchStr_ be ? ToString(? Get(_match_, *"0"*)).
1. If _matchStr_ is the empty String, then
1. Let _thisIndex_ be ℝ(? ToLength(? Get(_R_, *"lastIndex"*))).
1. Let _nextIndex_ be ! AdvanceStringIndex(_S_, _thisIndex_, _fullUnicode_).
1. Perform ? Set(_R_, *"lastIndex"*, 𝔽(_nextIndex_), *true*).
1. Perform ? GeneratorYield(_match_).
1. Perform ? GeneratorYield(! CreateIterResultObject(_match_, *false*)).
1. Return ! CreateIteratorFromClosure(_closure_, *"%RegExpStringIteratorPrototype%"*, %RegExpStringIteratorPrototype%).
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -37939,14 +37939,15 @@ <h1>
1. Else,
1. Let _len_ be ? LengthOfArrayLike(_array_).
1. If _index_ &ge; _len_, return *undefined*.
1. If _kind_ is ~key~, perform ? GeneratorYield(𝔽(_index_)).
1. If _kind_ is ~key~, perform ? GeneratorYield(! CreateIterResultObject(𝔽(_index_), *false*)).
1. Else,
1. Let _elementKey_ be ! ToString(𝔽(_index_)).
1. Let _elementValue_ be ? Get(_array_, _elementKey_).
1. If _kind_ is ~value~, perform ? GeneratorYield(_elementValue_).
1. If _kind_ is ~value~, perform ? GeneratorYield(! CreateIterResultObject(_elementValue_, *false*)).
1. Else,
1. Assert: _kind_ is ~key+value~.
1. Perform ? GeneratorYield(! CreateArrayFromList(&laquo; 𝔽(_index_), _elementValue_ &raquo;)).
1. Let _result_ be ! CreateArrayFromList(&laquo; 𝔽(_index_), _elementValue_ &raquo;).
1. Perform ? GeneratorYield(! CreateIterResultObject(_result_, *false*)).
1. Set _index_ to _index_ + 1.
1. Return ! CreateIteratorFromClosure(_closure_, *"%ArrayIteratorPrototype%"*, %ArrayIteratorPrototype%).
</emu-alg>
Expand Down Expand Up @@ -39749,7 +39750,7 @@ <h1>
1. Else,
1. Assert: _kind_ is ~key+value~.
1. Let _result_ be ! CreateArrayFromList(&laquo; _e_.[[Key]], _e_.[[Value]] &raquo;).
1. Perform ? GeneratorYield(_result_).
1. Perform ? GeneratorYield(! CreateIterResultObject(_result_, *false*)).
1. NOTE: The number of elements in _entries_ may have changed while execution of this abstract operation was paused by Yield.
1. Set _numEntries_ to the number of elements of _entries_.
1. Return *undefined*.
Expand Down Expand Up @@ -40034,10 +40035,11 @@ <h1>
1. Set _index_ to _index_ + 1.
1. If _e_ is not ~empty~, then
1. If _kind_ is ~key+value~, then
1. Perform ? GeneratorYield(! CreateArrayFromList(&laquo; _e_, _e_ &raquo;)).
1. Let _result_ be ! CreateArrayFromList(&laquo; _e_, _e_ &raquo;).
1. Perform ? GeneratorYield(! CreateIterResultObject(_result_, *false*)).
1. Else,
1. Assert: _kind_ is ~value~.
1. Perform ? GeneratorYield(_e_).
1. Perform ? GeneratorYield(! CreateIterResultObject(_e_, *false*)).
1. NOTE: The number of elements in _entries_ may have changed while execution of this abstract operation was paused by Yield.
1. Set _numEntries_ to the number of elements of _entries_.
1. Return *undefined*.
Expand Down

0 comments on commit 0fc1e8b

Please sign in to comment.