}
if n.Op == OLITERAL {
- nn := Nod(OXXX, nil, nil)
- *nn = *n
- n = nn
+ nn := *n
+ n = &nn
}
switch n.Op {
i2++
}
- nl := Nod(OXXX, nil, nil)
- *nl = *s[i1]
- nl.Orig = nl
+ nl := *s[i1]
+ nl.Orig = &nl
nl.SetVal(Val{strings.Join(strs, "")})
- s[i1] = nl
+ s[i1] = &nl
s = append(s[:i1+1], s[i2:]...)
}
}
}
if n.Op == OLITERAL {
- nn := Nod(OXXX, nil, nil)
- *nn = *n
- n = nn
+ nn := *n
+ n = &nn
}
lno := setlineno(n)
// declare the out arguments.
gen := nt.List.Len()
var i int = 0
- var nn *Node
for _, n = range nt.Rlist.Slice() {
if n.Op != ODCLFIELD {
Fatalf("funcargs out %v", Oconv(n.Op, 0))
// So the two cases must be distinguished.
// We do not record a pointer to the original node (n->orig).
// Having multiple names causes too much confusion in later passes.
- nn = Nod(OXXX, nil, nil)
-
- *nn = *n.Left
- nn.Orig = nn
+ nn := *n.Left
+ nn.Orig = &nn
nn.Sym = LookupN("~b", gen)
gen++
- n.Left = nn
+ n.Left = &nn
}
n.Left.Name.Param.Ntype = n.Right
}
if n.Sym != nil {
- n1 := Nod(OXXX, nil, nil)
- *n1 = *n
- n = n1
+ n1 := *n
+ n = &n1
}
n.Orig = newname(s)
}
func temp(t *Type) *Node {
- n := Nod(OXXX, nil, nil)
- Tempname(n, t)
+ var n Node
+ Tempname(&n, t)
n.Sym.Def.Used = true
return n.Orig
}
return n
}
- m := Nod(OXXX, nil, nil)
- *m = *n
+ m := *n
if m.Func != nil {
m.Func.Inl.Set(nil)
}
m.Ninit.Set(inlcopylist(n.Ninit.Slice()))
m.Nbody.Set(inlcopylist(n.Nbody.Slice()))
- return m
+ return &m
}
// Inlcalls/nodelist/node walks fn's statements and expressions and substitutes any
m.Left = newname(Lookup(p))
return m
- }
-
- m := Nod(OXXX, nil, nil)
- *m = *n
- m.Ninit.Set(nil)
+ default:
+ m := Nod(OXXX, nil, nil)
+ *m = *n
+ m.Ninit.Set(nil)
- if n.Op == OCLOSURE {
- Fatalf("cannot inline function containing closure: %v", Nconv(n, FmtSign))
- }
+ if n.Op == OCLOSURE {
+ Fatalf("cannot inline function containing closure: %v", Nconv(n, FmtSign))
+ }
- m.Left = subst.node(n.Left)
- m.Right = subst.node(n.Right)
- m.List.Set(subst.list(n.List))
- m.Rlist.Set(subst.list(n.Rlist))
- m.Ninit.Set(append(m.Ninit.Slice(), subst.list(n.Ninit)...))
- m.Nbody.Set(subst.list(n.Nbody))
+ m.Left = subst.node(n.Left)
+ m.Right = subst.node(n.Right)
+ m.List.Set(subst.list(n.List))
+ m.Rlist.Set(subst.list(n.Rlist))
+ m.Ninit.Set(append(m.Ninit.Slice(), subst.list(n.Ninit)...))
+ m.Nbody.Set(subst.list(n.Nbody))
- return m
+ return m
+ }
}
// Plaster over linenumbers
if l == n.Left {
return n
}
- a := Nod(OXXX, nil, nil)
- *a = *n
- a.Orig = a
+ a := *n
+ a.Orig = &a
a.Left = l
- a = typecheck(a, Erv)
- return a
+ return typecheck(&a, Erv)
}
return ordercopyexpr(n, n.Type, order, 0)
if l == n.Left {
return n
}
- a := Nod(OXXX, nil, nil)
- *a = *n
- a.Orig = a
+ a := *n
+ a.Orig = &a
a.Left = l
- a = typecheck(a, Erv)
- return a
+ return typecheck(&a, Erv)
case ODOTPTR, OIND:
l := ordercheapexpr(n.Left, order)
if l == n.Left {
return n
}
- a := Nod(OXXX, nil, nil)
- *a = *n
- a.Orig = a
+ a := *n
+ a.Orig = &a
a.Left = l
- a = typecheck(a, Erv)
- return a
+ return typecheck(&a, Erv)
case OINDEX, OINDEXMAP:
var l *Node
if l == n.Left && r == n.Right {
return n
}
- a := Nod(OXXX, nil, nil)
- *a = *n
- a.Orig = a
+ a := *n
+ a.Orig = &a
a.Left = l
a.Right = r
- a = typecheck(a, Erv)
- return a
+ return typecheck(&a, Erv)
+ default:
+ Fatalf("ordersafeexpr %v", Oconv(n.Op, 0))
+ return nil // not reached
}
-
- Fatalf("ordersafeexpr %v", Oconv(n.Op, 0))
- return nil // not reached
}
// Istemp reports whether n is a temporary variable.
// nodpc is the PC of the caller as extracted by
// getcallerpc. We use -widthptr(FP) for x86.
// BUG: this will not work on arm.
- nodpc := Nod(OXXX, nil, nil)
-
- *nodpc = *nodfp
+ nodpc := *nodfp
nodpc.Type = Types[TUINTPTR]
nodpc.Xoffset = int64(-Widthptr)
- nd := mkcall("racefuncenter", nil, nil, nodpc)
+ nd := mkcall("racefuncenter", nil, nil, &nodpc)
fn.Func.Enter.Set(append([]*Node{nd}, fn.Func.Enter.Slice()...))
nd = mkcall("racefuncexit", nil, nil)
fn.Func.Exit.Append(nd)
return nil
}
- var m *Node
switch n.Op {
default:
- m = Nod(OXXX, nil, nil)
- *m = *n
- m.Orig = m
+ m := *n
+ m.Orig = &m
m.Left = treecopy(n.Left, lineno)
m.Right = treecopy(n.Right, lineno)
m.List.Set(listtreecopy(n.List.Slice(), lineno))
Dump("treecopy", n)
Fatalf("treecopy Name")
}
+ return &m
case ONONAME:
if n.Sym == Lookup("iota") {
// but make a copy of the Node* just in case,
// so that all the copies of this const definition
// don't have the same iota value.
- m = Nod(OXXX, nil, nil)
- *m = *n
+ m := *n
if lineno != 0 {
m.Lineno = lineno
}
m.Name = new(Name)
*m.Name = *n.Name
m.Name.Iota = iota_
- break
+ return &m
}
- fallthrough
+ return n
case ONAME, OLITERAL, OTYPE:
- m = n
+ return n
}
-
- return m
}
// isnil reports whether n represents the universal untyped zero value "nil".
// The result of substArgTypes MUST be assigned back to old, e.g.
// n.Left = substArgTypes(n.Left, t1, t2)
func substArgTypes(old *Node, types ...*Type) *Node {
- n := Nod(OXXX, nil, nil)
- *n = *old // make shallow copy
+ n := *old // make shallow copy
for _, t := range types {
dowidth(t)
if len(types) > 0 {
Fatalf("substArgTypes: too many argument types")
}
- return n
+ return &n
}
// substAny walks t, replacing instances of "any" with successive