MCPcopy Index your code
hub / github.com/dispatchrun/coroutine / EvenSquareGenerator

Function EvenSquareGenerator

compiler/testdata/coroutine_durable.go:127–172  ·  view source on GitHub ↗

go:noinline

(_fn0 int)

Source from the content-addressed store, hash-verified

125
126//go:noinline
127func EvenSquareGenerator(_fn0 int) {
128 _c := coroutine.LoadContext[int, any]()
129 var _f0 *struct {
130 IP int
131 X0 int
132 X1 int
133 X2 int
134 } = coroutine.Push[struct {
135 IP int
136 X0 int
137 X1 int
138 X2 int
139 }](&_c.Stack)
140 if _f0.IP == 0 {
141 *_f0 = struct {
142 IP int
143 X0 int
144 X1 int
145 X2 int
146 }{X0: _fn0}
147 }
148 defer func() {
149 if !_c.Unwinding() {
150 coroutine.Pop(&_c.Stack)
151 }
152 }()
153 switch {
154 case _f0.IP < 2:
155 _f0.X1 = 1
156 _f0.IP = 2
157 fallthrough
158 case _f0.IP < 4:
159 for ; _f0.X1 <= _f0.X0; _f0.X1, _f0.IP = _f0.X1+1, 2 {
160 switch {
161 case _f0.IP < 3:
162 _f0.X2 = _f0.X1 % 2
163 _f0.IP = 3
164 fallthrough
165 case _f0.IP < 4:
166 if _f0.X2 == 0 {
167 coroutine.Yield[int, any](_f0.X1 * _f0.X1)
168 }
169 }
170 }
171 }
172}
173
174//go:noinline
175func NestedLoops(_fn0 int) (_ int) {

Callers

nothing calls this directly

Calls 3

LoadContextFunction · 0.92
PopFunction · 0.92
UnwindingMethod · 0.80

Tested by

no test coverage detected