cgen: simplify 1-elem in-case-of-recursion arrays

This commit is contained in:
Nigel Tao committed 2023-11-05 11:44:21 +11:00
1 parent df1d4f64e2
commit 2c2bb9baa5
6 files changed
+1025 -1034

No files matched your search

+1 -2
View File
@@ -280,8 +280,7 @@ func (g *gen) writeResumeSuspend1(b *buffer, f *funk, n *a.Var, suspend bool) er
} else {
local := fmt.Sprintf("%s%s", vPrefix, n.Name().Str(g.tm))
lhs := local
// TODO: don't hard-code [0], and allow recursive coroutines.
rhs := fmt.Sprintf("self->private_data.%s%s[0].%s", sPrefix, g.currFunk.astFunc.FuncName().Str(g.tm), lhs)
rhs := fmt.Sprintf("self->private_data.%s%s.%s", sPrefix, g.currFunk.astFunc.FuncName().Str(g.tm), lhs)
if suspend {
lhs, rhs = rhs, lhs
}