Re-arrange coro_susp_point's and coro stacks

This commit is contained in:
Nigel Tao committed 2019-02-09 11:15:56 +11:00
1 parent 9518af5a95
commit 957182fde7
2 files changed
+41 -21

No files matched your search

+22 -7
View File
@@ -747,6 +747,28 @@ func (g *gen) writeStructPrivateImpl(b *buffer, n *a.Struct) error {
}
if n.Classy() {
// TODO: allow max depth > 1 for recursive coroutines.
const maxDepth = 1
b.writeb('\n')
for _, file := range g.files {
for _, tld := range file.TopLevelDecls() {
if tld.Kind() != a.KFunc {
continue
}
o := tld.AsFunc()
if o.Receiver() != n.QID() || !o.Effect().Coroutine() {
continue
}
k := g.funks[o.QQID()]
if k.coroSuspPoint == 0 {
continue
}
b.printf("uint32_t %s%s[%d];\n", pPrefix, o.FuncName().Str(g.tm), maxDepth)
}
}
b.writeb('\n')
for _, file := range g.files {
for _, tld := range file.TopLevelDecls() {
@@ -762,13 +784,6 @@ func (g *gen) writeStructPrivateImpl(b *buffer, n *a.Struct) error {
continue
}
// TODO: allow max depth > 1 for recursive coroutines.
const maxDepth = 1
if k.coroSuspPoint != 0 {
b.printf("uint32_t %s%s[%d];\n", pPrefix, o.FuncName().Str(g.tm), maxDepth)
}
oldLenB0 := len(*b)
b.writes("struct {\n")
oldLenB1 := len(*b)