mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Remove obsolete gen.visitVars function
This commit is contained in:
1 parent
6ebe99ced9
commit
7bdbab9e08
3 files changed
+21
-61
No files matched your search
@@ -97,11 +97,13 @@ func (g *gen) findVars() error {
|
||||
}
|
||||
|
||||
f := g.currFunk.astFunc
|
||||
if err := g.visitVars(nil, f.Body(), 0, func(g *gen, b *buffer, n *a.Var) error {
|
||||
name := n.Name()
|
||||
if _, ok := h.vars[name]; !ok {
|
||||
g.currFunk.varList = append(g.currFunk.varList, n)
|
||||
h.vars[name] = len(h.vars)
|
||||
if err := f.AsNode().Walk(func(n *a.Node) error {
|
||||
if n.Kind() == a.KVar {
|
||||
name := n.AsVar().Name()
|
||||
if _, ok := h.vars[name]; !ok {
|
||||
g.currFunk.varList = append(g.currFunk.varList, n.AsVar())
|
||||
h.vars[name] = len(h.vars)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
|
||||
@@ -226,51 +226,6 @@ func (g *gen) writeSaveExprDerivedVars(b *buffer, n *a.Expr) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *gen) visitVars(b *buffer, block []*a.Node, depth uint32, f func(*gen, *buffer, *a.Var) error) error {
|
||||
if depth > a.MaxBodyDepth {
|
||||
return fmt.Errorf("body recursion depth too large")
|
||||
}
|
||||
depth++
|
||||
|
||||
for _, o := range block {
|
||||
switch o.Kind() {
|
||||
case a.KIOBind:
|
||||
if err := g.visitVars(b, o.AsIOBind().Body(), depth, f); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
case a.KIf:
|
||||
for o := o.AsIf(); o != nil; o = o.ElseIf() {
|
||||
if err := g.visitVars(b, o.BodyIfTrue(), depth, f); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.visitVars(b, o.BodyIfFalse(), depth, f); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
case a.KIterate:
|
||||
if err := g.visitVars(b, o.AsIterate().Variables(), depth, f); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.visitVars(b, o.AsIterate().Body(), depth, f); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
case a.KVar:
|
||||
if err := f(g, b, o.AsVar()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
case a.KWhile:
|
||||
if err := g.visitVars(b, o.AsWhile().Body(), depth, f); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *gen) writeResumeSuspend1(b *buffer, f *funk, n *a.Var, suspend bool, initBoolTypedVars bool) error {
|
||||
local := fmt.Sprintf("%s%s", vPrefix, n.Name().Str(g.tm))
|
||||
|
||||
@@ -383,22 +338,25 @@ fail:
|
||||
}
|
||||
|
||||
func (g *gen) writeResumeSuspend(b *buffer, f *funk, suspend bool, initBoolTypedVars bool) error {
|
||||
return g.visitVars(b, f.astFunc.Body(), 0, func(g *gen, b *buffer, n *a.Var) error {
|
||||
return g.writeResumeSuspend1(b, f, n, suspend, initBoolTypedVars)
|
||||
})
|
||||
for _, n := range f.varList {
|
||||
if err := g.writeResumeSuspend1(b, f, n, suspend, initBoolTypedVars); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *gen) writeVars(b *buffer, f *funk, skipPointerTypes bool, skipIterateVariables bool, skipNonresumable bool) error {
|
||||
return g.visitVars(b, f.astFunc.Body(), 0, func(g *gen, b *buffer, n *a.Var) error {
|
||||
for _, n := range f.varList {
|
||||
typ := n.XType()
|
||||
if skipPointerTypes && typ.HasPointers() {
|
||||
return nil
|
||||
continue
|
||||
}
|
||||
if skipIterateVariables && n.IterateVariable() {
|
||||
return nil
|
||||
continue
|
||||
}
|
||||
if skipNonresumable && (f.varResumables == nil || !f.varResumables[n.Name()]) {
|
||||
return nil
|
||||
continue
|
||||
}
|
||||
name := n.Name().Str(g.tm)
|
||||
if err := g.writeCTypeName(b, typ, vPrefix, name); err != nil {
|
||||
@@ -415,6 +373,6 @@ func (g *gen) writeVars(b *buffer, f *funk, skipPointerTypes bool, skipIterateVa
|
||||
b.printf("WUFFS_BASE__IGNORE_POTENTIALLY_UNUSED_VARIABLE(%s%s);\n", iopPrefix, preName)
|
||||
b.printf("WUFFS_BASE__IGNORE_POTENTIALLY_UNUSED_VARIABLE(%s%s);\n", io1Prefix, preName)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -6826,12 +6826,12 @@ wuffs_lzw__decoder__decode(wuffs_lzw__decoder* self,
|
||||
uint32_t v_bits;
|
||||
uint32_t v_n_bits;
|
||||
uint32_t v_code;
|
||||
uint16_t v_lm1_a;
|
||||
uint32_t v_c;
|
||||
uint32_t v_o;
|
||||
uint32_t v_steps;
|
||||
uint8_t v_first_byte;
|
||||
uint16_t v_lm1_b;
|
||||
uint16_t v_lm1_a;
|
||||
|
||||
uint8_t* iop_a_src = NULL;
|
||||
uint8_t* io0_a_src = NULL;
|
||||
@@ -6862,12 +6862,12 @@ wuffs_lzw__decoder__decode(wuffs_lzw__decoder* self,
|
||||
v_bits = self->private_impl.c_decode[0].v_bits;
|
||||
v_n_bits = self->private_impl.c_decode[0].v_n_bits;
|
||||
v_code = 0;
|
||||
v_lm1_a = 0;
|
||||
v_c = 0;
|
||||
v_o = 0;
|
||||
v_steps = 0;
|
||||
v_first_byte = 0;
|
||||
v_lm1_b = 0;
|
||||
v_lm1_a = 0;
|
||||
} else {
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
|
||||
Reference in new issue
Block a user