This repository was archived by the owner on Jan 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathgenerator-definitions-patch.html
76 lines (73 loc) · 5.2 KB
/
generator-definitions-patch.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<emu-clause id="sec-asyncgenerator-definitions-evaluation">
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>YieldExpression : `yield`</emu-grammar>
<emu-alg>
1. <ins>Let _generatorKind_ be ! GetGeneratorKind().</ins>
1. <ins>If _generatorKind_ is ~async~, then return ? AsyncGeneratorYield(*undefined*).</ins>
1. <ins>Otherwise, r</ins><del>R</del>eturn ? GeneratorYield(CreateIterResultObject(*undefined*, *false*)).
</emu-alg>
<emu-grammar>YieldExpression : `yield` AssignmentExpression</emu-grammar>
<emu-alg>
1. <ins>Let _generatorKind_ be ! GetGeneratorKind().</ins>
1. Let _exprRef_ be the result of evaluating |AssignmentExpression|.
1. Let _value_ be ? GetValue(_exprRef_).
1. <ins>If _generatorKind_ is ~async~, then return ? AsyncGeneratorYield(_value_).</ins>
1. <ins>Otherwise, r</ins><del>R</del>eturn ? GeneratorYield(CreateIterResultObject(_value_, *false*)).
</emu-alg>
<emu-grammar>
YieldExpression : `yield` `*` AssignmentExpression
</emu-grammar>
<emu-alg>
1. <ins>Let _generatorKind_ be ! GetGeneratorKind().</ins>
1. Let _exprRef_ be the result of evaluating |AssignmentExpression|.
1. Let _value_ be ? GetValue(_exprRef_).
1. Let _iteratorRecord_ be ? GetIterator(_value_<ins>, _generatorKind_</ins>).
1. Let _iterator_ be _iteratorRecord_.[[Iterator]].
1. Let _received_ be NormalCompletion(*undefined*).
1. Repeat
1. If _received_.[[Type]] is ~normal~, then
1. <del>Let _innerResult_ be ? IteratorNext(_iteratorRecord_, _received_.[[Value]]).</del>
1. <ins>Let _innerResult_ be ? Call(_iteratorRecord_.[[NextMethod]], _iteratorRecord_.[[Iterator]], « _received_.[[Value]] »).</ins>
1. <ins>If _generatorKind_ is ~async~, then set _innerResult_ to ? Await(_innerResult_).</ins>
1. <ins>If Type(_innerResult_) is not Object, throw a *TypeError* exception.</ins>
1. Let _done_ be ? IteratorComplete(_innerResult_).
1. If _done_ is *true*, then
1. Return ? IteratorValue(_innerResult_).
1. <ins>If _generatorKind_ is ~async~, then let _received_ be AsyncGeneratorYield(? IteratorValue(_innerResult_)).</ins>
1. <ins>Else, l</ins><del>L</del>et _received_ be GeneratorYield(_innerResult_).
1. Else if _received_.[[Type]] is ~throw~, then
1. Let _throw_ be ? GetMethod(_iterator_, `"throw"`).
1. If _throw_ is not *undefined*, then
1. Let _innerResult_ be ? Call(_throw_, _iterator_, « _received_.[[Value]] »).
1. <ins>If _generatorKind_ is ~async~, then set _innerResult_ to ? Await(_innerResult_).</ins>
1. NOTE: Exceptions from the inner iterator `throw` method are propagated. Normal completions from an inner `throw` method are processed similarly to an inner `next`.
1. If Type(_innerResult_) is not Object, throw a *TypeError* exception.
1. Let _done_ be ? IteratorComplete(_innerResult_).
1. If _done_ is *true*, then
1. Return ? IteratorValue(_innerResult_).
1. <ins>If _generatorKind_ is ~async~, then let _received_ be AsyncGeneratorYield(? IteratorValue(_innerResult_)).</ins>
1. <ins>Else, l</ins><del>L</del>et _received_ be GeneratorYield(_innerResult_).
1. Else,
1. NOTE: If _iterator_ does not have a `throw` method, this throw is going to terminate the `yield*` loop. But first we need to give _iterator_ a chance to clean up.
1. <ins>Let _closeCompletion_ be Completion{[[Type]]: ~normal~, [[Value]]: ~empty~, [[Target]]: ~empty~}.</ins>
1. <ins>If _generatorKind_ is ~async~, perform ? AsyncIteratorClose(_iteratorRecord_, _closeCompletion_).</ins>
1. <ins>Else, p</ins><del>P</del>erform ? IteratorClose(_iteratorRecord_, <del>Completion{[[Type]]: ~normal~, [[Value]]: ~empty~, [[Target]]: ~empty~}</del><ins>_closeCompletion_</ins>).
1. NOTE: The next step throws a *TypeError* to indicate that there was a `yield*` protocol violation: _iterator_ does not have a `throw` method.
1. Throw a *TypeError* exception.
1. Else,
1. Assert: _received_.[[Type]] is ~return~.
1. Let _return_ be ? GetMethod(_iterator_, `"return"`).
1. If _return_ is *undefined*, <del>return Completion(_received_).</del><ins>then:</ins>
1. <ins>If _generatorKind_ is ~async~, then set _received_.[[Value]] to ? Await(_received_.[[Value]]).</ins>
1. <ins>Return Completion(_received_).</ins>
1. Let _innerReturnResult_ be ? Call(_return_, _iterator_, « _received_.[[Value]] »).
1. <ins>If _generatorKind_ is ~async~, then set _innerReturnResult_ to ? Await(_innerReturnResult_).</ins>
1. If Type(_innerReturnResult_) is not Object, throw a *TypeError* exception.
1. Let _done_ be ? IteratorComplete(_innerReturnResult_).
1. If _done_ is *true*, then
1. Let _value_ be ? IteratorValue(_innerReturnResult_).
1. Return Completion{[[Type]]: ~return~, [[Value]]: _value_, [[Target]]: ~empty~}.
1. <ins>If _generatorKind_ is ~async~, then let _received_ be AsyncGeneratorYield(? IteratorValue(_innerResult_)).</ins>
1. <ins>Else, l</ins><del>L</del>et _received_ be GeneratorYield(_innerResult_).
</emu-alg>
</emu-clause>