e.nodeEscState(&e.theSink).Escloopdepth = -1
e.recursive = recursive
- for i := len(all) - 1; i >= 0; i-- {
- if n := all[i]; n.Op == ODCLFUNC {
+ for _, n := range all {
+ if n.Op == ODCLFUNC {
n.Esc = EscFuncPlanned
}
}
// flow-analyze functions
- for i := len(all) - 1; i >= 0; i-- {
- if n := all[i]; n.Op == ODCLFUNC {
+ for _, n := range all {
+ if n.Op == ODCLFUNC {
escfunc(e, n)
}
}
}
// for all top level functions, tag the typenodes corresponding to the param nodes
- for i := len(all) - 1; i >= 0; i-- {
- if n := all[i]; n.Op == ODCLFUNC {
+ for _, n := range all {
+ if n.Op == ODCLFUNC {
esctag(e, n)
}
}
if Debug['l'] != 0 {
// Find functions that can be inlined and clone them before walk expands them.
visitBottomUp(xtop, func(list []*Node, recursive bool) {
- // TODO: use a range statement here if the order does not matter
- for i := len(list) - 1; i >= 0; i-- {
- n := list[i]
+ for _, n := range list {
if n.Op == ODCLFUNC {
caninl(n)
inlcalls(n)
case CTSTR:
h = 0
s := n.Val().U.(string)
- for i := len(n.Val().U.(string)); i > 0; i-- {
- h = h*PRIME1 + uint32(s[0])
- s = s[1:]
+ for i := 0; i < len(s); i++ {
+ h = h*PRIME1 + uint32(s[i])
}
}
// find the exit blocks
var exits []*Block
- for i := len(f.Blocks) - 1; i >= 0; i-- {
- switch f.Blocks[i].Kind {
+ for _, b := range f.Blocks {
+ switch b.Kind {
case BlockExit, BlockRet, BlockRetJmp, BlockCall, BlockCheck:
- exits = append(exits, f.Blocks[i])
- break
+ exits = append(exits, b)
}
}
slots = make([]int, n)
s.slots = slots
}
- for i := f.NumValues() - 1; i >= 0; i-- {
+ for i := range slots {
slots[i] = -1
}