[dev.regabi] cmd/compile: remove Nodes.Set [generated]

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>
This commit is contained in:
Matthew Dempsky 2021-01-02 01:27:29 -08:00
parent 2f2d4b4e68
commit f2538033c0
21 changed files with 74 additions and 78 deletions

View file

@ -38,7 +38,7 @@ func Func(fn *ir.Func) {
} }
} }
fn.Body.Set([]ir.Node{ir.NewBlockStmt(base.Pos, nil)}) fn.Body = []ir.Node{ir.NewBlockStmt(base.Pos, nil)}
} }
func stmts(nn *ir.Nodes) { func stmts(nn *ir.Nodes) {
@ -114,7 +114,7 @@ func stmts(nn *ir.Nodes) {
} }
if cut { if cut {
nn.Set((*nn)[:i+1]) *nn = (*nn)[:i+1]
break break
} }
} }

View file

@ -544,7 +544,7 @@ func inlnode(n ir.Node, maxCost int32, inlMap map[*ir.Func]bool, edit func(ir.No
if as := n; as.Op() == ir.OAS2FUNC { if as := n; as.Op() == ir.OAS2FUNC {
as := as.(*ir.AssignListStmt) as := as.(*ir.AssignListStmt)
if as.Rhs[0].Op() == ir.OINLCALL { 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.SetOp(ir.OAS2)
as.SetTypecheck(0) as.SetTypecheck(0)
n = typecheck.Stmt(as) n = typecheck.Stmt(as)
@ -867,7 +867,7 @@ func mkinlcall(n *ir.CallExpr, fn *ir.Func, maxCost int32, inlMap map[*ir.Func]b
vas.Y.SetType(param.Type) vas.Y.SetType(param.Type)
} else { } else {
lit := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, ir.TypeNode(param.Type), nil) lit := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, ir.TypeNode(param.Type), nil)
lit.List.Set(varargs) lit.List = varargs
vas.Y = lit vas.Y = lit
} }
} }
@ -944,9 +944,9 @@ func mkinlcall(n *ir.CallExpr, fn *ir.Func, maxCost int32, inlMap map[*ir.Func]b
//dumplist("ninit post", ninit); //dumplist("ninit post", ninit);
call := ir.NewInlinedCallExpr(base.Pos, nil, nil) call := ir.NewInlinedCallExpr(base.Pos, nil, nil)
call.PtrInit().Set(ninit) *call.PtrInit() = ninit
call.Body.Set(body) call.Body = body
call.ReturnVars.Set(retvars) call.ReturnVars = retvars
call.SetType(n.Type()) call.SetType(n.Type())
call.SetTypecheck(1) call.SetTypecheck(1)
@ -1120,7 +1120,7 @@ func (subst *inlsubst) node(n ir.Node) ir.Node {
for _, n := range subst.retvars { for _, n := range subst.retvars {
as.Lhs.Append(n) as.Lhs.Append(n)
} }
as.Rhs.Set(subst.list(n.Results)) as.Rhs = subst.list(n.Results)
if subst.delayretvars { if subst.delayretvars {
for _, n := range as.Lhs { for _, n := range as.Lhs {
@ -1139,7 +1139,7 @@ func (subst *inlsubst) node(n ir.Node) ir.Node {
n := n.(*ir.BranchStmt) n := n.(*ir.BranchStmt)
m := ir.Copy(n).(*ir.BranchStmt) m := ir.Copy(n).(*ir.BranchStmt)
m.SetPos(subst.updatedPos(m.Pos())) m.SetPos(subst.updatedPos(m.Pos()))
m.PtrInit().Set(nil) *m.PtrInit() = nil
p := fmt.Sprintf("%s·%d", n.Label.Name, inlgen) p := fmt.Sprintf("%s·%d", n.Label.Name, inlgen)
m.Label = typecheck.Lookup(p) m.Label = typecheck.Lookup(p)
return m return m
@ -1148,7 +1148,7 @@ func (subst *inlsubst) node(n ir.Node) ir.Node {
n := n.(*ir.LabelStmt) n := n.(*ir.LabelStmt)
m := ir.Copy(n).(*ir.LabelStmt) m := ir.Copy(n).(*ir.LabelStmt)
m.SetPos(subst.updatedPos(m.Pos())) m.SetPos(subst.updatedPos(m.Pos()))
m.PtrInit().Set(nil) *m.PtrInit() = nil
p := fmt.Sprintf("%s·%d", n.Label.Name, inlgen) p := fmt.Sprintf("%s·%d", n.Label.Name, inlgen)
m.Label = typecheck.Lookup(p) m.Label = typecheck.Lookup(p)
return m return m

View file

@ -67,7 +67,7 @@ func NewAddStringExpr(pos src.XPos, list []Node) *AddStringExpr {
n := &AddStringExpr{} n := &AddStringExpr{}
n.pos = pos n.pos = pos
n.op = OADDSTR n.op = OADDSTR
n.List.Set(list) n.List = list
return n return n
} }
@ -173,7 +173,7 @@ func NewCallExpr(pos src.XPos, op Op, fun Node, args []Node) *CallExpr {
n.pos = pos n.pos = pos
n.orig = n n.orig = n
n.SetOp(op) n.SetOp(op)
n.Args.Set(args) n.Args = args
return n return n
} }
@ -231,7 +231,7 @@ func NewCompLitExpr(pos src.XPos, op Op, typ Ntype, list []Node) *CompLitExpr {
n := &CompLitExpr{Ntype: typ} n := &CompLitExpr{Ntype: typ}
n.pos = pos n.pos = pos
n.SetOp(op) n.SetOp(op)
n.List.Set(list) n.List = list
n.orig = n n.orig = n
return n return n
} }
@ -364,8 +364,8 @@ func NewInlinedCallExpr(pos src.XPos, body, retvars []Node) *InlinedCallExpr {
n := &InlinedCallExpr{} n := &InlinedCallExpr{}
n.pos = pos n.pos = pos
n.op = OINLCALL n.op = OINLCALL
n.Body.Set(body) n.Body = body
n.ReturnVars.Set(retvars) n.ReturnVars = retvars
return n return n
} }

View file

@ -323,10 +323,6 @@ const (
// a slice to save space. // a slice to save space.
type Nodes []Node 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. // Append appends entries to Nodes.
func (n *Nodes) Append(a ...Node) { func (n *Nodes) Append(a ...Node) {
if len(a) == 0 { if len(a) == 0 {

View file

@ -70,8 +70,8 @@ func NewAssignListStmt(pos src.XPos, op Op, lhs, rhs []Node) *AssignListStmt {
n := &AssignListStmt{} n := &AssignListStmt{}
n.pos = pos n.pos = pos
n.SetOp(op) n.SetOp(op)
n.Lhs.Set(lhs) n.Lhs = lhs
n.Rhs.Set(rhs) n.Rhs = rhs
return n return n
} }
@ -141,7 +141,7 @@ func NewBlockStmt(pos src.XPos, list []Node) *BlockStmt {
} }
} }
n.op = OBLOCK n.op = OBLOCK
n.List.Set(list) n.List = list
return n return n
} }
@ -216,7 +216,7 @@ func NewForStmt(pos src.XPos, init Node, cond, post Node, body []Node) *ForStmt
if init != nil { if init != nil {
n.init = []Node{init} n.init = []Node{init}
} }
n.Body.Set(body) n.Body = body
return n return n
} }
@ -262,8 +262,8 @@ func NewIfStmt(pos src.XPos, cond Node, body, els []Node) *IfStmt {
n := &IfStmt{Cond: cond} n := &IfStmt{Cond: cond}
n.pos = pos n.pos = pos
n.op = OIF n.op = OIF
n.Body.Set(body) n.Body = body
n.Else.Set(els) n.Else = els
return n return n
} }
@ -315,7 +315,7 @@ func NewRangeStmt(pos src.XPos, key, value, x Node, body []Node) *RangeStmt {
n := &RangeStmt{X: x, Key: key, Value: value} n := &RangeStmt{X: x, Key: key, Value: value}
n.pos = pos n.pos = pos
n.op = ORANGE n.op = ORANGE
n.Body.Set(body) n.Body = body
return n return n
} }
@ -331,7 +331,7 @@ func NewReturnStmt(pos src.XPos, results []Node) *ReturnStmt {
n.pos = pos n.pos = pos
n.op = ORETURN n.op = ORETURN
n.orig = n n.orig = n
n.Results.Set(results) n.Results = results
return n return n
} }

View file

@ -245,7 +245,7 @@ func (p *noder) funcBody(fn *ir.Func, block *syntax.BlockStmt) {
if body == nil { if body == nil {
body = []ir.Node{ir.NewBlockStmt(base.Pos, nil)} body = []ir.Node{ir.NewBlockStmt(base.Pos, nil)}
} }
fn.Body.Set(body) fn.Body = body
base.Pos = p.makeXPos(block.Rbrace) base.Pos = p.makeXPos(block.Rbrace)
fn.Endlineno = base.Pos fn.Endlineno = base.Pos
@ -772,7 +772,7 @@ func (p *noder) expr(expr syntax.Expr) ir.Node {
for i, e := range l { for i, e := range l {
l[i] = p.wrapname(expr.ElemList[i], e) l[i] = p.wrapname(expr.ElemList[i], e)
} }
n.List.Set(l) n.List = l
base.Pos = p.makeXPos(expr.Rbrace) base.Pos = p.makeXPos(expr.Rbrace)
return n return n
case *syntax.KeyValueExpr: case *syntax.KeyValueExpr:
@ -1128,8 +1128,8 @@ func (p *noder) stmtFall(stmt syntax.Stmt, fallOK bool) ir.Node {
if list, ok := stmt.Lhs.(*syntax.ListExpr); ok && len(list.ElemList) != 1 || len(rhs) != 1 { 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 := ir.NewAssignListStmt(p.pos(stmt), ir.OAS2, nil, nil)
n.Def = stmt.Op == syntax.Def n.Def = stmt.Op == syntax.Def
n.Lhs.Set(p.assignList(stmt.Lhs, n, n.Def)) n.Lhs = p.assignList(stmt.Lhs, n, n.Def)
n.Rhs.Set(rhs) n.Rhs = rhs
return n return n
} }
@ -1276,7 +1276,7 @@ func (p *noder) ifStmt(stmt *syntax.IfStmt) ir.Node {
e := p.stmt(stmt.Else) e := p.stmt(stmt.Else)
if e.Op() == ir.OBLOCK { if e.Op() == ir.OBLOCK {
e := e.(*ir.BlockStmt) e := e.(*ir.BlockStmt)
n.Else.Set(e.List) n.Else = e.List
} else { } else {
n.Else = []ir.Node{e} n.Else = []ir.Node{e}
} }
@ -1301,7 +1301,7 @@ func (p *noder) forStmt(stmt *syntax.ForStmt) ir.Node {
n.Value = lhs[1] n.Value = lhs[1]
} }
} }
n.Body.Set(p.blockStmt(stmt.Body)) n.Body = p.blockStmt(stmt.Body)
p.closeAnotherScope() p.closeAnotherScope()
return n return n
} }
@ -1359,7 +1359,7 @@ func (p *noder) caseClauses(clauses []*syntax.CaseClause, tswitch *ir.TypeSwitch
body = body[:len(body)-1] 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 l := len(n.Body); l > 0 && n.Body[l-1].Op() == ir.OFALL {
if tswitch != nil { if tswitch != nil {
base.Errorf("cannot fallthrough in type switch") base.Errorf("cannot fallthrough in type switch")

View file

@ -49,7 +49,7 @@ func Task() *ir.Name {
fn.Dcl = append(fn.Dcl, typecheck.InitTodoFunc.Dcl...) fn.Dcl = append(fn.Dcl, typecheck.InitTodoFunc.Dcl...)
typecheck.InitTodoFunc.Dcl = nil typecheck.InitTodoFunc.Dcl = nil
fn.Body.Set(nf) fn.Body = nf
typecheck.FinishFuncBody() typecheck.FinishFuncBody()
typecheck.Func(fn) typecheck.Func(fn)

View file

@ -1798,7 +1798,7 @@ func methodWrapper(rcvr *types.Type, method *types.Field) *obj.LSym {
} else { } else {
fn.SetWrapper(true) // ignore frame for panic+recover matching fn.SetWrapper(true) // ignore frame for panic+recover matching
call := ir.NewCallExpr(base.Pos, ir.OCALL, dot, nil) 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() call.IsDDD = tfn.Type().IsVariadic()
if method.Type.NumResults() > 0 { if method.Type.NumResults() > 0 {
ret := ir.NewReturnStmt(base.Pos, nil) ret := ir.NewReturnStmt(base.Pos, nil)

View file

@ -303,7 +303,7 @@ func makeABIWrapper(f *ir.Func, wrapperABI obj.ABI) {
tail = ir.NewBranchStmt(base.Pos, ir.ORETJMP, f.Nname.Sym()) tail = ir.NewBranchStmt(base.Pos, ir.ORETJMP, f.Nname.Sym())
} else { } else {
call := ir.NewCallExpr(base.Pos, ir.OCALL, f.Nname, nil) 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() call.IsDDD = tfn.Type().IsVariadic()
tail = call tail = call
if tfn.Type().NumResults() > 0 { if tfn.Type().NumResults() > 0 {

View file

@ -509,7 +509,7 @@ func EvalConst(n ir.Node) ir.Node {
} }
nl := ir.Copy(n).(*ir.AddStringExpr) 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, "")))) newList = append(newList, OrigConst(nl, constant.MakeString(strings.Join(strs, ""))))
i = i2 - 1 i = i2 - 1
} else { } else {
@ -518,7 +518,7 @@ func EvalConst(n ir.Node) ir.Node {
} }
nn := ir.Copy(n).(*ir.AddStringExpr) nn := ir.Copy(n).(*ir.AddStringExpr)
nn.List.Set(newList) nn.List = newList
return nn return nn
case ir.OCAP, ir.OLEN: case ir.OCAP, ir.OLEN:

View file

@ -52,7 +52,7 @@ func FixVariadicCall(call *ir.CallExpr) {
extra[i] = nil // allow GC extra[i] = nil // allow GC
} }
call.Args.Set(append(args[:vi], slice)) call.Args = append(args[:vi], slice)
call.IsDDD = true call.IsDDD = true
} }
@ -313,7 +313,7 @@ func MethodValueWrapper(dot *ir.SelectorExpr) *ir.Func {
} }
call := ir.NewCallExpr(base.Pos, ir.OCALL, ir.NewSelectorExpr(base.Pos, ir.OXDOT, ptr, meth), nil) 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() call.IsDDD = tfn.Type().IsVariadic()
if t0.NumResults() != 0 { if t0.NumResults() != 0 {
ret := ir.NewReturnStmt(base.Pos, nil) ret := ir.NewReturnStmt(base.Pos, nil)
@ -323,7 +323,7 @@ func MethodValueWrapper(dot *ir.SelectorExpr) *ir.Func {
body = append(body, call) body = append(body, call)
} }
fn.Body.Set(body) fn.Body = body
FinishFuncBody() FinishFuncBody()
Func(fn) Func(fn)
@ -798,7 +798,7 @@ func tcMake(n *ir.CallExpr) ir.Node {
return n return n
} }
n.Args.Set(nil) n.Args = nil
l := args[0] l := args[0]
l = typecheck(l, ctxType) l = typecheck(l, ctxType)
t := l.Type() t := l.Type()

View file

@ -779,7 +779,7 @@ func (r *importReader) caseList(switchExpr ir.Node) []*ir.CaseClause {
cases := make([]*ir.CaseClause, r.uint64()) cases := make([]*ir.CaseClause, r.uint64())
for i := range cases { for i := range cases {
cas := ir.NewCaseStmt(r.pos(), nil, nil) cas := ir.NewCaseStmt(r.pos(), nil, nil)
cas.List.Set(r.stmtList()) cas.List = r.stmtList()
if namedTypeSwitch { if namedTypeSwitch {
// Note: per-case variables will have distinct, dotted // Note: per-case variables will have distinct, dotted
// names after import. That's okay: swt.go only needs // names after import. That's okay: swt.go only needs
@ -789,7 +789,7 @@ func (r *importReader) caseList(switchExpr ir.Node) []*ir.CaseClause {
cas.Var = caseVar cas.Var = caseVar
caseVar.Defn = switchExpr caseVar.Defn = switchExpr
} }
cas.Body.Set(r.stmtList()) cas.Body = r.stmtList()
cases[i] = cas cases[i] = cas
} }
return cases return cases
@ -932,7 +932,7 @@ func (r *importReader) node() ir.Node {
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: 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 := builtinCall(r.pos(), op)
n.Args.Set(r.exprList()) n.Args = r.exprList()
if op == ir.OAPPEND { if op == ir.OAPPEND {
n.IsDDD = r.bool() n.IsDDD = r.bool()
} }
@ -945,7 +945,7 @@ func (r *importReader) node() ir.Node {
pos := r.pos() pos := r.pos()
init := r.stmtList() init := r.stmtList()
n := ir.NewCallExpr(pos, ir.OCALL, r.expr(), r.exprList()) n := ir.NewCallExpr(pos, ir.OCALL, r.expr(), r.exprList())
n.PtrInit().Set(init) *n.PtrInit() = init
n.IsDDD = r.bool() n.IsDDD = r.bool()
return n return n
@ -1033,14 +1033,14 @@ func (r *importReader) node() ir.Node {
case ir.OIF: case ir.OIF:
pos, init := r.pos(), r.stmtList() pos, init := r.pos(), r.stmtList()
n := ir.NewIfStmt(pos, r.expr(), r.stmtList(), r.stmtList()) n := ir.NewIfStmt(pos, r.expr(), r.stmtList(), r.stmtList())
n.PtrInit().Set(init) *n.PtrInit() = init
return n return n
case ir.OFOR: case ir.OFOR:
pos, init := r.pos(), r.stmtList() pos, init := r.pos(), r.stmtList()
cond, post := r.exprsOrNil() cond, post := r.exprsOrNil()
n := ir.NewForStmt(pos, nil, cond, post, r.stmtList()) n := ir.NewForStmt(pos, nil, cond, post, r.stmtList())
n.PtrInit().Set(init) *n.PtrInit() = init
return n return n
case ir.ORANGE: case ir.ORANGE:
@ -1052,7 +1052,7 @@ func (r *importReader) node() ir.Node {
pos := r.pos() pos := r.pos()
init := r.stmtList() init := r.stmtList()
n := ir.NewSelectStmt(pos, r.commList()) n := ir.NewSelectStmt(pos, r.commList())
n.PtrInit().Set(init) *n.PtrInit() = init
return n return n
case ir.OSWITCH: case ir.OSWITCH:
@ -1060,7 +1060,7 @@ func (r *importReader) node() ir.Node {
init := r.stmtList() init := r.stmtList()
x, _ := r.exprsOrNil() x, _ := r.exprsOrNil()
n := ir.NewSwitchStmt(pos, x, r.caseList(x)) n := ir.NewSwitchStmt(pos, x, r.caseList(x))
n.PtrInit().Set(init) *n.PtrInit() = init
return n return n
// case OCASE: // case OCASE:

View file

@ -64,7 +64,7 @@ func FuncBody(n *ir.Func) {
CheckUnused(n) CheckUnused(n)
CheckReturn(n) CheckReturn(n)
if base.Errors() > errorsBefore { if base.Errors() > errorsBefore {
n.Body.Set(nil) // type errors; do not compile n.Body = nil // type errors; do not compile
} }
} }
@ -971,9 +971,9 @@ func typecheckargs(n ir.InitNode) {
switch n := n.(type) { switch n := n.(type) {
case *ir.CallExpr: case *ir.CallExpr:
n.Args.Set(list) n.Args = list
case *ir.ReturnStmt: case *ir.ReturnStmt:
n.Results.Set(list) n.Results = list
} }
n.PtrInit().Append(Stmt(as)) n.PtrInit().Append(Stmt(as))
@ -1687,7 +1687,7 @@ func stringtoruneslit(n *ir.ConvExpr) ir.Node {
} }
nn := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, ir.TypeNode(n.Type()), nil) nn := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, ir.TypeNode(n.Type()), nil)
nn.List.Set(l) nn.List = l
return Expr(nn) return Expr(nn)
} }

View file

@ -264,7 +264,7 @@ func walkReturn(n *ir.ReturnStmt) ir.Node {
// move function calls out, to make ascompatee's job easier. // move function calls out, to make ascompatee's job easier.
walkExprListSafe(n.Results, n.PtrInit()) 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 return n
} }
walkExprList(n.Results, n.PtrInit()) walkExprList(n.Results, n.PtrInit())
@ -281,7 +281,7 @@ func walkReturn(n *ir.ReturnStmt) ir.Node {
a := ir.NewAssignStmt(base.Pos, nname, rhs[i]) a := ir.NewAssignStmt(base.Pos, nname, rhs[i])
res[i] = convas(a, n.PtrInit()) res[i] = convas(a, n.PtrInit())
} }
n.Results.Set(res) n.Results = res
return n return n
} }

View file

@ -531,7 +531,7 @@ func walkPrint(nn *ir.CallExpr, init *ir.Nodes) ir.Node {
t = append(t, n) t = append(t, n)
} }
t = append(t, ir.NewString("\n")) t = append(t, ir.NewString("\n"))
nn.Args.Set(t) nn.Args = t
} }
// Collapse runs of constant strings. // Collapse runs of constant strings.
@ -551,7 +551,7 @@ func walkPrint(nn *ir.CallExpr, init *ir.Nodes) ir.Node {
i++ i++
} }
} }
nn.Args.Set(t) nn.Args = t
calls := []ir.Node{mkcall("printlock", nil, init)} calls := []ir.Node{mkcall("printlock", nil, init)}
for i, n := range nn.Args { for i, n := range nn.Args {
@ -653,7 +653,7 @@ func walkPrint(nn *ir.CallExpr, init *ir.Nodes) ir.Node {
walkExprList(calls, init) walkExprList(calls, init)
r := ir.NewBlockStmt(base.Pos, nil) r := ir.NewBlockStmt(base.Pos, nil)
r.List.Set(calls) r.List = calls
return walkStmt(typecheck.Stmt(r)) return walkStmt(typecheck.Stmt(r))
} }

View file

@ -107,7 +107,7 @@ func Closure(fn *ir.Func) {
if len(body) > 0 { if len(body) > 0 {
typecheck.Stmts(body) typecheck.Stmts(body)
fn.Enter.Set(body) fn.Enter = body
fn.SetNeedctxt(true) fn.SetNeedctxt(true)
} }
} }
@ -131,7 +131,7 @@ func walkClosure(clo *ir.ClosureExpr, init *ir.Nodes) ir.Node {
clos := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, ir.TypeNode(typ), nil) clos := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, ir.TypeNode(typ), nil)
clos.SetEsc(clo.Esc()) 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 := typecheck.NodAddr(clos)
addr.SetEsc(clo.Esc()) addr.SetEsc(clo.Esc())

View file

@ -477,7 +477,7 @@ func walkAddString(n *ir.AddStringExpr, init *ir.Nodes) ir.Node {
cat := typecheck.LookupRuntime(fn) cat := typecheck.LookupRuntime(fn)
r := ir.NewCallExpr(base.Pos, ir.OCALL, cat, nil) r := ir.NewCallExpr(base.Pos, ir.OCALL, cat, nil)
r.Args.Set(args) r.Args = args
r1 := typecheck.Expr(r) r1 := typecheck.Expr(r)
r1 = walkExpr(r1, init) r1 = walkExpr(r1, init)
r1.SetType(n.Type()) r1.SetType(n.Type())
@ -562,8 +562,8 @@ func walkCall1(n *ir.CallExpr, init *ir.Nodes) {
} }
} }
n.Args.Set(tempAssigns) n.Args = tempAssigns
n.Rargs.Set(args) n.Rargs = args
} }
// walkDivMod walks an ODIV or OMOD node. // walkDivMod walks an ODIV or OMOD node.

View file

@ -423,7 +423,7 @@ func orderBlock(n *ir.Nodes, free map[string][]*ir.Name) {
order.edge() order.edge()
order.stmtList(*n) order.stmtList(*n)
order.cleanTemp(mark) order.cleanTemp(mark)
n.Set(order.out) *n = order.out
} }
// exprInPlace orders the side effects in *np and // exprInPlace orders the side effects in *np and
@ -1233,9 +1233,9 @@ func (o *orderState) expr1(n, lhs ir.Node) ir.Node {
// If left-hand side doesn't cause a short-circuit, issue right-hand side. // If left-hand side doesn't cause a short-circuit, issue right-hand side.
nif := ir.NewIfStmt(base.Pos, r, nil, nil) nif := ir.NewIfStmt(base.Pos, r, nil, nil)
if n.Op() == ir.OANDAND { if n.Op() == ir.OANDAND {
nif.Body.Set(gen) nif.Body = gen
} else { } else {
nif.Else.Set(gen) nif.Else = gen
} }
o.out = append(o.out, nif) o.out = append(o.out, nif)
return r return r
@ -1401,7 +1401,7 @@ func (o *orderState) expr1(n, lhs ir.Node) ir.Node {
statics = append(statics, r) statics = append(statics, r)
} }
n.List.Set(statics) n.List = statics
if len(dynamics) == 0 { if len(dynamics) == 0 {
return n return n
@ -1448,8 +1448,8 @@ func (o *orderState) as2(n *ir.AssignListStmt) {
o.out = append(o.out, n) o.out = append(o.out, n)
as := ir.NewAssignListStmt(base.Pos, ir.OAS2, nil, nil) as := ir.NewAssignListStmt(base.Pos, ir.OAS2, nil, nil)
as.Lhs.Set(left) as.Lhs = left
as.Rhs.Set(tmplist) as.Rhs = tmplist
o.stmt(typecheck.Stmt(as)) o.stmt(typecheck.Stmt(as))
} }

View file

@ -429,7 +429,7 @@ func arrayClear(loop *ir.RangeStmt, v1, v2, a ir.Node) ir.Node {
// i = len(a) - 1 // i = len(a) - 1
// } // }
n := ir.NewIfStmt(base.Pos, nil, nil, nil) 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)) n.Cond = ir.NewBinaryExpr(base.Pos, ir.ONE, ir.NewUnaryExpr(base.Pos, ir.OLEN, a), ir.NewInt(0))
// hp = &a[0] // hp = &a[0]

View file

@ -22,7 +22,7 @@ func walkSelect(sel *ir.SelectStmt) {
init = append(init, walkSelectCases(sel.Cases)...) init = append(init, walkSelectCases(sel.Cases)...)
sel.Cases = nil sel.Cases = nil
sel.Compiled.Set(init) sel.Compiled = init
walkStmtList(sel.Compiled) walkStmtList(sel.Compiled)
base.Pos = lno base.Pos = lno
@ -104,7 +104,7 @@ func walkSelectCases(cases []*ir.CommClause) []ir.Node {
n := cas.Comm n := cas.Comm
ir.SetPos(n) ir.SetPos(n)
r := ir.NewIfStmt(base.Pos, nil, nil, nil) r := ir.NewIfStmt(base.Pos, nil, nil, nil)
r.PtrInit().Set(cas.Init()) *r.PtrInit() = cas.Init()
var call ir.Node var call ir.Node
switch n.Op() { switch n.Op() {
default: default:
@ -136,8 +136,8 @@ func walkSelectCases(cases []*ir.CommClause) []ir.Node {
} }
r.Cond = typecheck.Expr(call) r.Cond = typecheck.Expr(call)
r.Body.Set(cas.Body) r.Body = cas.Body
r.Else.Set(append(dflt.Init(), dflt.Body...)) r.Else = append(dflt.Init(), dflt.Body...)
return []ir.Node{r, ir.NewBranchStmt(base.Pos, ir.OBREAK, nil)} return []ir.Node{r, ir.NewBranchStmt(base.Pos, ir.OBREAK, nil)}
} }

View file

@ -61,7 +61,7 @@ func walkStmt(n ir.Node) ir.Node {
// copy rewrote to a statement list and a temp for the length. // copy rewrote to a statement list and a temp for the length.
// Throw away the temp to avoid plain values as statements. // Throw away the temp to avoid plain values as statements.
n = ir.NewBlockStmt(n.Pos(), init) n = ir.NewBlockStmt(n.Pos(), init)
init.Set(nil) init = nil
} }
if len(init) > 0 { if len(init) > 0 {
switch n.Op() { switch n.Op() {
@ -265,7 +265,7 @@ func wrapCall(n *ir.CallExpr, init *ir.Nodes) ir.Node {
last := len(n.Args) - 1 last := len(n.Args) - 1
if va := n.Args[last]; va.Op() == ir.OSLICELIT { if va := n.Args[last]; va.Op() == ir.OSLICELIT {
va := va.(*ir.CompLitExpr) va := va.(*ir.CompLitExpr)
n.Args.Set(append(n.Args[:last], va.List...)) n.Args = append(n.Args[:last], va.List...)
n.IsDDD = false n.IsDDD = false
} }
} }