mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: merge Node.Opt and Node.Val behind access methods
$ sizeof -p cmd/compile/internal/gc Node Node 144 $ Change-Id: I688e3790964fe42f48c19f697ec38094a92fe1c1 Reviewed-on: https://go-review.googlesource.com/10531 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
a53710ffcb
commit
81d5810be9
23 changed files with 345 additions and 300 deletions
|
|
@ -441,7 +441,7 @@ func staticassign(l *Node, r *Node, out **NodeList) bool {
|
|||
|
||||
case OSTRARRAYBYTE:
|
||||
if l.Class == PEXTERN && r.Left.Op == OLITERAL {
|
||||
sval := r.Left.Val.U.(string)
|
||||
sval := r.Left.Val().U.(string)
|
||||
slicebytes(l, sval, len(sval))
|
||||
return true
|
||||
}
|
||||
|
|
@ -453,7 +453,7 @@ func staticassign(l *Node, r *Node, out **NodeList) bool {
|
|||
ta := typ(TARRAY)
|
||||
|
||||
ta.Type = r.Type.Type
|
||||
ta.Bound = Mpgetfix(r.Right.Val.U.(*Mpint))
|
||||
ta.Bound = Mpgetfix(r.Right.Val().U.(*Mpint))
|
||||
a := staticname(ta, 1)
|
||||
inittemps[r] = a
|
||||
n1 = *l
|
||||
|
|
@ -522,7 +522,7 @@ func staticname(t *Type, ctxt int) *Node {
|
|||
|
||||
func isliteral(n *Node) bool {
|
||||
if n.Op == OLITERAL {
|
||||
if n.Val.Ctype() != CTNIL {
|
||||
if n.Val().Ctype() != CTNIL {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
@ -726,7 +726,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init **NodeList) {
|
|||
// make an array type
|
||||
t := shallow(n.Type)
|
||||
|
||||
t.Bound = Mpgetfix(n.Right.Val.U.(*Mpint))
|
||||
t.Bound = Mpgetfix(n.Right.Val().U.(*Mpint))
|
||||
t.Width = 0
|
||||
t.Sym = nil
|
||||
t.Haspointers = 0
|
||||
|
|
@ -1231,7 +1231,7 @@ func oaslit(n *Node, init **NodeList) bool {
|
|||
|
||||
func getlit(lit *Node) int {
|
||||
if Smallintconst(lit) {
|
||||
return int(Mpgetfix(lit.Val.U.(*Mpint)))
|
||||
return int(Mpgetfix(lit.Val().U.(*Mpint)))
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
|
@ -1295,7 +1295,7 @@ func initplan(n *Node) {
|
|||
if a.Op != OKEY || !Smallintconst(a.Left) {
|
||||
Fatal("initplan arraylit")
|
||||
}
|
||||
addvalue(p, n.Type.Type.Width*Mpgetfix(a.Left.Val.U.(*Mpint)), nil, a.Right)
|
||||
addvalue(p, n.Type.Type.Width*Mpgetfix(a.Left.Val().U.(*Mpint)), nil, a.Right)
|
||||
}
|
||||
|
||||
case OSTRUCTLIT:
|
||||
|
|
@ -1356,7 +1356,7 @@ func addvalue(p *InitPlan, xoffset int64, key *Node, n *Node) {
|
|||
func iszero(n *Node) bool {
|
||||
switch n.Op {
|
||||
case OLITERAL:
|
||||
switch n.Val.Ctype() {
|
||||
switch n.Val().Ctype() {
|
||||
default:
|
||||
Dump("unexpected literal", n)
|
||||
Fatal("iszero")
|
||||
|
|
@ -1365,19 +1365,19 @@ func iszero(n *Node) bool {
|
|||
return true
|
||||
|
||||
case CTSTR:
|
||||
return n.Val.U.(string) == ""
|
||||
return n.Val().U.(string) == ""
|
||||
|
||||
case CTBOOL:
|
||||
return !n.Val.U.(bool)
|
||||
return !n.Val().U.(bool)
|
||||
|
||||
case CTINT, CTRUNE:
|
||||
return mpcmpfixc(n.Val.U.(*Mpint), 0) == 0
|
||||
return mpcmpfixc(n.Val().U.(*Mpint), 0) == 0
|
||||
|
||||
case CTFLT:
|
||||
return mpcmpfltc(n.Val.U.(*Mpflt), 0) == 0
|
||||
return mpcmpfltc(n.Val().U.(*Mpflt), 0) == 0
|
||||
|
||||
case CTCPLX:
|
||||
return mpcmpfltc(&n.Val.U.(*Mpcplx).Real, 0) == 0 && mpcmpfltc(&n.Val.U.(*Mpcplx).Imag, 0) == 0
|
||||
return mpcmpfltc(&n.Val().U.(*Mpcplx).Real, 0) == 0 && mpcmpfltc(&n.Val().U.(*Mpcplx).Imag, 0) == 0
|
||||
}
|
||||
|
||||
case OARRAYLIT:
|
||||
|
|
@ -1515,10 +1515,10 @@ func gen_as_init(n *Node) bool {
|
|||
gdata(&nam, nr, int(nr.Type.Width))
|
||||
|
||||
case TCOMPLEX64, TCOMPLEX128:
|
||||
gdatacomplex(&nam, nr.Val.U.(*Mpcplx))
|
||||
gdatacomplex(&nam, nr.Val().U.(*Mpcplx))
|
||||
|
||||
case TSTRING:
|
||||
gdatastring(&nam, nr.Val.U.(string))
|
||||
gdatastring(&nam, nr.Val().U.(string))
|
||||
}
|
||||
|
||||
return true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue