diff --git a/src/cmd/compile/internal/ir/expr.go b/src/cmd/compile/internal/ir/expr.go index 8ea31c1929..36a11dad9a 100644 --- a/src/cmd/compile/internal/ir/expr.go +++ b/src/cmd/compile/internal/ir/expr.go @@ -52,10 +52,10 @@ type miniExpr struct { const ( miniExprHasCall = 1 << iota - miniExprImplicit miniExprNonNil miniExprTransient miniExprBounded + miniExprImplicit // for use by implementations; not supported by every Expr ) func (*miniExpr) isExpr() {} @@ -66,8 +66,6 @@ func (n *miniExpr) Opt() interface{} { return n.opt } func (n *miniExpr) SetOpt(x interface{}) { n.opt = x } func (n *miniExpr) HasCall() bool { return n.flags&miniExprHasCall != 0 } func (n *miniExpr) SetHasCall(b bool) { n.flags.set(miniExprHasCall, b) } -func (n *miniExpr) Implicit() bool { return n.flags&miniExprImplicit != 0 } -func (n *miniExpr) SetImplicit(b bool) { n.flags.set(miniExprImplicit, b) } func (n *miniExpr) NonNil() bool { return n.flags&miniExprNonNil != 0 } func (n *miniExpr) MarkNonNil() { n.flags |= miniExprNonNil } func (n *miniExpr) Transient() bool { return n.flags&miniExprTransient != 0 } @@ -121,10 +119,12 @@ func NewAddrExpr(pos src.XPos, x Node) *AddrExpr { return n } -func (n *AddrExpr) Left() Node { return n.X } -func (n *AddrExpr) SetLeft(x Node) { n.X = x } -func (n *AddrExpr) Right() Node { return n.Alloc } -func (n *AddrExpr) SetRight(x Node) { n.Alloc = x } +func (n *AddrExpr) Left() Node { return n.X } +func (n *AddrExpr) SetLeft(x Node) { n.X = x } +func (n *AddrExpr) Right() Node { return n.Alloc } +func (n *AddrExpr) SetRight(x Node) { n.Alloc = x } +func (n *AddrExpr) Implicit() bool { return n.flags&miniExprImplicit != 0 } +func (n *AddrExpr) SetImplicit(b bool) { n.flags.set(miniExprImplicit, b) } func (n *AddrExpr) SetOp(op Op) { switch op { @@ -301,13 +301,15 @@ func NewCompLitExpr(pos src.XPos, op Op, typ Ntype, list []Node) *CompLitExpr { return n } -func (n *CompLitExpr) Orig() Node { return n.orig } -func (n *CompLitExpr) SetOrig(x Node) { n.orig = x } -func (n *CompLitExpr) Right() Node { return n.Ntype } -func (n *CompLitExpr) SetRight(x Node) { n.Ntype = toNtype(x) } -func (n *CompLitExpr) List() Nodes { return n.List_ } -func (n *CompLitExpr) PtrList() *Nodes { return &n.List_ } -func (n *CompLitExpr) SetList(x Nodes) { n.List_ = x } +func (n *CompLitExpr) Orig() Node { return n.orig } +func (n *CompLitExpr) SetOrig(x Node) { n.orig = x } +func (n *CompLitExpr) Right() Node { return n.Ntype } +func (n *CompLitExpr) SetRight(x Node) { n.Ntype = toNtype(x) } +func (n *CompLitExpr) List() Nodes { return n.List_ } +func (n *CompLitExpr) PtrList() *Nodes { return &n.List_ } +func (n *CompLitExpr) SetList(x Nodes) { n.List_ = x } +func (n *CompLitExpr) Implicit() bool { return n.flags&miniExprImplicit != 0 } +func (n *CompLitExpr) SetImplicit(b bool) { n.flags.set(miniExprImplicit, b) } func (n *CompLitExpr) SetOp(op Op) { switch op { @@ -354,8 +356,10 @@ func NewConvExpr(pos src.XPos, op Op, typ *types.Type, x Node) *ConvExpr { return n } -func (n *ConvExpr) Left() Node { return n.X } -func (n *ConvExpr) SetLeft(x Node) { n.X = x } +func (n *ConvExpr) Left() Node { return n.X } +func (n *ConvExpr) SetLeft(x Node) { n.X = x } +func (n *ConvExpr) Implicit() bool { return n.flags&miniExprImplicit != 0 } +func (n *ConvExpr) SetImplicit(b bool) { n.flags.set(miniExprImplicit, b) } func (n *ConvExpr) SetOp(op Op) { switch op { @@ -583,8 +587,10 @@ func NewParenExpr(pos src.XPos, x Node) *ParenExpr { return n } -func (n *ParenExpr) Left() Node { return n.X } -func (n *ParenExpr) SetLeft(x Node) { n.X = x } +func (n *ParenExpr) Left() Node { return n.X } +func (n *ParenExpr) SetLeft(x Node) { n.X = x } +func (n *ParenExpr) Implicit() bool { return n.flags&miniExprImplicit != 0 } +func (n *ParenExpr) SetImplicit(b bool) { n.flags.set(miniExprImplicit, b) } func (*ParenExpr) CanBeNtype() {} @@ -645,6 +651,8 @@ func (n *SelectorExpr) Sym() *types.Sym { return n.Sel } func (n *SelectorExpr) SetSym(x *types.Sym) { n.Sel = x } func (n *SelectorExpr) Offset() int64 { return n.Offset_ } func (n *SelectorExpr) SetOffset(x int64) { n.Offset_ = x } +func (n *SelectorExpr) Implicit() bool { return n.flags&miniExprImplicit != 0 } +func (n *SelectorExpr) SetImplicit(b bool) { n.flags.set(miniExprImplicit, b) } // Before type-checking, bytes.Buffer is a SelectorExpr. // After type-checking it becomes a Name. @@ -783,8 +791,10 @@ func NewStarExpr(pos src.XPos, x Node) *StarExpr { return n } -func (n *StarExpr) Left() Node { return n.X } -func (n *StarExpr) SetLeft(x Node) { n.X = x } +func (n *StarExpr) Left() Node { return n.X } +func (n *StarExpr) SetLeft(x Node) { n.X = x } +func (n *StarExpr) Implicit() bool { return n.flags&miniExprImplicit != 0 } +func (n *StarExpr) SetImplicit(b bool) { n.flags.set(miniExprImplicit, b) } func (*StarExpr) CanBeNtype() {}