mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
Generate temporary io_bind variables
This commit is contained in:
1 parent
4588cdcf5f
commit
3d1bb5e2a9
4 files changed
+40
-1
No files matched your search
@@ -130,12 +130,41 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
|
||||
case a.KIOBind:
|
||||
n := n.IOBind()
|
||||
inFields := n.InFields()
|
||||
|
||||
if g.currFunk.ioBinds > maxIOBinds || len(inFields) > maxIOBindInFields {
|
||||
return fmt.Errorf("too many temporary variables required")
|
||||
}
|
||||
ioBindNum := g.currFunk.ioBinds
|
||||
g.currFunk.ioBinds++
|
||||
|
||||
// TODO: do these variables need to be func-scoped (bigger scope)
|
||||
// instead of block-scoped (smaller scope) if the coro_susp_point
|
||||
// switch can jump past this initialization??
|
||||
b.writes("{\n")
|
||||
for i := 0; i < len(inFields); i++ {
|
||||
e := inFields[i].Expr()
|
||||
name := e.Ident().Str(g.tm)
|
||||
for j := 0; j < 2; j++ {
|
||||
b.printf("uint8_t* %s%d_bounds%d_%s = %s%s.private_impl.bounds[%d];\n",
|
||||
oPrefix, ioBindNum, j, name, aPrefix, name, j)
|
||||
}
|
||||
}
|
||||
|
||||
for _, o := range n.Body() {
|
||||
if err := g.writeStatement(b, o, depth); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for i := len(inFields) - 1; i >= 0; i-- {
|
||||
e := inFields[i].Expr()
|
||||
name := e.Ident().Str(g.tm)
|
||||
for j := 1; j >= 0; j-- {
|
||||
b.printf("%s%s.private_impl.bounds[%d] = %s%d_bounds%d_%s;\n",
|
||||
aPrefix, name, j, oPrefix, ioBindNum, j, name)
|
||||
}
|
||||
}
|
||||
b.writes("}\n")
|
||||
return nil
|
||||
|
||||
|
||||
Reference in new issue
Block a user