"cmd/internal/src"
)
-// Orig returns n.
-//
-// TODO(mdempsky): Remove.
-func Orig(n Node) Node {
- return n
-}
-
-// SepCopy returns a shallow copy of n.
-//
-// TODO(mdempsky): Replace with Copy.
-func SepCopy(n Node) Node {
- return n.copy()
-}
-
// Copy returns a shallow copy of n.
func Copy(n Node) Node {
return n.copy()
return
}
- // We always want the original, if any.
- if o := Orig(n); o != n {
- n = o
- continue
- }
-
// Skip implicit operations introduced during typechecking.
switch nn := n; nn.Op() {
case OADDR:
// IsNil reports whether n represents the universal untyped zero value "nil".
func IsNil(n Node) bool {
- // Check n.Orig because constant propagation may produce typed nil constants,
- // which don't exist in the Go spec.
- return n != nil && Orig(n).Op() == ONIL
+ return n != nil && n.Op() == ONIL
}
func IsBlank(n Node) bool {
func wrapName(pos src.XPos, x ir.Node) ir.Node {
// These nodes do not carry line numbers.
// Introduce a wrapper node to give them the correct line.
- switch ir.Orig(x).Op() {
+ switch x.Op() {
case ir.OTYPE, ir.OLITERAL:
if x.Sym() == nil {
break
case *ir.Name:
if n.Class == ir.PPARAM || (n.Class == ir.PPARAMOUT && !n.IsOutputParamInRegisters()) {
a.Name = obj.NAME_PARAM
- a.Sym = ir.Orig(n).(*ir.Name).Linksym()
- a.Offset += n.FrameOffset()
- break
- }
- a.Name = obj.NAME_AUTO
- if n.Class == ir.PPARAMOUT {
- a.Sym = ir.Orig(n).(*ir.Name).Linksym()
} else {
- a.Sym = n.Linksym()
+ a.Name = obj.NAME_AUTO
}
+ a.Sym = n.Linksym()
a.Offset += n.FrameOffset()
default:
v.Fatalf("aux in %s not implemented %#v", v, v.Aux)
default:
n.SetOp(ir.OCALLFUNC)
if t.Kind() != types.TFUNC {
- if o := ir.Orig(l); o.Name() != nil && types.BuiltinPkg.Lookup(o.Sym().Name).Def != nil {
+ if o := l; o.Name() != nil && types.BuiltinPkg.Lookup(o.Sym().Name).Def != nil {
// be more specific when the non-function
// name matches a predeclared function
base.Errorf("cannot call non-function %L, declared at %s",
if l == n.X {
return n
}
- a := ir.SepCopy(n).(*ir.UnaryExpr)
+ a := ir.Copy(n).(*ir.UnaryExpr)
a.X = l
return typecheck.Expr(a)
}
if l == n.X {
return n
}
- a := ir.SepCopy(n).(*ir.UnaryExpr)
+ a := ir.Copy(n).(*ir.UnaryExpr)
a.X = l
return typecheck.Expr(a)
if l == n.X {
return n
}
- a := ir.SepCopy(n).(*ir.SelectorExpr)
+ a := ir.Copy(n).(*ir.SelectorExpr)
a.X = l
return typecheck.Expr(a)
if l == n.X {
return n
}
- a := ir.SepCopy(n).(*ir.SelectorExpr)
+ a := ir.Copy(n).(*ir.SelectorExpr)
a.X = l
return typecheck.Expr(a)
if l == n.X {
return n
}
- a := ir.SepCopy(n).(*ir.StarExpr)
+ a := ir.Copy(n).(*ir.StarExpr)
a.X = l
return typecheck.Expr(a)
if l == n.X && r == n.Index {
return n
}
- a := ir.SepCopy(n).(*ir.IndexExpr)
+ a := ir.Copy(n).(*ir.IndexExpr)
a.X = l
a.Index = r
return typecheck.Expr(a)