Commit bd8bb673 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/internal/gc: unembed Param field

This is an automated follow-up to CL 10210.
It was generated with a combination of eg and gofmt -r.

No functional changes. Passes toolstash -cmp.

Change-Id: I35f5897948a270b472d8cf80612071b4b29e9a2b
Reviewed-on: https://go-review.googlesource.com/10253Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent f2c3957e
...@@ -71,8 +71,8 @@ func widstruct(errtype *Type, t *Type, o int64, flag int) int64 { ...@@ -71,8 +71,8 @@ func widstruct(errtype *Type, t *Type, o int64, flag int) int64 {
// in typecheck.c. usually addrescapes runs after // in typecheck.c. usually addrescapes runs after
// widstruct, in which case we could drop this, // widstruct, in which case we could drop this,
// but function closure functions are the exception. // but function closure functions are the exception.
if f.Nname.Stackparam != nil { if f.Nname.Param.Stackparam != nil {
f.Nname.Stackparam.Xoffset = o f.Nname.Param.Stackparam.Xoffset = o
f.Nname.Xoffset = 0 f.Nname.Xoffset = 0
} else { } else {
f.Nname.Xoffset = o f.Nname.Xoffset = o
......
...@@ -17,7 +17,7 @@ func closurehdr(ntype *Node) { ...@@ -17,7 +17,7 @@ func closurehdr(ntype *Node) {
var a *Node var a *Node
n := Nod(OCLOSURE, nil, nil) n := Nod(OCLOSURE, nil, nil)
n.Ntype = ntype n.Param.Ntype = ntype
n.Funcdepth = Funcdepth n.Funcdepth = Funcdepth
n.Func.Outerfunc = Curfn n.Func.Outerfunc = Curfn
...@@ -72,8 +72,8 @@ func closurebody(body *NodeList) *Node { ...@@ -72,8 +72,8 @@ func closurebody(body *NodeList) *Node {
var v *Node var v *Node
for l := func_.Func.Cvars; l != nil; l = l.Next { for l := func_.Func.Cvars; l != nil; l = l.Next {
v = l.N v = l.N
v.Closure.Closure = v.Outer v.Param.Closure.Param.Closure = v.Param.Outer
v.Outerexpr = oldname(v.Sym) v.Param.Outerexpr = oldname(v.Sym)
} }
return func_ return func_
...@@ -83,7 +83,7 @@ func typecheckclosure(func_ *Node, top int) { ...@@ -83,7 +83,7 @@ func typecheckclosure(func_ *Node, top int) {
var n *Node var n *Node
for l := func_.Func.Cvars; l != nil; l = l.Next { for l := func_.Func.Cvars; l != nil; l = l.Next {
n = l.N.Closure n = l.N.Param.Closure
if !n.Name.Captured { if !n.Name.Captured {
n.Name.Captured = true n.Name.Captured = true
if n.Name.Decldepth == 0 { if n.Name.Decldepth == 0 {
...@@ -105,9 +105,9 @@ func typecheckclosure(func_ *Node, top int) { ...@@ -105,9 +105,9 @@ func typecheckclosure(func_ *Node, top int) {
} }
oldfn := Curfn oldfn := Curfn
typecheck(&func_.Ntype, Etype) typecheck(&func_.Param.Ntype, Etype)
func_.Type = func_.Ntype.Type func_.Type = func_.Param.Ntype.Type
func_.Top = top func_.Param.Top = top
// Type check the body now, but only if we're inside a function. // Type check the body now, but only if we're inside a function.
// At top level (in a variable initialization: curfn==nil) we're not // At top level (in a variable initialization: curfn==nil) we're not
...@@ -193,7 +193,7 @@ func makeclosure(func_ *Node) *Node { ...@@ -193,7 +193,7 @@ func makeclosure(func_ *Node) *Node {
xfunc.Nname = newfuncname(closurename(func_)) xfunc.Nname = newfuncname(closurename(func_))
xfunc.Nname.Sym.Flags |= SymExported // disable export xfunc.Nname.Sym.Flags |= SymExported // disable export
xfunc.Nname.Ntype = xtype xfunc.Nname.Param.Ntype = xtype
xfunc.Nname.Defn = xfunc xfunc.Nname.Defn = xfunc
declare(xfunc.Nname, PFUNC) declare(xfunc.Nname, PFUNC)
xfunc.Nname.Funcdepth = func_.Funcdepth xfunc.Nname.Funcdepth = func_.Funcdepth
...@@ -207,8 +207,8 @@ func makeclosure(func_ *Node) *Node { ...@@ -207,8 +207,8 @@ func makeclosure(func_ *Node) *Node {
} }
typecheck(&xfunc, Etop) typecheck(&xfunc, Etop)
xfunc.Closure = func_ xfunc.Param.Closure = func_
func_.Closure = xfunc func_.Param.Closure = xfunc
func_.Nbody = nil func_.Nbody = nil
func_.List = nil func_.List = nil
...@@ -229,7 +229,7 @@ func capturevars(xfunc *Node) { ...@@ -229,7 +229,7 @@ func capturevars(xfunc *Node) {
lno := int(lineno) lno := int(lineno)
lineno = xfunc.Lineno lineno = xfunc.Lineno
func_ := xfunc.Closure func_ := xfunc.Param.Closure
func_.Func.Enter = nil func_.Func.Enter = nil
for l := func_.Func.Cvars; l != nil; l = l.Next { for l := func_.Func.Cvars; l != nil; l = l.Next {
v = l.N v = l.N
...@@ -249,14 +249,14 @@ func capturevars(xfunc *Node) { ...@@ -249,14 +249,14 @@ func capturevars(xfunc *Node) {
// so that the outer frame also grabs them and knows they escape. // so that the outer frame also grabs them and knows they escape.
dowidth(v.Type) dowidth(v.Type)
outer = v.Outerexpr outer = v.Param.Outerexpr
v.Outerexpr = nil v.Param.Outerexpr = nil
// out parameters will be assigned to implicitly upon return. // out parameters will be assigned to implicitly upon return.
if outer.Class != PPARAMOUT && !v.Closure.Addrtaken && !v.Closure.Assigned && v.Type.Width <= 128 { if outer.Class != PPARAMOUT && !v.Param.Closure.Addrtaken && !v.Param.Closure.Assigned && v.Type.Width <= 128 {
v.Name.Byval = true v.Name.Byval = true
} else { } else {
v.Closure.Addrtaken = true v.Param.Closure.Addrtaken = true
outer = Nod(OADDR, outer, nil) outer = Nod(OADDR, outer, nil)
} }
...@@ -269,7 +269,7 @@ func capturevars(xfunc *Node) { ...@@ -269,7 +269,7 @@ func capturevars(xfunc *Node) {
if v.Name.Byval { if v.Name.Byval {
how = "value" how = "value"
} }
Warnl(int(v.Lineno), "%v capturing by %s: %v (addr=%v assign=%v width=%d)", name, how, v.Sym, v.Closure.Addrtaken, v.Closure.Assigned, int32(v.Type.Width)) Warnl(int(v.Lineno), "%v capturing by %s: %v (addr=%v assign=%v width=%d)", name, how, v.Sym, v.Param.Closure.Addrtaken, v.Param.Closure.Assigned, int32(v.Type.Width))
} }
typecheck(&outer, Erv) typecheck(&outer, Erv)
...@@ -284,9 +284,9 @@ func capturevars(xfunc *Node) { ...@@ -284,9 +284,9 @@ func capturevars(xfunc *Node) {
func transformclosure(xfunc *Node) { func transformclosure(xfunc *Node) {
lno := int(lineno) lno := int(lineno)
lineno = xfunc.Lineno lineno = xfunc.Lineno
func_ := xfunc.Closure func_ := xfunc.Param.Closure
if func_.Top&Ecall != 0 { if func_.Param.Top&Ecall != 0 {
// If the closure is directly called, we transform it to a plain function call // If the closure is directly called, we transform it to a plain function call
// with variables passed as args. This avoids allocation of a closure object. // with variables passed as args. This avoids allocation of a closure object.
// Here we do only a part of the transformation. Walk of OCALLFUNC(OCLOSURE) // Here we do only a part of the transformation. Walk of OCALLFUNC(OCLOSURE)
...@@ -395,7 +395,7 @@ func transformclosure(xfunc *Node) { ...@@ -395,7 +395,7 @@ func transformclosure(xfunc *Node) {
// Declare variable holding addresses taken from closure // Declare variable holding addresses taken from closure
// and initialize in entry prologue. // and initialize in entry prologue.
addr = newname(Lookupf("&%s", v.Sym.Name)) addr = newname(Lookupf("&%s", v.Sym.Name))
addr.Ntype = Nod(OIND, typenod(v.Type), nil) addr.Param.Ntype = Nod(OIND, typenod(v.Type), nil)
addr.Class = PAUTO addr.Class = PAUTO
addr.Used = true addr.Used = true
addr.Curfn = xfunc addr.Curfn = xfunc
...@@ -420,7 +420,7 @@ func transformclosure(xfunc *Node) { ...@@ -420,7 +420,7 @@ func transformclosure(xfunc *Node) {
func walkclosure(func_ *Node, init **NodeList) *Node { func walkclosure(func_ *Node, init **NodeList) *Node {
// If no closure vars, don't bother wrapping. // If no closure vars, don't bother wrapping.
if func_.Func.Cvars == nil { if func_.Func.Cvars == nil {
return func_.Closure.Nname return func_.Param.Closure.Nname
} }
// Create closure in the form of a composite literal. // Create closure in the form of a composite literal.
...@@ -457,7 +457,7 @@ func walkclosure(func_ *Node, init **NodeList) *Node { ...@@ -457,7 +457,7 @@ func walkclosure(func_ *Node, init **NodeList) *Node {
clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil)) clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil))
clos.Esc = func_.Esc clos.Esc = func_.Esc
clos.Right.Implicit = true clos.Right.Implicit = true
clos.List = concat(list1(Nod(OCFUNC, func_.Closure.Nname, nil)), func_.Func.Enter) clos.List = concat(list1(Nod(OCFUNC, func_.Param.Closure.Nname, nil)), func_.Func.Enter)
// Force type conversion from *struct to the func type. // Force type conversion from *struct to the func type.
clos = Nod(OCONVNOP, clos, nil) clos = Nod(OCONVNOP, clos, nil)
...@@ -583,7 +583,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node { ...@@ -583,7 +583,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node {
xfunc.Func.Dupok = true xfunc.Func.Dupok = true
xfunc.Nname = newfuncname(sym) xfunc.Nname = newfuncname(sym)
xfunc.Nname.Sym.Flags |= SymExported // disable export xfunc.Nname.Sym.Flags |= SymExported // disable export
xfunc.Nname.Ntype = xtype xfunc.Nname.Param.Ntype = xtype
xfunc.Nname.Defn = xfunc xfunc.Nname.Defn = xfunc
declare(xfunc.Nname, PFUNC) declare(xfunc.Nname, PFUNC)
...@@ -606,10 +606,10 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node { ...@@ -606,10 +606,10 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node {
xfunc.Func.Dcl = list(xfunc.Func.Dcl, ptr) xfunc.Func.Dcl = list(xfunc.Func.Dcl, ptr)
var body *NodeList var body *NodeList
if Isptr[rcvrtype.Etype] || Isinter(rcvrtype) { if Isptr[rcvrtype.Etype] || Isinter(rcvrtype) {
ptr.Ntype = typenod(rcvrtype) ptr.Param.Ntype = typenod(rcvrtype)
body = list(body, Nod(OAS, ptr, cv)) body = list(body, Nod(OAS, ptr, cv))
} else { } else {
ptr.Ntype = typenod(Ptrto(rcvrtype)) ptr.Param.Ntype = typenod(Ptrto(rcvrtype))
body = list(body, Nod(OAS, ptr, Nod(OADDR, cv, nil))) body = list(body, Nod(OAS, ptr, Nod(OADDR, cv, nil)))
} }
......
...@@ -260,7 +260,7 @@ func variter(vl *NodeList, t *Node, el *NodeList) *NodeList { ...@@ -260,7 +260,7 @@ func variter(vl *NodeList, t *Node, el *NodeList) *NodeList {
v = vl.N v = vl.N
v.Op = ONAME v.Op = ONAME
declare(v, dclcontext) declare(v, dclcontext)
v.Ntype = t v.Param.Ntype = t
v.Defn = as2 v.Defn = as2
if Funcdepth > 0 { if Funcdepth > 0 {
init = list(init, Nod(ODCL, v, nil)) init = list(init, Nod(ODCL, v, nil))
...@@ -288,7 +288,7 @@ func variter(vl *NodeList, t *Node, el *NodeList) *NodeList { ...@@ -288,7 +288,7 @@ func variter(vl *NodeList, t *Node, el *NodeList) *NodeList {
v = vl.N v = vl.N
v.Op = ONAME v.Op = ONAME
declare(v, dclcontext) declare(v, dclcontext)
v.Ntype = t v.Param.Ntype = t
if e != nil || Funcdepth > 0 || isblank(v) { if e != nil || Funcdepth > 0 || isblank(v) {
if Funcdepth > 0 { if Funcdepth > 0 {
...@@ -343,7 +343,7 @@ func constiter(vl *NodeList, t *Node, cl *NodeList) *NodeList { ...@@ -343,7 +343,7 @@ func constiter(vl *NodeList, t *Node, cl *NodeList) *NodeList {
v.Op = OLITERAL v.Op = OLITERAL
declare(v, dclcontext) declare(v, dclcontext)
v.Ntype = t v.Param.Ntype = t
v.Defn = c v.Defn = c
vv = list(vv, Nod(ODCLCONST, v, nil)) vv = list(vv, Nod(ODCLCONST, v, nil))
...@@ -431,7 +431,7 @@ func oldname(s *Sym) *Node { ...@@ -431,7 +431,7 @@ func oldname(s *Sym) *Node {
// are parsing x := 5 inside the closure, until we get to // are parsing x := 5 inside the closure, until we get to
// the := it looks like a reference to the outer x so we'll // the := it looks like a reference to the outer x so we'll
// make x a closure variable unnecessarily. // make x a closure variable unnecessarily.
if n.Closure == nil || n.Closure.Funcdepth != Funcdepth { if n.Param.Closure == nil || n.Param.Closure.Funcdepth != Funcdepth {
// create new closure var. // create new closure var.
c := Nod(ONAME, nil, nil) c := Nod(ONAME, nil, nil)
...@@ -442,15 +442,15 @@ func oldname(s *Sym) *Node { ...@@ -442,15 +442,15 @@ func oldname(s *Sym) *Node {
c.Addable = false c.Addable = false
c.Ullman = 2 c.Ullman = 2
c.Funcdepth = Funcdepth c.Funcdepth = Funcdepth
c.Outer = n.Closure c.Param.Outer = n.Param.Closure
n.Closure = c n.Param.Closure = c
c.Closure = n c.Param.Closure = n
c.Xoffset = 0 c.Xoffset = 0
Curfn.Func.Cvars = list(Curfn.Func.Cvars, c) Curfn.Func.Cvars = list(Curfn.Func.Cvars, c)
} }
// return ref to closure var, not original // return ref to closure var, not original
return n.Closure return n.Param.Closure
} }
return n return n
...@@ -555,7 +555,7 @@ func ifacedcl(n *Node) { ...@@ -555,7 +555,7 @@ func ifacedcl(n *Node) {
dclcontext = PPARAM dclcontext = PPARAM
markdcl() markdcl()
Funcdepth++ Funcdepth++
n.Outer = Curfn n.Param.Outer = Curfn
Curfn = n Curfn = n
funcargs(n.Right) funcargs(n.Right)
...@@ -584,13 +584,13 @@ func funchdr(n *Node) { ...@@ -584,13 +584,13 @@ func funchdr(n *Node) {
markdcl() markdcl()
Funcdepth++ Funcdepth++
n.Outer = Curfn n.Param.Outer = Curfn
Curfn = n Curfn = n
if n.Nname != nil { if n.Nname != nil {
funcargs(n.Nname.Ntype) funcargs(n.Nname.Param.Ntype)
} else if n.Ntype != nil { } else if n.Param.Ntype != nil {
funcargs(n.Ntype) funcargs(n.Param.Ntype)
} else { } else {
funcargs2(n.Type) funcargs2(n.Type)
} }
...@@ -616,7 +616,7 @@ func funcargs(nt *Node) { ...@@ -616,7 +616,7 @@ func funcargs(nt *Node) {
} }
if n.Left != nil { if n.Left != nil {
n.Left.Op = ONAME n.Left.Op = ONAME
n.Left.Ntype = n.Right n.Left.Param.Ntype = n.Right
declare(n.Left, PPARAM) declare(n.Left, PPARAM)
if dclcontext == PAUTO { if dclcontext == PAUTO {
vargen++ vargen++
...@@ -633,7 +633,7 @@ func funcargs(nt *Node) { ...@@ -633,7 +633,7 @@ func funcargs(nt *Node) {
} }
if n.Left != nil { if n.Left != nil {
n.Left.Op = ONAME n.Left.Op = ONAME
n.Left.Ntype = n.Right n.Left.Param.Ntype = n.Right
declare(n.Left, PPARAM) declare(n.Left, PPARAM)
if dclcontext == PAUTO { if dclcontext == PAUTO {
vargen++ vargen++
...@@ -680,7 +680,7 @@ func funcargs(nt *Node) { ...@@ -680,7 +680,7 @@ func funcargs(nt *Node) {
n.Left = nn n.Left = nn
} }
n.Left.Ntype = n.Right n.Left.Param.Ntype = n.Right
declare(n.Left, PPARAMOUT) declare(n.Left, PPARAMOUT)
if dclcontext == PAUTO { if dclcontext == PAUTO {
i++ i++
...@@ -748,8 +748,8 @@ func funcbody(n *Node) { ...@@ -748,8 +748,8 @@ func funcbody(n *Node) {
} }
popdcl() popdcl()
Funcdepth-- Funcdepth--
Curfn = n.Outer Curfn = n.Param.Outer
n.Outer = nil n.Param.Outer = nil
if Funcdepth == 0 { if Funcdepth == 0 {
dclcontext = PEXTERN dclcontext = PEXTERN
} }
...@@ -771,7 +771,7 @@ func typedcl0(s *Sym) *Node { ...@@ -771,7 +771,7 @@ func typedcl0(s *Sym) *Node {
* return the ODCLTYPE node to use. * return the ODCLTYPE node to use.
*/ */
func typedcl1(n *Node, t *Node, local bool) *Node { func typedcl1(n *Node, t *Node, local bool) *Node {
n.Ntype = t n.Param.Ntype = t
n.Local = local n.Local = local
return Nod(ODCLTYPE, n, nil) return Nod(ODCLTYPE, n, nil)
} }
......
...@@ -154,7 +154,7 @@ func (v *bottomUpVisitor) visitcode(n *Node, min uint32) uint32 { ...@@ -154,7 +154,7 @@ func (v *bottomUpVisitor) visitcode(n *Node, min uint32) uint32 {
} }
if n.Op == OCLOSURE { if n.Op == OCLOSURE {
m := v.visit(n.Closure) m := v.visit(n.Param.Closure)
if m < min { if m < min {
min = m min = m
} }
...@@ -849,7 +849,7 @@ func esc(e *EscState, n *Node, up *Node) { ...@@ -849,7 +849,7 @@ func esc(e *EscState, n *Node, up *Node) {
if v.Op == OXXX { // unnamed out argument; see dcl.c:/^funcargs if v.Op == OXXX { // unnamed out argument; see dcl.c:/^funcargs
continue continue
} }
a = v.Closure a = v.Param.Closure
if !v.Name.Byval { if !v.Name.Byval {
a = Nod(OADDR, a, nil) a = Nod(OADDR, a, nil)
a.Lineno = v.Lineno a.Lineno = v.Lineno
...@@ -1363,7 +1363,7 @@ func esccall(e *EscState, n *Node, up *Node) { ...@@ -1363,7 +1363,7 @@ func esccall(e *EscState, n *Node, up *Node) {
} }
if fn != nil && fn.Op == ONAME && fn.Class == PFUNC && if fn != nil && fn.Op == ONAME && fn.Class == PFUNC &&
fn.Defn != nil && fn.Defn.Nbody != nil && fn.Ntype != nil && fn.Defn.Esc < EscFuncTagged { fn.Defn != nil && fn.Defn.Nbody != nil && fn.Param.Ntype != nil && fn.Defn.Esc < EscFuncTagged {
if Debug['m'] > 2 { if Debug['m'] > 2 {
fmt.Printf("%v::esccall:: %v in recursive group\n", Ctxt.Line(int(lineno)), Nconv(n, obj.FmtShort)) fmt.Printf("%v::esccall:: %v in recursive group\n", Ctxt.Line(int(lineno)), Nconv(n, obj.FmtShort))
} }
...@@ -1375,17 +1375,17 @@ func esccall(e *EscState, n *Node, up *Node) { ...@@ -1375,17 +1375,17 @@ func esccall(e *EscState, n *Node, up *Node) {
} }
// set up out list on this call node // set up out list on this call node
for lr := fn.Ntype.Rlist; lr != nil; lr = lr.Next { for lr := fn.Param.Ntype.Rlist; lr != nil; lr = lr.Next {
n.Escretval = list(n.Escretval, lr.N.Left) // type.rlist -> dclfield -> ONAME (PPARAMOUT) n.Escretval = list(n.Escretval, lr.N.Left) // type.rlist -> dclfield -> ONAME (PPARAMOUT)
} }
// Receiver. // Receiver.
if n.Op != OCALLFUNC { if n.Op != OCALLFUNC {
escassign(e, fn.Ntype.Left.Left, n.Left.Left) escassign(e, fn.Param.Ntype.Left.Left, n.Left.Left)
} }
var src *Node var src *Node
for lr := fn.Ntype.List; ll != nil && lr != nil; ll, lr = ll.Next, lr.Next { for lr := fn.Param.Ntype.List; ll != nil && lr != nil; ll, lr = ll.Next, lr.Next {
src = ll.N src = ll.N
if lr.N.Isddd && !n.Isddd { if lr.N.Isddd && !n.Isddd {
// Introduce ODDDARG node to represent ... allocation. // Introduce ODDDARG node to represent ... allocation.
...@@ -1653,7 +1653,7 @@ func escwalk(e *EscState, level Level, dst *Node, src *Node) { ...@@ -1653,7 +1653,7 @@ func escwalk(e *EscState, level Level, dst *Node, src *Node) {
if leaks && Debug['m'] != 0 { if leaks && Debug['m'] != 0 {
Warnl(int(src.Lineno), "leaking closure reference %v", Nconv(src, obj.FmtShort)) Warnl(int(src.Lineno), "leaking closure reference %v", Nconv(src, obj.FmtShort))
} }
escwalk(e, level, dst, src.Closure) escwalk(e, level, dst, src.Param.Closure)
} }
case OPTRLIT, OADDR: case OPTRLIT, OADDR:
......
...@@ -64,7 +64,7 @@ func autoexport(n *Node, ctxt uint8) { ...@@ -64,7 +64,7 @@ func autoexport(n *Node, ctxt uint8) {
if (ctxt != PEXTERN && ctxt != PFUNC) || dclcontext != PEXTERN { if (ctxt != PEXTERN && ctxt != PFUNC) || dclcontext != PEXTERN {
return return
} }
if n.Param != nil && n.Ntype != nil && n.Ntype.Op == OTFUNC && n.Ntype.Left != nil { // method if n.Param != nil && n.Param.Ntype != nil && n.Param.Ntype.Op == OTFUNC && n.Param.Ntype.Left != nil { // method
return return
} }
......
...@@ -1199,7 +1199,7 @@ func exprfmt(n *Node, prec int) string { ...@@ -1199,7 +1199,7 @@ func exprfmt(n *Node, prec int) string {
if n.Nbody != nil { if n.Nbody != nil {
return fmt.Sprintf("%v { %v }", n.Type, n.Nbody) return fmt.Sprintf("%v { %v }", n.Type, n.Nbody)
} }
return fmt.Sprintf("%v { %v }", n.Type, n.Closure.Nbody) return fmt.Sprintf("%v { %v }", n.Type, n.Param.Closure.Nbody)
case OCOMPLIT: case OCOMPLIT:
ptrlit := n.Right != nil && n.Right.Implicit && n.Right.Type != nil && Isptr[n.Right.Type.Etype] ptrlit := n.Right != nil && n.Right.Implicit && n.Right.Type != nil && Isptr[n.Right.Type.Etype]
...@@ -1521,9 +1521,9 @@ func nodedump(n *Node, flag int) string { ...@@ -1521,9 +1521,9 @@ func nodedump(n *Node, flag int) string {
} else { } else {
fmt.Fprintf(&buf, "%v%v", Oconv(int(n.Op), 0), Jconv(n, 0)) fmt.Fprintf(&buf, "%v%v", Oconv(int(n.Op), 0), Jconv(n, 0))
} }
if recur && n.Type == nil && n.Ntype != nil { if recur && n.Type == nil && n.Param.Ntype != nil {
indent(&buf) indent(&buf)
fmt.Fprintf(&buf, "%v-ntype%v", Oconv(int(n.Op), 0), n.Ntype) fmt.Fprintf(&buf, "%v-ntype%v", Oconv(int(n.Op), 0), n.Param.Ntype)
} }
case OASOP: case OASOP:
...@@ -1531,9 +1531,9 @@ func nodedump(n *Node, flag int) string { ...@@ -1531,9 +1531,9 @@ func nodedump(n *Node, flag int) string {
case OTYPE: case OTYPE:
fmt.Fprintf(&buf, "%v %v%v type=%v", Oconv(int(n.Op), 0), n.Sym, Jconv(n, 0), n.Type) fmt.Fprintf(&buf, "%v %v%v type=%v", Oconv(int(n.Op), 0), n.Sym, Jconv(n, 0), n.Type)
if recur && n.Type == nil && n.Ntype != nil { if recur && n.Type == nil && n.Param.Ntype != nil {
indent(&buf) indent(&buf)
fmt.Fprintf(&buf, "%v-ntype%v", Oconv(int(n.Op), 0), n.Ntype) fmt.Fprintf(&buf, "%v-ntype%v", Oconv(int(n.Op), 0), n.Param.Ntype)
} }
} }
......
...@@ -57,14 +57,14 @@ func addrescapes(n *Node) { ...@@ -57,14 +57,14 @@ func addrescapes(n *Node) {
// expression to refer to stack copy // expression to refer to stack copy
case PPARAM, PPARAMOUT: case PPARAM, PPARAMOUT:
n.Stackparam = Nod(OPARAM, n, nil) n.Param.Stackparam = Nod(OPARAM, n, nil)
n.Stackparam.Type = n.Type n.Param.Stackparam.Type = n.Type
n.Stackparam.Addable = true n.Param.Stackparam.Addable = true
if n.Xoffset == BADWIDTH { if n.Xoffset == BADWIDTH {
Fatal("addrescapes before param assignment") Fatal("addrescapes before param assignment")
} }
n.Stackparam.Xoffset = n.Xoffset n.Param.Stackparam.Xoffset = n.Xoffset
fallthrough fallthrough
case PAUTO: case PAUTO:
......
...@@ -1422,7 +1422,7 @@ fndcl: ...@@ -1422,7 +1422,7 @@ fndcl:
$$ = Nod(ODCLFUNC, nil, nil); $$ = Nod(ODCLFUNC, nil, nil);
$$.Nname = newfuncname($1); $$.Nname = newfuncname($1);
$$.Nname.Defn = $$; $$.Nname.Defn = $$;
$$.Nname.Ntype = t; // TODO: check if nname already has an ntype $$.Nname.Param.Ntype = t; // TODO: check if nname already has an ntype
declare($$.Nname, PFUNC); declare($$.Nname, PFUNC);
funchdr($$); funchdr($$);
...@@ -1457,7 +1457,7 @@ fndcl: ...@@ -1457,7 +1457,7 @@ fndcl:
$$.Func.Shortname = newfuncname($4); $$.Func.Shortname = newfuncname($4);
$$.Nname = methodname1($$.Func.Shortname, rcvr.Right); $$.Nname = methodname1($$.Func.Shortname, rcvr.Right);
$$.Nname.Defn = $$; $$.Nname.Defn = $$;
$$.Nname.Ntype = t; $$.Nname.Param.Ntype = t;
$$.Nname.Nointerface = nointerface; $$.Nname.Nointerface = nointerface;
declare($$.Nname, PFUNC); declare($$.Nname, PFUNC);
......
...@@ -116,7 +116,7 @@ func fninit(n *NodeList) { ...@@ -116,7 +116,7 @@ func fninit(n *NodeList) {
initsym := Lookup("init") initsym := Lookup("init")
fn.Nname = newname(initsym) fn.Nname = newname(initsym)
fn.Nname.Defn = fn fn.Nname.Defn = fn
fn.Nname.Ntype = Nod(OTFUNC, nil, nil) fn.Nname.Param.Ntype = Nod(OTFUNC, nil, nil)
declare(fn.Nname, PFUNC) declare(fn.Nname, PFUNC)
funchdr(fn) funchdr(fn)
......
...@@ -400,7 +400,7 @@ func Main() { ...@@ -400,7 +400,7 @@ func Main() {
// This needs to run before escape analysis, // This needs to run before escape analysis,
// because variables captured by value do not escape. // because variables captured by value do not escape.
for l := xtop; l != nil; l = l.Next { for l := xtop; l != nil; l = l.Next {
if l.N.Op == ODCLFUNC && l.N.Closure != nil { if l.N.Op == ODCLFUNC && l.N.Param.Closure != nil {
Curfn = l.N Curfn = l.N
capturevars(l.N) capturevars(l.N)
} }
...@@ -454,7 +454,7 @@ func Main() { ...@@ -454,7 +454,7 @@ func Main() {
// This needs to happen before walk, because closures must be transformed // This needs to happen before walk, because closures must be transformed
// before walk reaches a call of a closure. // before walk reaches a call of a closure.
for l := xtop; l != nil; l = l.Next { for l := xtop; l != nil; l = l.Next {
if l.N.Op == ODCLFUNC && l.N.Closure != nil { if l.N.Op == ODCLFUNC && l.N.Param.Closure != nil {
Curfn = l.N Curfn = l.N
transformclosure(l.N) transformclosure(l.N)
} }
......
...@@ -221,7 +221,7 @@ func init2(n *Node, out **NodeList) { ...@@ -221,7 +221,7 @@ func init2(n *Node, out **NodeList) {
init2list(n.Nelse, out) init2list(n.Nelse, out)
if n.Op == OCLOSURE { if n.Op == OCLOSURE {
init2list(n.Closure.Nbody, out) init2list(n.Param.Closure.Nbody, out)
} }
if n.Op == ODOTMETH || n.Op == OCALLPART { if n.Op == ODOTMETH || n.Op == OCALLPART {
init2(n.Type.Nname, out) init2(n.Type.Nname, out)
......
...@@ -2375,7 +2375,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) { ...@@ -2375,7 +2375,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
markdcl() markdcl()
this := Nod(ODCLFIELD, newname(Lookup(".this")), typenod(rcvr)) this := Nod(ODCLFIELD, newname(Lookup(".this")), typenod(rcvr))
this.Left.Ntype = this.Right this.Left.Param.Ntype = this.Right
in := structargs(getinarg(method.Type), 1) in := structargs(getinarg(method.Type), 1)
out := structargs(Getoutarg(method.Type), 0) out := structargs(Getoutarg(method.Type), 0)
...@@ -2401,7 +2401,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) { ...@@ -2401,7 +2401,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
fn := Nod(ODCLFUNC, nil, nil) fn := Nod(ODCLFUNC, nil, nil)
fn.Nname = newname(newnam) fn.Nname = newname(newnam)
fn.Nname.Defn = fn fn.Nname.Defn = fn
fn.Nname.Ntype = t fn.Nname.Param.Ntype = t
declare(fn.Nname, PFUNC) declare(fn.Nname, PFUNC)
funchdr(fn) funchdr(fn)
...@@ -2575,7 +2575,7 @@ func genhash(sym *Sym, t *Type) { ...@@ -2575,7 +2575,7 @@ func genhash(sym *Sym, t *Type) {
fn.Nname = newname(sym) fn.Nname = newname(sym)
fn.Nname.Class = PFUNC fn.Nname.Class = PFUNC
tfn := Nod(OTFUNC, nil, nil) tfn := Nod(OTFUNC, nil, nil)
fn.Nname.Ntype = tfn fn.Nname.Param.Ntype = tfn
n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t))) n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t)))
tfn.List = list(tfn.List, n) tfn.List = list(tfn.List, n)
...@@ -2587,7 +2587,7 @@ func genhash(sym *Sym, t *Type) { ...@@ -2587,7 +2587,7 @@ func genhash(sym *Sym, t *Type) {
tfn.Rlist = list(tfn.Rlist, n) tfn.Rlist = list(tfn.Rlist, n)
funchdr(fn) funchdr(fn)
typecheck(&fn.Nname.Ntype, Etype) typecheck(&fn.Nname.Param.Ntype, Etype)
// genhash is only called for types that have equality but // genhash is only called for types that have equality but
// cannot be handled by the standard algorithms, // cannot be handled by the standard algorithms,
...@@ -2827,7 +2827,7 @@ func geneq(sym *Sym, t *Type) { ...@@ -2827,7 +2827,7 @@ func geneq(sym *Sym, t *Type) {
fn.Nname = newname(sym) fn.Nname = newname(sym)
fn.Nname.Class = PFUNC fn.Nname.Class = PFUNC
tfn := Nod(OTFUNC, nil, nil) tfn := Nod(OTFUNC, nil, nil)
fn.Nname.Ntype = tfn fn.Nname.Param.Ntype = tfn
n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t))) n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t)))
tfn.List = list(tfn.List, n) tfn.List = list(tfn.List, n)
......
...@@ -169,10 +169,10 @@ func typecheckswitch(n *Node) { ...@@ -169,10 +169,10 @@ func typecheckswitch(n *Node) {
if nvar != nil { if nvar != nil {
if ll != nil && ll.Next == nil && ll.N.Type != nil && !Istype(ll.N.Type, TNIL) { if ll != nil && ll.Next == nil && ll.N.Type != nil && !Istype(ll.N.Type, TNIL) {
// single entry type switch // single entry type switch
nvar.Ntype = typenod(ll.N.Type) nvar.Param.Ntype = typenod(ll.N.Type)
} else { } else {
// multiple entry type switch or default // multiple entry type switch or default
nvar.Ntype = typenod(n.Type) nvar.Param.Ntype = typenod(n.Type)
} }
typecheck(&nvar, Erv|Easgn) typecheck(&nvar, Erv|Easgn)
......
...@@ -38,7 +38,7 @@ type Node struct { ...@@ -38,7 +38,7 @@ type Node struct {
Curfn *Node // function for local variables Curfn *Node // function for local variables
Paramfld *Type // TFIELD for this PPARAM; also for ODOT, curfn Paramfld *Type // TFIELD for this PPARAM; also for ODOT, curfn
Alloc *Node // allocation call Alloc *Node // allocation call
*Param Param *Param
// OPACK // OPACK
Pkg *Pkg Pkg *Pkg
......
...@@ -813,8 +813,8 @@ OpSwitch: ...@@ -813,8 +813,8 @@ OpSwitch:
var l *Node var l *Node
for l = n.Left; l != r; l = l.Left { for l = n.Left; l != r; l = l.Left {
l.Addrtaken = true l.Addrtaken = true
if l.Param != nil && l.Closure != nil { if l.Param != nil && l.Param.Closure != nil {
l.Closure.Addrtaken = true l.Param.Closure.Addrtaken = true
} }
} }
...@@ -822,8 +822,8 @@ OpSwitch: ...@@ -822,8 +822,8 @@ OpSwitch:
Fatal("found non-orig name node %v", l) Fatal("found non-orig name node %v", l)
} }
l.Addrtaken = true l.Addrtaken = true
if l.Param != nil && l.Closure != nil { if l.Param != nil && l.Param.Closure != nil {
l.Closure.Addrtaken = true l.Param.Closure.Addrtaken = true
} }
defaultlit(&n.Left, nil) defaultlit(&n.Left, nil)
l = n.Left l = n.Left
...@@ -3273,14 +3273,14 @@ func checkassign(stmt *Node, n *Node) { ...@@ -3273,14 +3273,14 @@ func checkassign(stmt *Node, n *Node) {
var l *Node var l *Node
for l = n; l != r; l = l.Left { for l = n; l != r; l = l.Left {
l.Assigned = true l.Assigned = true
if l.Param != nil && l.Closure != nil { if l.Param != nil && l.Param.Closure != nil {
l.Closure.Assigned = true l.Param.Closure.Assigned = true
} }
} }
l.Assigned = true l.Assigned = true
if l.Param != nil && l.Closure != nil { if l.Param != nil && l.Param.Closure != nil {
l.Closure.Assigned = true l.Param.Closure.Assigned = true
} }
} }
...@@ -3345,7 +3345,7 @@ func typecheckas(n *Node) { ...@@ -3345,7 +3345,7 @@ func typecheckas(n *Node) {
// so that the conversion below happens). // so that the conversion below happens).
n.Left = resolve(n.Left) n.Left = resolve(n.Left)
if n.Left.Defn != n || n.Left.Ntype != nil { if n.Left.Defn != n || n.Left.Param.Ntype != nil {
typecheck(&n.Left, Erv|Easgn) typecheck(&n.Left, Erv|Easgn)
} }
...@@ -3357,7 +3357,7 @@ func typecheckas(n *Node) { ...@@ -3357,7 +3357,7 @@ func typecheckas(n *Node) {
} }
} }
if n.Left.Defn == n && n.Left.Ntype == nil { if n.Left.Defn == n && n.Left.Param.Ntype == nil {
defaultlit(&n.Right, nil) defaultlit(&n.Right, nil)
n.Left.Type = n.Right.Type n.Left.Type = n.Right.Type
} }
...@@ -3386,7 +3386,7 @@ func typecheckas2(n *Node) { ...@@ -3386,7 +3386,7 @@ func typecheckas2(n *Node) {
// delicate little dance. // delicate little dance.
ll.N = resolve(ll.N) ll.N = resolve(ll.N)
if ll.N.Defn != n || ll.N.Ntype != nil { if ll.N.Defn != n || ll.N.Param.Ntype != nil {
typecheck(&ll.N, Erv|Easgn) typecheck(&ll.N, Erv|Easgn)
} }
} }
...@@ -3410,7 +3410,7 @@ func typecheckas2(n *Node) { ...@@ -3410,7 +3410,7 @@ func typecheckas2(n *Node) {
if ll.N.Type != nil && lr.N.Type != nil { if ll.N.Type != nil && lr.N.Type != nil {
lr.N = assignconv(lr.N, ll.N.Type, "assignment") lr.N = assignconv(lr.N, ll.N.Type, "assignment")
} }
if ll.N.Defn == n && ll.N.Ntype == nil { if ll.N.Defn == n && ll.N.Param.Ntype == nil {
defaultlit(&lr.N, nil) defaultlit(&lr.N, nil)
ll.N.Type = lr.N.Type ll.N.Type = lr.N.Type
} }
...@@ -3443,7 +3443,7 @@ func typecheckas2(n *Node) { ...@@ -3443,7 +3443,7 @@ func typecheckas2(n *Node) {
if t.Type != nil && ll.N.Type != nil { if t.Type != nil && ll.N.Type != nil {
checkassignto(t.Type, ll.N) checkassignto(t.Type, ll.N)
} }
if ll.N.Defn == n && ll.N.Ntype == nil { if ll.N.Defn == n && ll.N.Param.Ntype == nil {
ll.N.Type = t.Type ll.N.Type = t.Type
} }
t = structnext(&s) t = structnext(&s)
...@@ -3482,7 +3482,7 @@ func typecheckas2(n *Node) { ...@@ -3482,7 +3482,7 @@ func typecheckas2(n *Node) {
if l.Type != nil && l.Type.Etype != TBOOL { if l.Type != nil && l.Type.Etype != TBOOL {
checkassignto(Types[TBOOL], l) checkassignto(Types[TBOOL], l)
} }
if l.Defn == n && l.Ntype == nil { if l.Defn == n && l.Param.Ntype == nil {
l.Type = Types[TBOOL] l.Type = Types[TBOOL]
} }
goto out goto out
...@@ -3646,8 +3646,8 @@ func typecheckdeftype(n *Node) { ...@@ -3646,8 +3646,8 @@ func typecheckdeftype(n *Node) {
setlineno(n) setlineno(n)
n.Type.Sym = n.Sym n.Type.Sym = n.Sym
n.Typecheck = 1 n.Typecheck = 1
typecheck(&n.Ntype, Etype) typecheck(&n.Param.Ntype, Etype)
t := n.Ntype.Type t := n.Param.Ntype.Type
if t == nil { if t == nil {
n.Diag = 1 n.Diag = 1
n.Type = nil n.Type = nil
...@@ -3757,10 +3757,10 @@ func typecheckdef(n *Node) *Node { ...@@ -3757,10 +3757,10 @@ func typecheckdef(n *Node) *Node {
break break
case OLITERAL: case OLITERAL:
if n.Ntype != nil { if n.Param.Ntype != nil {
typecheck(&n.Ntype, Etype) typecheck(&n.Param.Ntype, Etype)
n.Type = n.Ntype.Type n.Type = n.Param.Ntype.Type
n.Ntype = nil n.Param.Ntype = nil
if n.Type == nil { if n.Type == nil {
n.Diag = 1 n.Diag = 1
goto ret goto ret
...@@ -3809,9 +3809,9 @@ func typecheckdef(n *Node) *Node { ...@@ -3809,9 +3809,9 @@ func typecheckdef(n *Node) *Node {
n.Type = e.Type n.Type = e.Type
case ONAME: case ONAME:
if n.Ntype != nil { if n.Param.Ntype != nil {
typecheck(&n.Ntype, Etype) typecheck(&n.Param.Ntype, Etype)
n.Type = n.Ntype.Type n.Type = n.Param.Ntype.Type
if n.Type == nil { if n.Type == nil {
n.Diag = 1 n.Diag = 1
......
...@@ -615,7 +615,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -615,7 +615,7 @@ func walkexpr(np **Node, init **NodeList) {
n.Left.Func.Enter = nil n.Left.Func.Enter = nil
// Replace OCLOSURE with ONAME/PFUNC. // Replace OCLOSURE with ONAME/PFUNC.
n.Left = n.Left.Closure.Nname n.Left = n.Left.Param.Closure.Nname
// Update type of OCALLFUNC node. // Update type of OCALLFUNC node.
// Output arguments had not changed, but their offsets could. // Output arguments had not changed, but their offsets could.
...@@ -2687,8 +2687,8 @@ func paramstoheap(argin **Type, out int) *NodeList { ...@@ -2687,8 +2687,8 @@ func paramstoheap(argin **Type, out int) *NodeList {
} }
nn = list(nn, Nod(OAS, v.Name.Heapaddr, v.Alloc)) nn = list(nn, Nod(OAS, v.Name.Heapaddr, v.Alloc))
if v.Class&^PHEAP != PPARAMOUT { if v.Class&^PHEAP != PPARAMOUT {
as = Nod(OAS, v, v.Stackparam) as = Nod(OAS, v, v.Param.Stackparam)
v.Stackparam.Typecheck = 1 v.Param.Stackparam.Typecheck = 1
typecheck(&as, Etop) typecheck(&as, Etop)
as = applywritebarrier(as, &nn) as = applywritebarrier(as, &nn)
nn = list(nn, as) nn = list(nn, as)
...@@ -2711,7 +2711,7 @@ func returnsfromheap(argin **Type) *NodeList { ...@@ -2711,7 +2711,7 @@ func returnsfromheap(argin **Type) *NodeList {
if v == nil || v.Class != PHEAP|PPARAMOUT { if v == nil || v.Class != PHEAP|PPARAMOUT {
continue continue
} }
nn = list(nn, Nod(OAS, v.Stackparam, v)) nn = list(nn, Nod(OAS, v.Param.Stackparam, v))
} }
return nn return nn
...@@ -4026,7 +4026,7 @@ func walkprintfunc(np **Node, init **NodeList) { ...@@ -4026,7 +4026,7 @@ func walkprintfunc(np **Node, init **NodeList) {
buf = fmt.Sprintf("print·%d", walkprintfunc_prgen) buf = fmt.Sprintf("print·%d", walkprintfunc_prgen)
fn.Nname = newname(Lookup(buf)) fn.Nname = newname(Lookup(buf))
fn.Nname.Defn = fn fn.Nname.Defn = fn
fn.Nname.Ntype = t fn.Nname.Param.Ntype = t
declare(fn.Nname, PFUNC) declare(fn.Nname, PFUNC)
oldfn := Curfn oldfn := Curfn
......
...@@ -2560,7 +2560,7 @@ yydefault: ...@@ -2560,7 +2560,7 @@ yydefault:
yyVAL.node = Nod(ODCLFUNC, nil, nil) yyVAL.node = Nod(ODCLFUNC, nil, nil)
yyVAL.node.Nname = newfuncname(yyDollar[1].sym) yyVAL.node.Nname = newfuncname(yyDollar[1].sym)
yyVAL.node.Nname.Defn = yyVAL.node yyVAL.node.Nname.Defn = yyVAL.node
yyVAL.node.Nname.Ntype = t // TODO: check if nname already has an ntype yyVAL.node.Nname.Param.Ntype = t // TODO: check if nname already has an ntype
declare(yyVAL.node.Nname, PFUNC) declare(yyVAL.node.Nname, PFUNC)
funchdr(yyVAL.node) funchdr(yyVAL.node)
...@@ -2597,7 +2597,7 @@ yydefault: ...@@ -2597,7 +2597,7 @@ yydefault:
yyVAL.node.Func.Shortname = newfuncname(yyDollar[4].sym) yyVAL.node.Func.Shortname = newfuncname(yyDollar[4].sym)
yyVAL.node.Nname = methodname1(yyVAL.node.Func.Shortname, rcvr.Right) yyVAL.node.Nname = methodname1(yyVAL.node.Func.Shortname, rcvr.Right)
yyVAL.node.Nname.Defn = yyVAL.node yyVAL.node.Nname.Defn = yyVAL.node
yyVAL.node.Nname.Ntype = t yyVAL.node.Nname.Param.Ntype = t
yyVAL.node.Nname.Nointerface = nointerface yyVAL.node.Nname.Nointerface = nointerface
declare(yyVAL.node.Nname, PFUNC) declare(yyVAL.node.Nname, PFUNC)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment