MCPcopy Create free account
hub / github.com/dispatchrun/coroutine / SquareGenerator

Function SquareGenerator

compiler/testdata/coroutine_durable.go:24–57  ·  view source on GitHub ↗

go:noinline

(_fn0 int)

Source from the content-addressed store, hash-verified

22
23//go:noinline
24func SquareGenerator(_fn0 int) {
25 _c := coroutine.LoadContext[int, any]()
26 var _f0 *struct {
27 IP int
28 X0 int
29 X1 int
30 } = coroutine.Push[struct {
31 IP int
32 X0 int
33 X1 int
34 }](&_c.Stack)
35 if _f0.IP == 0 {
36 *_f0 = struct {
37 IP int
38 X0 int
39 X1 int
40 }{X0: _fn0}
41 }
42 defer func() {
43 if !_c.Unwinding() {
44 coroutine.Pop(&_c.Stack)
45 }
46 }()
47 switch {
48 case _f0.IP < 2:
49 _f0.X1 = 1
50 _f0.IP = 2
51 fallthrough
52 case _f0.IP < 3:
53 for ; _f0.X1 <= _f0.X0; _f0.X1, _f0.IP = _f0.X1+1, 2 {
54 coroutine.Yield[int, any](_f0.X1 * _f0.X1)
55 }
56 }
57}
58
59//go:noinline
60func SquareGeneratorTwice(_fn0 int) {

Callers 2

SquareGeneratorTwiceFunction · 0.70
SquareGeneratorTwiceLoopFunction · 0.70

Calls 3

LoadContextFunction · 0.92
PopFunction · 0.92
UnwindingMethod · 0.80

Tested by

no test coverage detected