Roll back 'unconditionally resume local vars'

See the previous commit for the rationale.
This commit is contained in:
Nigel Tao committed 2018-02-22 11:23:58 +11:00
1 parent 2b6b0acb4f
commit 5a927d6905
5 files changed
+129 -73

No files matched your search

+9 -3
View File
@@ -225,12 +225,18 @@ func (g *gen) writeFuncImplHeader(b *buffer) error {
func (g *gen) writeFuncImplBodyResume(b *buffer) error {
if g.currFunk.suspendible {
if err := g.writeResumeSuspend(b, g.currFunk.astFunc.Body(), false, false); err != nil {
return err
}
// TODO: don't hard-code [0], and allow recursive coroutines.
b.printf("uint32_t coro_susp_point = self->private_impl.%s%s[0].coro_susp_point;\n",
cPrefix, g.currFunk.astFunc.FuncName().Str(g.tm))
b.printf("if (coro_susp_point) {\n")
if err := g.writeResumeSuspend(b, g.currFunk.astFunc.Body(), false, false); err != nil {
return err
}
b.writes("} else {\n")
if err := g.writeResumeSuspend(b, g.currFunk.astFunc.Body(), false, true); err != nil {
return err
}
b.writes("}\n")
// Generate a coroutine switch similiar to the technique in
// https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
//
-1
View File
@@ -296,7 +296,6 @@ func (g *gen) visitVars(b *buffer, block []*a.Node, depth uint32, f func(*gen, *
return nil
}
// TODO: initBoolTypedVars is never used.
func (g *gen) writeResumeSuspend1(b *buffer, n *a.Var, suspend bool, initBoolTypedVars bool) error {
local := fmt.Sprintf("%s%s", vPrefix, n.Name().Str(g.tm))