mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Add some support for iterate assertions.
This commit is contained in:
1 parent
e8d16fa54d
commit
b024cb1d8c
6 files changed
+76
-43
No files matched your search
@@ -31,7 +31,7 @@ type funk struct {
|
||||
|
||||
astFunc *a.Func
|
||||
derivedVars map[t.ID]struct{}
|
||||
jumpTargets map[*a.While]uint32
|
||||
jumpTargets map[a.Loop]uint32
|
||||
coroSuspPoint uint32
|
||||
tempW uint32
|
||||
tempR uint32
|
||||
@@ -42,9 +42,9 @@ type funk struct {
|
||||
shortReads []string
|
||||
}
|
||||
|
||||
func (k *funk) jumpTarget(n *a.While) (uint32, error) {
|
||||
func (k *funk) jumpTarget(n a.Loop) (uint32, error) {
|
||||
if k.jumpTargets == nil {
|
||||
k.jumpTargets = map[*a.While]uint32{}
|
||||
k.jumpTargets = map[a.Loop]uint32{}
|
||||
}
|
||||
if jt, ok := k.jumpTargets[n]; ok {
|
||||
return jt, nil
|
||||
|
||||
@@ -258,6 +258,7 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
b.printf("uint8_t* %s%s = %sslice_%s.ptr;\n", vPrefix, name, iPrefix, name)
|
||||
b.printf("uint8_t* %send_%s = %sslice_%s.ptr + %sslice_%s.len;\n",
|
||||
iPrefix, name, iPrefix, name, iPrefix, name)
|
||||
// TODO: look at n.HasContinue().
|
||||
b.printf("while (%s%s < %send_%s) {\n", vPrefix, name, iPrefix, name)
|
||||
for _, o := range n.Body() {
|
||||
if err := g.writeStatement(b, o, depth); err != nil {
|
||||
@@ -265,6 +266,7 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
}
|
||||
}
|
||||
b.printf("%s%s++;\n}\n", vPrefix, name)
|
||||
// TODO: look at n.HasBreak().
|
||||
|
||||
b.writes("}\n")
|
||||
return nil
|
||||
|
||||
Reference in new issue
Block a user