// adds "adjust" to all the argument locations for the call n.
// n must be a defer or go node that has already been walked.
func adjustargs(n *Node, adjust int) {
- var arg *Node
- var lhs *Node
-
callfunc := n.Left
- for _, arg = range callfunc.List.Slice() {
+ for _, arg := range callfunc.List.Slice() {
if arg.Op != OAS {
Fatalf("call arg not assignment")
}
- lhs = arg.Left
+ lhs := arg.Left
if lhs.Op == ONAME {
// This is a temporary introduced by reorder1.
// The real store to the stack appears later in the arg list.
// so that reorder3 can fix up conflicts
var rl []*Node
- var cl Class
for _, ln := range Curfn.Func.Dcl {
- cl = ln.Class()
+ cl := ln.Class()
if cl == PAUTO || cl == PAUTOHEAP {
break
}
var f *Node // last fncall assigned to stack
var r []*Node // non fncalls and tempnames assigned to stack
d := 0
- var a *Node
for _, n := range all {
if !n.HasCall() {
r = append(r, n)
}
// make assignment of fncall to tempname
- a = temp(n.Right.Type)
+ a := temp(n.Right.Type)
a = nod(OAS, a, n.Right)
g = append(g, a)
//
// function calls have been removed.
func reorder3(all []*Node) []*Node {
- var l *Node
-
// If a needed expression may be affected by an
// earlier assignment, make an early copy of that
// expression and use the copy instead.
var mapinit Nodes
for i, n := range all {
- l = n.Left
+ l := n.Left
// Save subexpressions needed on left side.
// Drill through non-dereferences.
memwrite := 0
varwrite := 0
- var a *Node
for _, an := range all[:i] {
- a = outervalue(an.Left)
+ a := outervalue(an.Left)
for a.Op == ODOT {
a = a.Left
t := nod(OTFUNC, nil, nil)
num := 0
var printargs []*Node
- var a *Node
- var buf string
for _, n1 := range n.List.Slice() {
- buf = fmt.Sprintf("a%d", num)
+ buf := fmt.Sprintf("a%d", num)
num++
- a = namedfield(buf, n1.Type)
+ a := namedfield(buf, n1.Type)
t.List.Append(a)
printargs = append(printargs, a.Left)
}
sym := lookupN("print·%d", walkprintfunc_prgen)
fn := dclfunc(sym, t)
- a = nod(n.Op, nil, nil)
+ a := nod(n.Op, nil, nil)
a.List.Set(printargs)
a = typecheck(a, Etop)
a = walkstmt(a)