Just "=". It's cleaner.
Passes toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/ir
pkgs=$(go list . ../...)
rf '
ex '"$(echo $pkgs)"' {
var l Nodes
var p *Nodes
p.Set(l) -> *p = l
}
ex '"$(echo $pkgs)"' {
var n InitNode
var l Nodes
*n.PtrInit() = l -> n.SetInit(l)
}
rm Nodes.Set
'
Change-Id: Ic97219792243667146a02776553942ae1189ff7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/281002
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
}
}
- fn.Body.Set([]ir.Node{ir.NewBlockStmt(base.Pos, nil)})
+ fn.Body = []ir.Node{ir.NewBlockStmt(base.Pos, nil)}
}
func stmts(nn *ir.Nodes) {
}
if cut {
- nn.Set((*nn)[:i+1])
+ *nn = (*nn)[:i+1]
break
}
}
if as := n; as.Op() == ir.OAS2FUNC {
as := as.(*ir.AssignListStmt)
if as.Rhs[0].Op() == ir.OINLCALL {
- as.Rhs.Set(inlconv2list(as.Rhs[0].(*ir.InlinedCallExpr)))
+ as.Rhs = inlconv2list(as.Rhs[0].(*ir.InlinedCallExpr))
as.SetOp(ir.OAS2)
as.SetTypecheck(0)
n = typecheck.Stmt(as)
vas.Y.SetType(param.Type)
} else {
lit := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, ir.TypeNode(param.Type), nil)
- lit.List.Set(varargs)
+ lit.List = varargs
vas.Y = lit
}
}
//dumplist("ninit post", ninit);
call := ir.NewInlinedCallExpr(base.Pos, nil, nil)
- call.PtrInit().Set(ninit)
- call.Body.Set(body)
- call.ReturnVars.Set(retvars)
+ *call.PtrInit() = ninit
+ call.Body = body
+ call.ReturnVars = retvars
call.SetType(n.Type())
call.SetTypecheck(1)
for _, n := range subst.retvars {
as.Lhs.Append(n)
}
- as.Rhs.Set(subst.list(n.Results))
+ as.Rhs = subst.list(n.Results)
if subst.delayretvars {
for _, n := range as.Lhs {
n := n.(*ir.BranchStmt)
m := ir.Copy(n).(*ir.BranchStmt)
m.SetPos(subst.updatedPos(m.Pos()))
- m.PtrInit().Set(nil)
+ *m.PtrInit() = nil
p := fmt.Sprintf("%s·%d", n.Label.Name, inlgen)
m.Label = typecheck.Lookup(p)
return m
n := n.(*ir.LabelStmt)
m := ir.Copy(n).(*ir.LabelStmt)
m.SetPos(subst.updatedPos(m.Pos()))
- m.PtrInit().Set(nil)
+ *m.PtrInit() = nil
p := fmt.Sprintf("%s·%d", n.Label.Name, inlgen)
m.Label = typecheck.Lookup(p)
return m
n := &AddStringExpr{}
n.pos = pos
n.op = OADDSTR
- n.List.Set(list)
+ n.List = list
return n
}
n.pos = pos
n.orig = n
n.SetOp(op)
- n.Args.Set(args)
+ n.Args = args
return n
}
n := &CompLitExpr{Ntype: typ}
n.pos = pos
n.SetOp(op)
- n.List.Set(list)
+ n.List = list
n.orig = n
return n
}
n := &InlinedCallExpr{}
n.pos = pos
n.op = OINLCALL
- n.Body.Set(body)
- n.ReturnVars.Set(retvars)
+ n.Body = body
+ n.ReturnVars = retvars
return n
}
// a slice to save space.
type Nodes []Node
-// Set sets n to a slice.
-// This takes ownership of the slice.
-func (n *Nodes) Set(s []Node) { *n = s }
-
// Append appends entries to Nodes.
func (n *Nodes) Append(a ...Node) {
if len(a) == 0 {
n := &AssignListStmt{}
n.pos = pos
n.SetOp(op)
- n.Lhs.Set(lhs)
- n.Rhs.Set(rhs)
+ n.Lhs = lhs
+ n.Rhs = rhs
return n
}
}
}
n.op = OBLOCK
- n.List.Set(list)
+ n.List = list
return n
}
if init != nil {
n.init = []Node{init}
}
- n.Body.Set(body)
+ n.Body = body
return n
}
n := &IfStmt{Cond: cond}
n.pos = pos
n.op = OIF
- n.Body.Set(body)
- n.Else.Set(els)
+ n.Body = body
+ n.Else = els
return n
}
n := &RangeStmt{X: x, Key: key, Value: value}
n.pos = pos
n.op = ORANGE
- n.Body.Set(body)
+ n.Body = body
return n
}
n.pos = pos
n.op = ORETURN
n.orig = n
- n.Results.Set(results)
+ n.Results = results
return n
}
if body == nil {
body = []ir.Node{ir.NewBlockStmt(base.Pos, nil)}
}
- fn.Body.Set(body)
+ fn.Body = body
base.Pos = p.makeXPos(block.Rbrace)
fn.Endlineno = base.Pos
for i, e := range l {
l[i] = p.wrapname(expr.ElemList[i], e)
}
- n.List.Set(l)
+ n.List = l
base.Pos = p.makeXPos(expr.Rbrace)
return n
case *syntax.KeyValueExpr:
if list, ok := stmt.Lhs.(*syntax.ListExpr); ok && len(list.ElemList) != 1 || len(rhs) != 1 {
n := ir.NewAssignListStmt(p.pos(stmt), ir.OAS2, nil, nil)
n.Def = stmt.Op == syntax.Def
- n.Lhs.Set(p.assignList(stmt.Lhs, n, n.Def))
- n.Rhs.Set(rhs)
+ n.Lhs = p.assignList(stmt.Lhs, n, n.Def)
+ n.Rhs = rhs
return n
}
e := p.stmt(stmt.Else)
if e.Op() == ir.OBLOCK {
e := e.(*ir.BlockStmt)
- n.Else.Set(e.List)
+ n.Else = e.List
} else {
n.Else = []ir.Node{e}
}
n.Value = lhs[1]
}
}
- n.Body.Set(p.blockStmt(stmt.Body))
+ n.Body = p.blockStmt(stmt.Body)
p.closeAnotherScope()
return n
}
body = body[:len(body)-1]
}
- n.Body.Set(p.stmtsFall(body, true))
+ n.Body = p.stmtsFall(body, true)
if l := len(n.Body); l > 0 && n.Body[l-1].Op() == ir.OFALL {
if tswitch != nil {
base.Errorf("cannot fallthrough in type switch")
fn.Dcl = append(fn.Dcl, typecheck.InitTodoFunc.Dcl...)
typecheck.InitTodoFunc.Dcl = nil
- fn.Body.Set(nf)
+ fn.Body = nf
typecheck.FinishFuncBody()
typecheck.Func(fn)
} else {
fn.SetWrapper(true) // ignore frame for panic+recover matching
call := ir.NewCallExpr(base.Pos, ir.OCALL, dot, nil)
- call.Args.Set(ir.ParamNames(tfn.Type()))
+ call.Args = ir.ParamNames(tfn.Type())
call.IsDDD = tfn.Type().IsVariadic()
if method.Type.NumResults() > 0 {
ret := ir.NewReturnStmt(base.Pos, nil)
tail = ir.NewBranchStmt(base.Pos, ir.ORETJMP, f.Nname.Sym())
} else {
call := ir.NewCallExpr(base.Pos, ir.OCALL, f.Nname, nil)
- call.Args.Set(ir.ParamNames(tfn.Type()))
+ call.Args = ir.ParamNames(tfn.Type())
call.IsDDD = tfn.Type().IsVariadic()
tail = call
if tfn.Type().NumResults() > 0 {
}
nl := ir.Copy(n).(*ir.AddStringExpr)
- nl.List.Set(s[i:i2])
+ nl.List = s[i:i2]
newList = append(newList, OrigConst(nl, constant.MakeString(strings.Join(strs, ""))))
i = i2 - 1
} else {
}
nn := ir.Copy(n).(*ir.AddStringExpr)
- nn.List.Set(newList)
+ nn.List = newList
return nn
case ir.OCAP, ir.OLEN:
extra[i] = nil // allow GC
}
- call.Args.Set(append(args[:vi], slice))
+ call.Args = append(args[:vi], slice)
call.IsDDD = true
}
}
call := ir.NewCallExpr(base.Pos, ir.OCALL, ir.NewSelectorExpr(base.Pos, ir.OXDOT, ptr, meth), nil)
- call.Args.Set(ir.ParamNames(tfn.Type()))
+ call.Args = ir.ParamNames(tfn.Type())
call.IsDDD = tfn.Type().IsVariadic()
if t0.NumResults() != 0 {
ret := ir.NewReturnStmt(base.Pos, nil)
body = append(body, call)
}
- fn.Body.Set(body)
+ fn.Body = body
FinishFuncBody()
Func(fn)
return n
}
- n.Args.Set(nil)
+ n.Args = nil
l := args[0]
l = typecheck(l, ctxType)
t := l.Type()
cases := make([]*ir.CaseClause, r.uint64())
for i := range cases {
cas := ir.NewCaseStmt(r.pos(), nil, nil)
- cas.List.Set(r.stmtList())
+ cas.List = r.stmtList()
if namedTypeSwitch {
// Note: per-case variables will have distinct, dotted
// names after import. That's okay: swt.go only needs
cas.Var = caseVar
caseVar.Defn = switchExpr
}
- cas.Body.Set(r.stmtList())
+ cas.Body = r.stmtList()
cases[i] = cas
}
return cases
case ir.OCOPY, ir.OCOMPLEX, ir.OREAL, ir.OIMAG, ir.OAPPEND, ir.OCAP, ir.OCLOSE, ir.ODELETE, ir.OLEN, ir.OMAKE, ir.ONEW, ir.OPANIC, ir.ORECOVER, ir.OPRINT, ir.OPRINTN:
n := builtinCall(r.pos(), op)
- n.Args.Set(r.exprList())
+ n.Args = r.exprList()
if op == ir.OAPPEND {
n.IsDDD = r.bool()
}
pos := r.pos()
init := r.stmtList()
n := ir.NewCallExpr(pos, ir.OCALL, r.expr(), r.exprList())
- n.PtrInit().Set(init)
+ *n.PtrInit() = init
n.IsDDD = r.bool()
return n
case ir.OIF:
pos, init := r.pos(), r.stmtList()
n := ir.NewIfStmt(pos, r.expr(), r.stmtList(), r.stmtList())
- n.PtrInit().Set(init)
+ *n.PtrInit() = init
return n
case ir.OFOR:
pos, init := r.pos(), r.stmtList()
cond, post := r.exprsOrNil()
n := ir.NewForStmt(pos, nil, cond, post, r.stmtList())
- n.PtrInit().Set(init)
+ *n.PtrInit() = init
return n
case ir.ORANGE:
pos := r.pos()
init := r.stmtList()
n := ir.NewSelectStmt(pos, r.commList())
- n.PtrInit().Set(init)
+ *n.PtrInit() = init
return n
case ir.OSWITCH:
init := r.stmtList()
x, _ := r.exprsOrNil()
n := ir.NewSwitchStmt(pos, x, r.caseList(x))
- n.PtrInit().Set(init)
+ *n.PtrInit() = init
return n
// case OCASE:
CheckUnused(n)
CheckReturn(n)
if base.Errors() > errorsBefore {
- n.Body.Set(nil) // type errors; do not compile
+ n.Body = nil // type errors; do not compile
}
}
switch n := n.(type) {
case *ir.CallExpr:
- n.Args.Set(list)
+ n.Args = list
case *ir.ReturnStmt:
- n.Results.Set(list)
+ n.Results = list
}
n.PtrInit().Append(Stmt(as))
}
nn := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, ir.TypeNode(n.Type()), nil)
- nn.List.Set(l)
+ nn.List = l
return Expr(nn)
}
// move function calls out, to make ascompatee's job easier.
walkExprListSafe(n.Results, n.PtrInit())
- n.Results.Set(ascompatee(n.Op(), rl, n.Results, n.PtrInit()))
+ n.Results = ascompatee(n.Op(), rl, n.Results, n.PtrInit())
return n
}
walkExprList(n.Results, n.PtrInit())
a := ir.NewAssignStmt(base.Pos, nname, rhs[i])
res[i] = convas(a, n.PtrInit())
}
- n.Results.Set(res)
+ n.Results = res
return n
}
t = append(t, n)
}
t = append(t, ir.NewString("\n"))
- nn.Args.Set(t)
+ nn.Args = t
}
// Collapse runs of constant strings.
i++
}
}
- nn.Args.Set(t)
+ nn.Args = t
calls := []ir.Node{mkcall("printlock", nil, init)}
for i, n := range nn.Args {
walkExprList(calls, init)
r := ir.NewBlockStmt(base.Pos, nil)
- r.List.Set(calls)
+ r.List = calls
return walkStmt(typecheck.Stmt(r))
}
if len(body) > 0 {
typecheck.Stmts(body)
- fn.Enter.Set(body)
+ fn.Enter = body
fn.SetNeedctxt(true)
}
}
clos := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, ir.TypeNode(typ), nil)
clos.SetEsc(clo.Esc())
- clos.List.Set(append([]ir.Node{ir.NewUnaryExpr(base.Pos, ir.OCFUNC, fn.Nname)}, closureArgs(clo)...))
+ clos.List = append([]ir.Node{ir.NewUnaryExpr(base.Pos, ir.OCFUNC, fn.Nname)}, closureArgs(clo)...)
addr := typecheck.NodAddr(clos)
addr.SetEsc(clo.Esc())
cat := typecheck.LookupRuntime(fn)
r := ir.NewCallExpr(base.Pos, ir.OCALL, cat, nil)
- r.Args.Set(args)
+ r.Args = args
r1 := typecheck.Expr(r)
r1 = walkExpr(r1, init)
r1.SetType(n.Type())
}
}
- n.Args.Set(tempAssigns)
- n.Rargs.Set(args)
+ n.Args = tempAssigns
+ n.Rargs = args
}
// walkDivMod walks an ODIV or OMOD node.
order.edge()
order.stmtList(*n)
order.cleanTemp(mark)
- n.Set(order.out)
+ *n = order.out
}
// exprInPlace orders the side effects in *np and
// If left-hand side doesn't cause a short-circuit, issue right-hand side.
nif := ir.NewIfStmt(base.Pos, r, nil, nil)
if n.Op() == ir.OANDAND {
- nif.Body.Set(gen)
+ nif.Body = gen
} else {
- nif.Else.Set(gen)
+ nif.Else = gen
}
o.out = append(o.out, nif)
return r
statics = append(statics, r)
}
- n.List.Set(statics)
+ n.List = statics
if len(dynamics) == 0 {
return n
o.out = append(o.out, n)
as := ir.NewAssignListStmt(base.Pos, ir.OAS2, nil, nil)
- as.Lhs.Set(left)
- as.Rhs.Set(tmplist)
+ as.Lhs = left
+ as.Rhs = tmplist
o.stmt(typecheck.Stmt(as))
}
// i = len(a) - 1
// }
n := ir.NewIfStmt(base.Pos, nil, nil, nil)
- n.Body.Set(nil)
+ n.Body = nil
n.Cond = ir.NewBinaryExpr(base.Pos, ir.ONE, ir.NewUnaryExpr(base.Pos, ir.OLEN, a), ir.NewInt(0))
// hp = &a[0]
init = append(init, walkSelectCases(sel.Cases)...)
sel.Cases = nil
- sel.Compiled.Set(init)
+ sel.Compiled = init
walkStmtList(sel.Compiled)
base.Pos = lno
n := cas.Comm
ir.SetPos(n)
r := ir.NewIfStmt(base.Pos, nil, nil, nil)
- r.PtrInit().Set(cas.Init())
+ *r.PtrInit() = cas.Init()
var call ir.Node
switch n.Op() {
default:
}
r.Cond = typecheck.Expr(call)
- r.Body.Set(cas.Body)
- r.Else.Set(append(dflt.Init(), dflt.Body...))
+ r.Body = cas.Body
+ r.Else = append(dflt.Init(), dflt.Body...)
return []ir.Node{r, ir.NewBranchStmt(base.Pos, ir.OBREAK, nil)}
}
// copy rewrote to a statement list and a temp for the length.
// Throw away the temp to avoid plain values as statements.
n = ir.NewBlockStmt(n.Pos(), init)
- init.Set(nil)
+ init = nil
}
if len(init) > 0 {
switch n.Op() {
last := len(n.Args) - 1
if va := n.Args[last]; va.Op() == ir.OSLICELIT {
va := va.(*ir.CompLitExpr)
- n.Args.Set(append(n.Args[:last], va.List...))
+ n.Args = append(n.Args[:last], va.List...)
n.IsDDD = false
}
}