Passes toolstash-check -all.
Change-Id: Ib9f969e5ecc1537b7eab186dc4fd504a50f800f2
Reviewed-on: https://go-review.googlesource.com/38586
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
if int(cv.Type.Align) > Widthptr {
cv.Xoffset = int64(cv.Type.Align)
}
- ptr := nod(ONAME, nil, nil)
- ptr.Sym = lookup("rcvr")
+ ptr := newname(lookup("rcvr"))
ptr.Class = PAUTO
- ptr.SetAddable(true)
ptr.SetUsed(true)
ptr.Name.Curfn = xfunc
- ptr.Xoffset = 0
xfunc.Func.Dcl = append(xfunc.Func.Dcl, ptr)
var body []*Node
if rcvrtype.IsPtr() || rcvrtype.IsInterface() {
return init
}
-// newname returns a new ONAME Node associated with symbol s.
-func newname(s *Sym) *Node {
- if s == nil {
- Fatalf("newname nil")
- }
- n := nod(ONAME, nil, nil)
- n.Sym = s
- n.SetAddable(true)
- n.Xoffset = 0
- return n
-}
-
// newnoname returns a new ONONAME Node associated with symbol s.
func newnoname(s *Sym) *Node {
if s == nil {
c := n.Name.Param.Innermost
if c == nil || c.Name.Funcdepth != funcdepth {
// Do not have a closure var for the active closure yet; make one.
- c = nod(ONAME, nil, nil)
- c.Sym = s
+ c = newname(s)
c.Class = PAUTOHEAP
c.SetIsClosureVar(true)
c.SetIsddd(n.Isddd())
c.Name.Param.Outer = n.Name.Param.Innermost
n.Name.Param.Innermost = c
- c.Xoffset = 0
Curfn.Func.Cvars.Append(c)
}
cE := e.nodeEscState(call)
cE.Retval.Set(nil) // Suspect this is not nil for indirect calls.
for i, f := range fntype.Results().Fields().Slice() {
- ret := nod(ONAME, nil, nil)
buf := fmt.Sprintf(".out%d", i)
- ret.Sym = lookup(buf)
+ ret := newname(lookup(buf))
+ ret.SetAddable(false) // TODO(mdempsky): Seems suspicious.
ret.Type = f.Type
ret.Class = PAUTO
ret.Name.Curfn = Curfn
// Preserve a copy so we can still write code referring to the original,
// and substitute that copy into the function declaration list
// so that analyses of the local (on-stack) variables use it.
- stackcopy := nod(ONAME, nil, nil)
- stackcopy.Sym = n.Sym
+ stackcopy := newname(n.Sym)
+ stackcopy.SetAddable(false)
stackcopy.Type = n.Type
stackcopy.Xoffset = n.Xoffset
stackcopy.Class = n.Class
// Add a preceding . to avoid clash with legal names.
s := lookupN(".autotmp_", statuniqgen)
statuniqgen++
- n := nod(ONAME, nil, nil)
- n.Sym = s
+ n := newname(s)
s.Def = n
n.Type = t
n.Class = PAUTO
- n.SetAddable(true)
n.Esc = EscNever
n.Name.Curfn = Curfn
n.Name.SetAutoTemp(true)
Curfn.Func.Dcl = append(Curfn.Func.Dcl, n)
dowidth(t)
- n.Xoffset = 0
*nn = *n
}
funarg = t.StructType().Funarg
// Build fake variable name for whole arg struct.
- n = nod(ONAME, nil, nil)
- n.Sym = lookup(".args")
+ n = newname(lookup(".args"))
n.Type = t
first := t.Field(0)
if first == nil {
Fatalf("nodarg: offset not computed for %v", t)
}
n.Xoffset = first.Offset
- n.SetAddable(true)
case *Field:
funarg = t.Funarg
// Build fake name for individual variable.
// This is safe because if there was a real declared name
// we'd have used it above.
- n = nod(ONAME, nil, nil)
+ n = newname(lookup("__"))
n.Type = t.Type
- n.Sym = t.Sym
if t.Offset == BADWIDTH {
Fatalf("nodarg: offset not computed for %v", t)
}
n.Xoffset = t.Offset
- n.SetAddable(true)
n.Orig = t.Nname
}
}
}
-func nod(op Op, nleft *Node, nright *Node) *Node {
+func nod(op Op, nleft, nright *Node) *Node {
+ return nodl(lineno, op, nleft, nright)
+}
+
+func nodl(pos src.XPos, op Op, nleft, nright *Node) *Node {
var n *Node
switch op {
case OCLOSURE, ODCLFUNC:
n = &x.Node
n.Func = &x.Func
case ONAME:
- var x struct {
- Node
- Name
- Param
- }
- n = &x.Node
- n.Name = &x.Name
- n.Name.Param = &x.Param
+ Fatalf("use newname instead")
case OLABEL, OPACK:
var x struct {
Node
n.Op = op
n.Left = nleft
n.Right = nright
- n.Pos = lineno
+ n.Pos = pos
n.Xoffset = BADWIDTH
n.Orig = n
- if n.Name != nil {
- n.Name.Curfn = Curfn
+ return n
+}
+
+// newname returns a new ONAME Node associated with symbol s.
+func newname(s *Sym) *Node {
+ if s == nil {
+ Fatalf("newname nil")
+ }
+
+ var x struct {
+ Node
+ Name
+ Param
}
+ n := &x.Node
+ n.Name = &x.Name
+ n.Name.Param = &x.Param
+
+ n.Op = ONAME
+ n.Pos = lineno
+ n.Name.Curfn = Curfn
+ n.Orig = n
+
+ n.Sym = s
+ n.SetAddable(true)
return n
}
for _, s := range builtinFuncs {
// TODO(marvin): Fix Node.EType type union.
s2 := Pkglookup(s.name, builtinpkg)
- s2.Def = nod(ONAME, nil, nil)
- s2.Def.Sym = s2
+ s2.Def = newname(s2)
s2.Def.Etype = EType(s.op)
}
for _, s := range unsafeFuncs {
s2 := Pkglookup(s.name, unsafepkg)
- s2.Def = nod(ONAME, nil, nil)
- s2.Def.Sym = s2
+ s2.Def = newname(s2)
s2.Def.Etype = EType(s.op)
}
s = lookup("_")
s.Block = -100
- s.Def = nod(ONAME, nil, nil)
- s.Def.Sym = s
+ s.Def = newname(s)
Types[TBLANK] = typ(TBLANK)
s.Def.Type = Types[TBLANK]
nblank = s.Def
s = Pkglookup("_", builtinpkg)
s.Block = -100
- s.Def = nod(ONAME, nil, nil)
- s.Def.Sym = s
+ s.Def = newname(s)
Types[TBLANK] = typ(TBLANK)
s.Def.Type = Types[TBLANK]
s1.Block = s.Block
}
- nodfp = nod(ONAME, nil, nil)
+ nodfp = newname(lookup(".fp"))
nodfp.Type = Types[TINT32]
- nodfp.Xoffset = 0
nodfp.Class = PPARAM
- nodfp.Sym = lookup(".fp")
}