Simplify cgen of empty functions

This commit is contained in:
Nigel Tao committed 2020-04-16 09:34:50 +10:00
1 parent e39f3cbf42
commit 9f6c40246f
2 files changed
+13 -79

No files matched your search

+13 -9
View File
@@ -188,16 +188,20 @@ func (g *gen) writeFuncImpl(b *buffer, n *a.Func) error {
return err
}
b.writes("{\n")
b.writex(k.bPrologue)
if k.astFunc.Effect().Coroutine() {
b.writex(k.bBodyResume)
}
b.writex(k.bBody)
if k.astFunc.Effect().Coroutine() {
b.writex(k.bBodySuspend)
} else if k.hasGotoOK {
b.writes("\ngoto ok;ok:\n") // The goto avoids the "unused label" warning.
if (len(n.Body()) != 0) || n.Effect().Coroutine() || (n.Out() != nil) {
b.writex(k.bPrologue)
if n.Effect().Coroutine() {
b.writex(k.bBodyResume)
}
b.writex(k.bBody)
if n.Effect().Coroutine() {
b.writex(k.bBodySuspend)
} else if k.hasGotoOK {
b.writes("\ngoto ok;ok:\n") // The goto avoids the "unused label" warning.
}
}
b.writex(k.bEpilogue)
b.writes("}\n\n")
return nil