Don't have suspend state if we don't suspend.

This commit is contained in:
Nigel Tao committed 2017-08-26 17:27:01 +10:00
1 parent a8423cee70
commit 018d8d1893
4 files changed
+18 -127

No files matched your search

+3
View File
@@ -558,6 +558,9 @@ func (g *gen) writeStruct(b *buffer, n *a.Struct) error {
if o.Receiver() != n.Name() || !o.Suspendible() {
continue
}
if k := g.funks[o.QID()]; k.coroSuspPoint == 0 {
continue
}
// TODO: allow max depth > 1 for recursive coroutines.
const maxDepth = 1
b.writes("struct {\n")
+14 -2
View File
@@ -97,9 +97,21 @@ func (g *gen) writeFuncImpl(b *buffer, n *a.Func) error {
}
b.writes("{\n")
b.writex(k.bHeader)
b.writex(k.bBodyResume)
if k.suspendible {
if k.coroSuspPoint > 0 {
b.writex(k.bBodyResume)
} else {
b.writes("{\n")
}
}
b.writex(k.bBody)
b.writex(k.bBodySuspend)
if k.suspendible {
if k.coroSuspPoint > 0 {
b.writex(k.bBodySuspend)
} else {
b.writes("}\n")
}
}
b.writex(k.bFooter)
b.writes("}\n\n")
return nil