Commit 81d5810b authored by Russ Cox's avatar Russ Cox

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/10531Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent a53710ff
...@@ -542,7 +542,7 @@ func cgen_wb(n, res *Node, wb bool) { ...@@ -542,7 +542,7 @@ func cgen_wb(n, res *Node, wb bool) {
var n1 Node var n1 Node
Regalloc(&n1, Types[Tptr], res) Regalloc(&n1, Types[Tptr], res)
p1 := Thearch.Gins(Thearch.Optoas(OAS, n1.Type), nil, &n1) p1 := Thearch.Gins(Thearch.Optoas(OAS, n1.Type), nil, &n1)
Datastring(nl.Val.U.(string), &p1.From) Datastring(nl.Val().U.(string), &p1.From)
p1.From.Type = obj.TYPE_ADDR p1.From.Type = obj.TYPE_ADDR
Thearch.Gmove(&n1, res) Thearch.Gmove(&n1, res)
Regfree(&n1) Regfree(&n1)
...@@ -1036,7 +1036,7 @@ func Agenr(n *Node, a *Node, res *Node) { ...@@ -1036,7 +1036,7 @@ func Agenr(n *Node, a *Node, res *Node) {
if Isconst(nl, CTSTR) { if Isconst(nl, CTSTR) {
Fatal("constant string constant index") Fatal("constant string constant index")
} }
v := uint64(Mpgetfix(nr.Val.U.(*Mpint))) v := uint64(Mpgetfix(nr.Val().U.(*Mpint)))
var n2 Node var n2 Node
if Isslice(nl.Type) || nl.Type.Etype == TSTRING { if Isslice(nl.Type) || nl.Type.Etype == TSTRING {
if Debug['B'] == 0 && !n.Bounded { if Debug['B'] == 0 && !n.Bounded {
...@@ -1072,7 +1072,7 @@ func Agenr(n *Node, a *Node, res *Node) { ...@@ -1072,7 +1072,7 @@ func Agenr(n *Node, a *Node, res *Node) {
if Debug['B'] == 0 && !n.Bounded { if Debug['B'] == 0 && !n.Bounded {
// check bounds // check bounds
if Isconst(nl, CTSTR) { if Isconst(nl, CTSTR) {
Nodconst(&n4, Types[TUINT32], int64(len(nl.Val.U.(string)))) Nodconst(&n4, Types[TUINT32], int64(len(nl.Val().U.(string))))
} else if Isslice(nl.Type) || nl.Type.Etype == TSTRING { } else if Isslice(nl.Type) || nl.Type.Etype == TSTRING {
n1 = n3 n1 = n3
n1.Op = OINDREG n1.Op = OINDREG
...@@ -1097,7 +1097,7 @@ func Agenr(n *Node, a *Node, res *Node) { ...@@ -1097,7 +1097,7 @@ func Agenr(n *Node, a *Node, res *Node) {
if Isconst(nl, CTSTR) { if Isconst(nl, CTSTR) {
Regalloc(&n3, Types[Tptr], res) Regalloc(&n3, Types[Tptr], res)
p1 := Thearch.Gins(Thearch.Optoas(OAS, Types[Tptr]), nil, &n3) p1 := Thearch.Gins(Thearch.Optoas(OAS, Types[Tptr]), nil, &n3)
Datastring(nl.Val.U.(string), &p1.From) Datastring(nl.Val().U.(string), &p1.From)
p1.From.Type = obj.TYPE_ADDR p1.From.Type = obj.TYPE_ADDR
} else if Isslice(nl.Type) || nl.Type.Etype == TSTRING { } else if Isslice(nl.Type) || nl.Type.Etype == TSTRING {
n1 = n3 n1 = n3
...@@ -1188,7 +1188,7 @@ func Agenr(n *Node, a *Node, res *Node) { ...@@ -1188,7 +1188,7 @@ func Agenr(n *Node, a *Node, res *Node) {
if Isconst(nl, CTSTR) { if Isconst(nl, CTSTR) {
Fatal("constant string constant index") // front end should handle Fatal("constant string constant index") // front end should handle
} }
v := uint64(Mpgetfix(nr.Val.U.(*Mpint))) v := uint64(Mpgetfix(nr.Val().U.(*Mpint)))
if Isslice(nl.Type) || nl.Type.Etype == TSTRING { if Isslice(nl.Type) || nl.Type.Etype == TSTRING {
if Debug['B'] == 0 && !n.Bounded { if Debug['B'] == 0 && !n.Bounded {
nlen := n3 nlen := n3
...@@ -1233,7 +1233,7 @@ func Agenr(n *Node, a *Node, res *Node) { ...@@ -1233,7 +1233,7 @@ func Agenr(n *Node, a *Node, res *Node) {
var nlen Node var nlen Node
if Isconst(nl, CTSTR) { if Isconst(nl, CTSTR) {
Nodconst(&nlen, t, int64(len(nl.Val.U.(string)))) Nodconst(&nlen, t, int64(len(nl.Val().U.(string))))
} else if Isslice(nl.Type) || nl.Type.Etype == TSTRING { } else if Isslice(nl.Type) || nl.Type.Etype == TSTRING {
nlen = n3 nlen = n3
nlen.Type = t nlen.Type = t
...@@ -1253,7 +1253,7 @@ func Agenr(n *Node, a *Node, res *Node) { ...@@ -1253,7 +1253,7 @@ func Agenr(n *Node, a *Node, res *Node) {
if Isconst(nl, CTSTR) { if Isconst(nl, CTSTR) {
Regalloc(&n3, Types[Tptr], res) Regalloc(&n3, Types[Tptr], res)
p1 := Thearch.Gins(Thearch.Optoas(OAS, Types[Tptr]), nil, &n3) p1 := Thearch.Gins(Thearch.Optoas(OAS, Types[Tptr]), nil, &n3)
Datastring(nl.Val.U.(string), &p1.From) Datastring(nl.Val().U.(string), &p1.From)
p1.From.Type = obj.TYPE_ADDR p1.From.Type = obj.TYPE_ADDR
Thearch.Gins(Thearch.Optoas(OADD, n3.Type), &n2, &n3) Thearch.Gins(Thearch.Optoas(OADD, n3.Type), &n2, &n3)
goto indexdone1 goto indexdone1
...@@ -1378,7 +1378,7 @@ func Agenr(n *Node, a *Node, res *Node) { ...@@ -1378,7 +1378,7 @@ func Agenr(n *Node, a *Node, res *Node) {
if Isconst(nl, CTSTR) { if Isconst(nl, CTSTR) {
Fatal("constant string constant index") // front end should handle Fatal("constant string constant index") // front end should handle
} }
v := uint64(Mpgetfix(nr.Val.U.(*Mpint))) v := uint64(Mpgetfix(nr.Val().U.(*Mpint)))
if Isslice(nl.Type) || nl.Type.Etype == TSTRING { if Isslice(nl.Type) || nl.Type.Etype == TSTRING {
if Debug['B'] == 0 && !n.Bounded { if Debug['B'] == 0 && !n.Bounded {
p1 := Thearch.Ginscmp(OGT, Types[Simtype[TUINT]], &nlen, Nodintconst(int64(v)), +1) p1 := Thearch.Ginscmp(OGT, Types[Simtype[TUINT]], &nlen, Nodintconst(int64(v)), +1)
...@@ -1416,7 +1416,7 @@ func Agenr(n *Node, a *Node, res *Node) { ...@@ -1416,7 +1416,7 @@ func Agenr(n *Node, a *Node, res *Node) {
t = Types[TUINT64] t = Types[TUINT64]
} }
if Isconst(nl, CTSTR) { if Isconst(nl, CTSTR) {
Nodconst(&nlen, t, int64(len(nl.Val.U.(string)))) Nodconst(&nlen, t, int64(len(nl.Val().U.(string))))
} else if Isslice(nl.Type) || nl.Type.Etype == TSTRING { } else if Isslice(nl.Type) || nl.Type.Etype == TSTRING {
// nlen already initialized // nlen already initialized
} else { } else {
...@@ -1431,7 +1431,7 @@ func Agenr(n *Node, a *Node, res *Node) { ...@@ -1431,7 +1431,7 @@ func Agenr(n *Node, a *Node, res *Node) {
if Isconst(nl, CTSTR) { if Isconst(nl, CTSTR) {
Regalloc(&n3, Types[Tptr], res) Regalloc(&n3, Types[Tptr], res)
p1 := Thearch.Gins(Thearch.Optoas(OAS, n3.Type), nil, &n3) // XXX was LEAQ! p1 := Thearch.Gins(Thearch.Optoas(OAS, n3.Type), nil, &n3) // XXX was LEAQ!
Datastring(nl.Val.U.(string), &p1.From) Datastring(nl.Val().U.(string), &p1.From)
p1.From.Type = obj.TYPE_ADDR p1.From.Type = obj.TYPE_ADDR
Thearch.Gins(Thearch.Optoas(OADD, n3.Type), &n2, &n3) Thearch.Gins(Thearch.Optoas(OADD, n3.Type), &n2, &n3)
goto indexdone goto indexdone
...@@ -1718,7 +1718,7 @@ func Igen(n *Node, a *Node, res *Node) { ...@@ -1718,7 +1718,7 @@ func Igen(n *Node, a *Node, res *Node) {
// Compute &a[i] as &a + i*width. // Compute &a[i] as &a + i*width.
a.Type = n.Type a.Type = n.Type
a.Xoffset += Mpgetfix(n.Right.Val.U.(*Mpint)) * n.Type.Width a.Xoffset += Mpgetfix(n.Right.Val().U.(*Mpint)) * n.Type.Width
Fixlargeoffset(a) Fixlargeoffset(a)
return return
} }
...@@ -1868,11 +1868,11 @@ func bgenx(n, res *Node, wantTrue bool, likely int, to *obj.Prog) { ...@@ -1868,11 +1868,11 @@ func bgenx(n, res *Node, wantTrue bool, likely int, to *obj.Prog) {
Fatal("bgen: non-bool const %v\n", Nconv(n, obj.FmtLong)) Fatal("bgen: non-bool const %v\n", Nconv(n, obj.FmtLong))
} }
if genval { if genval {
Cgen(Nodbool(wantTrue == n.Val.U.(bool)), res) Cgen(Nodbool(wantTrue == n.Val().U.(bool)), res)
return return
} }
// If n == wantTrue, jump; otherwise do nothing. // If n == wantTrue, jump; otherwise do nothing.
if wantTrue == n.Val.U.(bool) { if wantTrue == n.Val().U.(bool) {
Patch(Gbranch(obj.AJMP, nil, likely), to) Patch(Gbranch(obj.AJMP, nil, likely), to)
} }
return return
...@@ -2206,7 +2206,7 @@ func stkof(n *Node) int64 { ...@@ -2206,7 +2206,7 @@ func stkof(n *Node) int64 {
return off return off
} }
if Isconst(n.Right, CTINT) { if Isconst(n.Right, CTINT) {
return off + t.Type.Width*Mpgetfix(n.Right.Val.U.(*Mpint)) return off + t.Type.Width*Mpgetfix(n.Right.Val().U.(*Mpint))
} }
return +1000 // on stack but not sure exactly where return +1000 // on stack but not sure exactly where
...@@ -2661,7 +2661,7 @@ func cgen_div(op int, nl *Node, nr *Node, res *Node) { ...@@ -2661,7 +2661,7 @@ func cgen_div(op int, nl *Node, nr *Node, res *Node) {
case TUINT64: case TUINT64:
var m Magic var m Magic
m.W = w m.W = w
m.Ud = uint64(Mpgetfix(nr.Val.U.(*Mpint))) m.Ud = uint64(Mpgetfix(nr.Val().U.(*Mpint)))
Umagic(&m) Umagic(&m)
if m.Bad != 0 { if m.Bad != 0 {
break break
...@@ -2699,7 +2699,7 @@ func cgen_div(op int, nl *Node, nr *Node, res *Node) { ...@@ -2699,7 +2699,7 @@ func cgen_div(op int, nl *Node, nr *Node, res *Node) {
case TINT64: case TINT64:
var m Magic var m Magic
m.W = w m.W = w
m.Sd = Mpgetfix(nr.Val.U.(*Mpint)) m.Sd = Mpgetfix(nr.Val().U.(*Mpint))
Smagic(&m) Smagic(&m)
if m.Bad != 0 { if m.Bad != 0 {
break break
...@@ -3048,7 +3048,7 @@ func cgen_slice(n, res *Node, wb bool) { ...@@ -3048,7 +3048,7 @@ func cgen_slice(n, res *Node, wb bool) {
return return
} }
if n.Op == OSLICESTR && Isconst(n.Left, CTSTR) { if n.Op == OSLICESTR && Isconst(n.Left, CTSTR) {
Nodconst(&xlen, indexRegType, int64(len(n.Left.Val.U.(string)))) Nodconst(&xlen, indexRegType, int64(len(n.Left.Val().U.(string))))
return return
} }
regalloc(&xlen, indexRegType, nil) regalloc(&xlen, indexRegType, nil)
...@@ -3204,20 +3204,20 @@ func cgen_slice(n, res *Node, wb bool) { ...@@ -3204,20 +3204,20 @@ func cgen_slice(n, res *Node, wb bool) {
if n.Op == OSLICEARR || n.Op == OSLICE3ARR { if n.Op == OSLICEARR || n.Op == OSLICE3ARR {
bound = n.Left.Type.Type.Bound bound = n.Left.Type.Type.Bound
} else if n.Op == OSLICESTR && Isconst(n.Left, CTSTR) { } else if n.Op == OSLICESTR && Isconst(n.Left, CTSTR) {
bound = int64(len(n.Left.Val.U.(string))) bound = int64(len(n.Left.Val().U.(string)))
} }
if Isconst(&i, CTINT) { if Isconst(&i, CTINT) {
if mpcmpfixc(i.Val.U.(*Mpint), 0) < 0 || bound >= 0 && mpcmpfixc(i.Val.U.(*Mpint), bound) > 0 { if mpcmpfixc(i.Val().U.(*Mpint), 0) < 0 || bound >= 0 && mpcmpfixc(i.Val().U.(*Mpint), bound) > 0 {
Yyerror("slice index out of bounds") Yyerror("slice index out of bounds")
} }
} }
if Isconst(&j, CTINT) { if Isconst(&j, CTINT) {
if mpcmpfixc(j.Val.U.(*Mpint), 0) < 0 || bound >= 0 && mpcmpfixc(j.Val.U.(*Mpint), bound) > 0 { if mpcmpfixc(j.Val().U.(*Mpint), 0) < 0 || bound >= 0 && mpcmpfixc(j.Val().U.(*Mpint), bound) > 0 {
Yyerror("slice index out of bounds") Yyerror("slice index out of bounds")
} }
} }
if Isconst(&k, CTINT) { if Isconst(&k, CTINT) {
if mpcmpfixc(k.Val.U.(*Mpint), 0) < 0 || bound >= 0 && mpcmpfixc(k.Val.U.(*Mpint), bound) > 0 { if mpcmpfixc(k.Val().U.(*Mpint), 0) < 0 || bound >= 0 && mpcmpfixc(k.Val().U.(*Mpint), bound) > 0 {
Yyerror("slice index out of bounds") Yyerror("slice index out of bounds")
} }
} }
...@@ -3226,7 +3226,7 @@ func cgen_slice(n, res *Node, wb bool) { ...@@ -3226,7 +3226,7 @@ func cgen_slice(n, res *Node, wb bool) {
same := func(n1, n2 *Node) bool { same := func(n1, n2 *Node) bool {
return n1.Op == OREGISTER && n2.Op == OREGISTER && n1.Reg == n2.Reg || return n1.Op == OREGISTER && n2.Op == OREGISTER && n1.Reg == n2.Reg ||
n1.Op == ONAME && n2.Op == ONAME && n1.Orig == n2.Orig && n1.Type == n2.Type && n1.Xoffset == n2.Xoffset || n1.Op == ONAME && n2.Op == ONAME && n1.Orig == n2.Orig && n1.Type == n2.Type && n1.Xoffset == n2.Xoffset ||
n1.Op == OLITERAL && n2.Op == OLITERAL && Mpcmpfixfix(n1.Val.U.(*Mpint), n2.Val.U.(*Mpint)) == 0 n1.Op == OLITERAL && n2.Op == OLITERAL && Mpcmpfixfix(n1.Val().U.(*Mpint), n2.Val().U.(*Mpint)) == 0
} }
// obvious reports whether n1 <= n2 is obviously true, // obvious reports whether n1 <= n2 is obviously true,
...@@ -3245,7 +3245,7 @@ func cgen_slice(n, res *Node, wb bool) { ...@@ -3245,7 +3245,7 @@ func cgen_slice(n, res *Node, wb bool) {
return true // len(x) <= cap(x) always true return true // len(x) <= cap(x) always true
} }
if Isconst(n1, CTINT) && Isconst(n2, CTINT) { if Isconst(n1, CTINT) && Isconst(n2, CTINT) {
if Mpcmpfixfix(n1.Val.U.(*Mpint), n2.Val.U.(*Mpint)) <= 0 { if Mpcmpfixfix(n1.Val().U.(*Mpint), n2.Val().U.(*Mpint)) <= 0 {
return true // n1, n2 constants such that n1 <= n2 return true // n1, n2 constants such that n1 <= n2
} }
Yyerror("slice index out of bounds") Yyerror("slice index out of bounds")
...@@ -3258,11 +3258,11 @@ func cgen_slice(n, res *Node, wb bool) { ...@@ -3258,11 +3258,11 @@ func cgen_slice(n, res *Node, wb bool) {
// n1 might be a 64-bit constant, even on 32-bit architectures, // n1 might be a 64-bit constant, even on 32-bit architectures,
// but it will be represented in 32 bits. // but it will be represented in 32 bits.
if Ctxt.Arch.Regsize == 4 && Is64(n1.Type) { if Ctxt.Arch.Regsize == 4 && Is64(n1.Type) {
if mpcmpfixc(n1.Val.U.(*Mpint), 1<<31) >= 0 { if mpcmpfixc(n1.Val().U.(*Mpint), 1<<31) >= 0 {
Fatal("missed slice out of bounds check") Fatal("missed slice out of bounds check")
} }
var tmp Node var tmp Node
Nodconst(&tmp, indexRegType, Mpgetfix(n1.Val.U.(*Mpint))) Nodconst(&tmp, indexRegType, Mpgetfix(n1.Val().U.(*Mpint)))
n1 = &tmp n1 = &tmp
} }
p := Thearch.Ginscmp(OGT, indexRegType, n1, n2, -1) p := Thearch.Ginscmp(OGT, indexRegType, n1, n2, -1)
...@@ -3346,9 +3346,9 @@ func cgen_slice(n, res *Node, wb bool) { ...@@ -3346,9 +3346,9 @@ func cgen_slice(n, res *Node, wb bool) {
switch j.Op { switch j.Op {
case OLITERAL: case OLITERAL:
if Isconst(&i, CTINT) { if Isconst(&i, CTINT) {
Nodconst(&j, indexRegType, Mpgetfix(j.Val.U.(*Mpint))-Mpgetfix(i.Val.U.(*Mpint))) Nodconst(&j, indexRegType, Mpgetfix(j.Val().U.(*Mpint))-Mpgetfix(i.Val().U.(*Mpint)))
if Debug_slice > 0 { if Debug_slice > 0 {
Warn("slice: result len == %d", Mpgetfix(j.Val.U.(*Mpint))) Warn("slice: result len == %d", Mpgetfix(j.Val().U.(*Mpint)))
} }
break break
} }
...@@ -3363,7 +3363,7 @@ func cgen_slice(n, res *Node, wb bool) { ...@@ -3363,7 +3363,7 @@ func cgen_slice(n, res *Node, wb bool) {
fallthrough fallthrough
case OREGISTER: case OREGISTER:
if i.Op == OLITERAL { if i.Op == OLITERAL {
v := Mpgetfix(i.Val.U.(*Mpint)) v := Mpgetfix(i.Val().U.(*Mpint))
if v != 0 { if v != 0 {
ginscon(Thearch.Optoas(OSUB, indexRegType), v, &j) ginscon(Thearch.Optoas(OSUB, indexRegType), v, &j)
} }
...@@ -3406,9 +3406,9 @@ func cgen_slice(n, res *Node, wb bool) { ...@@ -3406,9 +3406,9 @@ func cgen_slice(n, res *Node, wb bool) {
switch k.Op { switch k.Op {
case OLITERAL: case OLITERAL:
if Isconst(&i, CTINT) { if Isconst(&i, CTINT) {
Nodconst(&k, indexRegType, Mpgetfix(k.Val.U.(*Mpint))-Mpgetfix(i.Val.U.(*Mpint))) Nodconst(&k, indexRegType, Mpgetfix(k.Val().U.(*Mpint))-Mpgetfix(i.Val().U.(*Mpint)))
if Debug_slice > 0 { if Debug_slice > 0 {
Warn("slice: result cap == %d", Mpgetfix(k.Val.U.(*Mpint))) Warn("slice: result cap == %d", Mpgetfix(k.Val().U.(*Mpint)))
} }
break break
} }
...@@ -3429,7 +3429,7 @@ func cgen_slice(n, res *Node, wb bool) { ...@@ -3429,7 +3429,7 @@ func cgen_slice(n, res *Node, wb bool) {
Warn("slice: result cap == 0") Warn("slice: result cap == 0")
} }
} else if i.Op == OLITERAL { } else if i.Op == OLITERAL {
v := Mpgetfix(i.Val.U.(*Mpint)) v := Mpgetfix(i.Val().U.(*Mpint))
if v != 0 { if v != 0 {
ginscon(Thearch.Optoas(OSUB, indexRegType), v, &k) ginscon(Thearch.Optoas(OSUB, indexRegType), v, &k)
} }
...@@ -3512,7 +3512,7 @@ func cgen_slice(n, res *Node, wb bool) { ...@@ -3512,7 +3512,7 @@ func cgen_slice(n, res *Node, wb bool) {
w = res.Type.Type.Width // res is []T, elem size is T.width w = res.Type.Type.Width // res is []T, elem size is T.width
} }
if Isconst(&i, CTINT) { if Isconst(&i, CTINT) {
ginscon(Thearch.Optoas(OADD, xbase.Type), Mpgetfix(i.Val.U.(*Mpint))*w, &xbase) ginscon(Thearch.Optoas(OADD, xbase.Type), Mpgetfix(i.Val().U.(*Mpint))*w, &xbase)
} else if Thearch.AddIndex != nil && Thearch.AddIndex(&i, w, &xbase) { } else if Thearch.AddIndex != nil && Thearch.AddIndex(&i, w, &xbase) {
// done by back end // done by back end
} else if w == 1 { } else if w == 1 {
......
...@@ -16,7 +16,7 @@ func (n *Node) Int() int64 { ...@@ -16,7 +16,7 @@ func (n *Node) Int() int64 {
if !Isconst(n, CTINT) { if !Isconst(n, CTINT) {
Fatal("Int(%v)", n) Fatal("Int(%v)", n)
} }
return Mpgetfix(n.Val.U.(*Mpint)) return Mpgetfix(n.Val().U.(*Mpint))
} }
// SetInt sets n's value to i. // SetInt sets n's value to i.
...@@ -25,7 +25,7 @@ func (n *Node) SetInt(i int64) { ...@@ -25,7 +25,7 @@ func (n *Node) SetInt(i int64) {
if !Isconst(n, CTINT) { if !Isconst(n, CTINT) {
Fatal("SetInt(%v)", n) Fatal("SetInt(%v)", n)
} }
Mpmovecfix(n.Val.U.(*Mpint), i) Mpmovecfix(n.Val().U.(*Mpint), i)
} }
// SetBigInt sets n's value to x. // SetBigInt sets n's value to x.
...@@ -34,7 +34,7 @@ func (n *Node) SetBigInt(x *big.Int) { ...@@ -34,7 +34,7 @@ func (n *Node) SetBigInt(x *big.Int) {
if !Isconst(n, CTINT) { if !Isconst(n, CTINT) {
Fatal("SetBigInt(%v)", n) Fatal("SetBigInt(%v)", n)
} }
n.Val.U.(*Mpint).Val.Set(x) n.Val().U.(*Mpint).Val.Set(x)
} }
// Bool returns n as an bool. // Bool returns n as an bool.
...@@ -43,7 +43,7 @@ func (n *Node) Bool() bool { ...@@ -43,7 +43,7 @@ func (n *Node) Bool() bool {
if !Isconst(n, CTBOOL) { if !Isconst(n, CTBOOL) {
Fatal("Int(%v)", n) Fatal("Int(%v)", n)
} }
return n.Val.U.(bool) return n.Val().U.(bool)
} }
/* /*
...@@ -135,8 +135,8 @@ func convlit1(np **Node, t *Type, explicit bool) { ...@@ -135,8 +135,8 @@ func convlit1(np **Node, t *Type, explicit bool) {
case OLSH, ORSH: case OLSH, ORSH:
convlit1(&n.Left, t, explicit && isideal(n.Left.Type)) convlit1(&n.Left, t, explicit && isideal(n.Left.Type))
t = n.Left.Type t = n.Left.Type
if t != nil && t.Etype == TIDEAL && n.Val.Ctype() != CTINT { if t != nil && t.Etype == TIDEAL && n.Val().Ctype() != CTINT {
n.Val = toint(n.Val) n.SetVal(toint(n.Val()))
} }
if t != nil && !Isint[t.Etype] { if t != nil && !Isint[t.Etype] {
Yyerror("invalid operation: %v (shift of type %v)", n, t) Yyerror("invalid operation: %v (shift of type %v)", n, t)
...@@ -226,8 +226,8 @@ func convlit1(np **Node, t *Type, explicit bool) { ...@@ -226,8 +226,8 @@ func convlit1(np **Node, t *Type, explicit bool) {
// if it is an unsafe.Pointer // if it is an unsafe.Pointer
case TUINTPTR: case TUINTPTR:
if n.Type.Etype == TUNSAFEPTR { if n.Type.Etype == TUNSAFEPTR {
n.Val.U = new(Mpint) n.SetVal(Val{new(Mpint)})
Mpmovecfix(n.Val.U.(*Mpint), 0) Mpmovecfix(n.Val().U.(*Mpint), 0)
} else { } else {
goto bad goto bad
} }
...@@ -242,19 +242,19 @@ func convlit1(np **Node, t *Type, explicit bool) { ...@@ -242,19 +242,19 @@ func convlit1(np **Node, t *Type, explicit bool) {
if n.Type.Etype == TUNSAFEPTR && t.Etype != TUINTPTR { if n.Type.Etype == TUNSAFEPTR && t.Etype != TUINTPTR {
goto bad goto bad
} }
ct := int(n.Val.Ctype()) ct := int(n.Val().Ctype())
if Isint[et] { if Isint[et] {
switch ct { switch ct {
default: default:
goto bad goto bad
case CTCPLX, CTFLT, CTRUNE: case CTCPLX, CTFLT, CTRUNE:
n.Val = toint(n.Val) n.SetVal(toint(n.Val()))
fallthrough fallthrough
// flowthrough // flowthrough
case CTINT: case CTINT:
overflow(n.Val, t) overflow(n.Val(), t)
} }
} else if Isfloat[et] { } else if Isfloat[et] {
switch ct { switch ct {
...@@ -262,12 +262,12 @@ func convlit1(np **Node, t *Type, explicit bool) { ...@@ -262,12 +262,12 @@ func convlit1(np **Node, t *Type, explicit bool) {
goto bad goto bad
case CTCPLX, CTINT, CTRUNE: case CTCPLX, CTINT, CTRUNE:
n.Val = toflt(n.Val) n.SetVal(toflt(n.Val()))
fallthrough fallthrough
// flowthrough // flowthrough
case CTFLT: case CTFLT:
n.Val.U = truncfltlit(n.Val.U.(*Mpflt), t) n.SetVal(Val{truncfltlit(n.Val().U.(*Mpflt), t)})
} }
} else if Iscomplex[et] { } else if Iscomplex[et] {
switch ct { switch ct {
...@@ -275,13 +275,13 @@ func convlit1(np **Node, t *Type, explicit bool) { ...@@ -275,13 +275,13 @@ func convlit1(np **Node, t *Type, explicit bool) {
goto bad goto bad
case CTFLT, CTINT, CTRUNE: case CTFLT, CTINT, CTRUNE:
n.Val = tocplx(n.Val) n.SetVal(tocplx(n.Val()))
case CTCPLX: case CTCPLX:
overflow(n.Val, t) overflow(n.Val(), t)
} }
} else if et == TSTRING && (ct == CTINT || ct == CTRUNE) && explicit { } else if et == TSTRING && (ct == CTINT || ct == CTRUNE) && explicit {
n.Val = tostr(n.Val) n.SetVal(tostr(n.Val()))
} else { } else {
goto bad goto bad
} }
...@@ -476,7 +476,7 @@ func consttype(n *Node) int { ...@@ -476,7 +476,7 @@ func consttype(n *Node) int {
if n == nil || n.Op != OLITERAL { if n == nil || n.Op != OLITERAL {
return -1 return -1
} }
return int(n.Val.Ctype()) return int(n.Val().Ctype())
} }
func Isconst(n *Node, ct int) bool { func Isconst(n *Node, ct int) bool {
...@@ -555,14 +555,14 @@ func evconst(n *Node) { ...@@ -555,14 +555,14 @@ func evconst(n *Node) {
l2 = l1 l2 = l1
for l2 != nil && Isconst(l2.N, CTSTR) { for l2 != nil && Isconst(l2.N, CTSTR) {
nr = l2.N nr = l2.N
strs = append(strs, nr.Val.U.(string)) strs = append(strs, nr.Val().U.(string))
l2 = l2.Next l2 = l2.Next
} }
nl = Nod(OXXX, nil, nil) nl = Nod(OXXX, nil, nil)
*nl = *l1.N *nl = *l1.N
nl.Orig = nl nl.Orig = nl
nl.Val.U = strings.Join(strs, "") nl.SetVal(Val{strings.Join(strs, "")})
l1.N = nl l1.N = nl
l1.Next = l2 l1.Next = l2
} }
...@@ -576,7 +576,7 @@ func evconst(n *Node) { ...@@ -576,7 +576,7 @@ func evconst(n *Node) {
// collapse single-constant list to single constant. // collapse single-constant list to single constant.
if count(n.List) == 1 && Isconst(n.List.N, CTSTR) { if count(n.List) == 1 && Isconst(n.List.N, CTSTR) {
n.Op = OLITERAL n.Op = OLITERAL
n.Val = n.List.N.Val n.SetVal(n.List.N.Val())
} }
return return
...@@ -603,7 +603,7 @@ func evconst(n *Node) { ...@@ -603,7 +603,7 @@ func evconst(n *Node) {
if nr == nil { if nr == nil {
// copy numeric value to avoid modifying // copy numeric value to avoid modifying
// nl, in case someone still refers to it (e.g. iota). // nl, in case someone still refers to it (e.g. iota).
v = nl.Val v = nl.Val()
if wl == TIDEAL { if wl == TIDEAL {
v = copyval(v) v = copyval(v)
...@@ -634,7 +634,7 @@ func evconst(n *Node) { ...@@ -634,7 +634,7 @@ func evconst(n *Node) {
OCONV<<16 | CTSTR: OCONV<<16 | CTSTR:
convlit1(&nl, n.Type, true) convlit1(&nl, n.Type, true)
v = nl.Val v = nl.Val()
case OPLUS<<16 | CTINT, case OPLUS<<16 | CTINT,
OPLUS<<16 | CTRUNE: OPLUS<<16 | CTRUNE:
...@@ -735,21 +735,21 @@ func evconst(n *Node) { ...@@ -735,21 +735,21 @@ func evconst(n *Node) {
if nr.Type != nil && (Issigned[nr.Type.Etype] || !Isint[nr.Type.Etype]) { if nr.Type != nil && (Issigned[nr.Type.Etype] || !Isint[nr.Type.Etype]) {
goto illegal goto illegal
} }
if nl.Val.Ctype() != CTRUNE { if nl.Val().Ctype() != CTRUNE {
nl.Val = toint(nl.Val) nl.SetVal(toint(nl.Val()))
} }
nr.Val = toint(nr.Val) nr.SetVal(toint(nr.Val()))
} }
// copy numeric value to avoid modifying // copy numeric value to avoid modifying
// n->left, in case someone still refers to it (e.g. iota). // n->left, in case someone still refers to it (e.g. iota).
v = nl.Val v = nl.Val()
if wl == TIDEAL { if wl == TIDEAL {
v = copyval(v) v = copyval(v)
} }
rv = nr.Val rv = nr.Val()
// convert to common ideal // convert to common ideal
if v.Ctype() == CTCPLX || rv.Ctype() == CTCPLX { if v.Ctype() == CTCPLX || rv.Ctype() == CTCPLX {
...@@ -1066,7 +1066,7 @@ ret: ...@@ -1066,7 +1066,7 @@ ret:
// restore value of n->orig. // restore value of n->orig.
n.Orig = norig n.Orig = norig
n.Val = v n.SetVal(v)
// check range. // check range.
lno = int(setlineno(n)) lno = int(setlineno(n))
...@@ -1076,7 +1076,7 @@ ret: ...@@ -1076,7 +1076,7 @@ ret:
// truncate precision for non-ideal float. // truncate precision for non-ideal float.
if v.Ctype() == CTFLT && n.Type.Etype != TIDEAL { if v.Ctype() == CTFLT && n.Type.Etype != TIDEAL {
n.Val.U = truncfltlit(v.U.(*Mpflt), n.Type) n.SetVal(Val{truncfltlit(v.U.(*Mpflt), n.Type)})
} }
return return
...@@ -1103,7 +1103,7 @@ illegal: ...@@ -1103,7 +1103,7 @@ illegal:
func nodlit(v Val) *Node { func nodlit(v Val) *Node {
n := Nod(OLITERAL, nil, nil) n := Nod(OLITERAL, nil, nil)
n.Val = v n.SetVal(v)
switch v.Ctype() { switch v.Ctype() {
default: default:
Fatal("nodlit ctype %d", v.Ctype()) Fatal("nodlit ctype %d", v.Ctype())
...@@ -1131,7 +1131,7 @@ func nodcplxlit(r Val, i Val) *Node { ...@@ -1131,7 +1131,7 @@ func nodcplxlit(r Val, i Val) *Node {
c := new(Mpcplx) c := new(Mpcplx)
n := Nod(OLITERAL, nil, nil) n := Nod(OLITERAL, nil, nil)
n.Type = Types[TIDEAL] n.Type = Types[TIDEAL]
n.Val.U = c n.SetVal(Val{c})
if r.Ctype() != CTFLT || i.Ctype() != CTFLT { if r.Ctype() != CTFLT || i.Ctype() != CTFLT {
Fatal("nodcplxlit ctype %d/%d", r.Ctype(), i.Ctype()) Fatal("nodcplxlit ctype %d/%d", r.Ctype(), i.Ctype())
...@@ -1154,7 +1154,7 @@ func idealkind(n *Node) int { ...@@ -1154,7 +1154,7 @@ func idealkind(n *Node) int {
return CTxxx return CTxxx
case OLITERAL: case OLITERAL:
return int(n.Val.Ctype()) return int(n.Val().Ctype())
// numeric kinds. // numeric kinds.
case OADD, case OADD,
...@@ -1229,7 +1229,7 @@ func defaultlit(np **Node, t *Type) { ...@@ -1229,7 +1229,7 @@ func defaultlit(np **Node, t *Type) {
return return
} }
if n.Val.Ctype() == CTNIL { if n.Val().Ctype() == CTNIL {
lineno = int32(lno) lineno = int32(lno)
if n.Diag == 0 { if n.Diag == 0 {
Yyerror("use of untyped nil") Yyerror("use of untyped nil")
...@@ -1240,7 +1240,7 @@ func defaultlit(np **Node, t *Type) { ...@@ -1240,7 +1240,7 @@ func defaultlit(np **Node, t *Type) {
break break
} }
if n.Val.Ctype() == CTSTR { if n.Val().Ctype() == CTSTR {
t1 := Types[TSTRING] t1 := Types[TSTRING]
Convlit(np, t1) Convlit(np, t1)
break break
...@@ -1282,17 +1282,17 @@ num: ...@@ -1282,17 +1282,17 @@ num:
if t != nil { if t != nil {
if Isint[t.Etype] { if Isint[t.Etype] {
t1 = t t1 = t
n.Val = toint(n.Val) n.SetVal(toint(n.Val()))
} else if Isfloat[t.Etype] { } else if Isfloat[t.Etype] {
t1 = t t1 = t
n.Val = toflt(n.Val) n.SetVal(toflt(n.Val()))
} else if Iscomplex[t.Etype] { } else if Iscomplex[t.Etype] {
t1 = t t1 = t
n.Val = tocplx(n.Val) n.SetVal(tocplx(n.Val()))
} }
} }
overflow(n.Val, t1) overflow(n.Val(), t1)
Convlit(np, t1) Convlit(np, t1)
lineno = int32(lno) lineno = int32(lno)
return return
...@@ -1353,7 +1353,7 @@ func defaultlit2(lp **Node, rp **Node, force int) { ...@@ -1353,7 +1353,7 @@ func defaultlit2(lp **Node, rp **Node, force int) {
} }
func cmpslit(l, r *Node) int { func cmpslit(l, r *Node) int {
return stringsCompare(l.Val.U.(string), r.Val.U.(string)) return stringsCompare(l.Val().U.(string), r.Val().U.(string))
} }
func Smallintconst(n *Node) bool { func Smallintconst(n *Node) bool {
...@@ -1370,7 +1370,7 @@ func Smallintconst(n *Node) bool { ...@@ -1370,7 +1370,7 @@ func Smallintconst(n *Node) bool {
return true return true
case TIDEAL, TINT64, TUINT64, TPTR64: case TIDEAL, TINT64, TUINT64, TPTR64:
if Mpcmpfixfix(n.Val.U.(*Mpint), Minintval[TINT32]) < 0 || Mpcmpfixfix(n.Val.U.(*Mpint), Maxintval[TINT32]) > 0 { if Mpcmpfixfix(n.Val().U.(*Mpint), Minintval[TINT32]) < 0 || Mpcmpfixfix(n.Val().U.(*Mpint), Maxintval[TINT32]) > 0 {
break break
} }
return true return true
...@@ -1393,10 +1393,10 @@ func nonnegconst(n *Node) int { ...@@ -1393,10 +1393,10 @@ func nonnegconst(n *Node) int {
TINT64, TINT64,
TUINT64, TUINT64,
TIDEAL: TIDEAL:
if Mpcmpfixfix(n.Val.U.(*Mpint), Minintval[TUINT32]) < 0 || Mpcmpfixfix(n.Val.U.(*Mpint), Maxintval[TINT32]) > 0 { if Mpcmpfixfix(n.Val().U.(*Mpint), Minintval[TUINT32]) < 0 || Mpcmpfixfix(n.Val().U.(*Mpint), Maxintval[TINT32]) > 0 {
break break
} }
return int(Mpgetfix(n.Val.U.(*Mpint))) return int(Mpgetfix(n.Val().U.(*Mpint)))
} }
} }
...@@ -1443,46 +1443,46 @@ func (n *Node) Convconst(con *Node, t *Type) { ...@@ -1443,46 +1443,46 @@ func (n *Node) Convconst(con *Node, t *Type) {
Nodconst(con, Types[TINT8], 0) Nodconst(con, Types[TINT8], 0)
con.Type = t con.Type = t
con.Val = n.Val con.SetVal(n.Val())
if Isint[tt] { if Isint[tt] {
con.Val.U = new(Mpint) con.SetVal(Val{new(Mpint)})
var i int64 var i int64
switch n.Val.Ctype() { switch n.Val().Ctype() {
default: default:
Fatal("convconst ctype=%d %v", n.Val.Ctype(), Tconv(t, obj.FmtLong)) Fatal("convconst ctype=%d %v", n.Val().Ctype(), Tconv(t, obj.FmtLong))
case CTINT, CTRUNE: case CTINT, CTRUNE:
i = Mpgetfix(n.Val.U.(*Mpint)) i = Mpgetfix(n.Val().U.(*Mpint))
case CTBOOL: case CTBOOL:
i = int64(obj.Bool2int(n.Val.U.(bool))) i = int64(obj.Bool2int(n.Val().U.(bool)))
case CTNIL: case CTNIL:
i = 0 i = 0
} }
i = iconv(i, tt) i = iconv(i, tt)
Mpmovecfix(con.Val.U.(*Mpint), i) Mpmovecfix(con.Val().U.(*Mpint), i)
return return
} }
if Isfloat[tt] { if Isfloat[tt] {
con.Val = toflt(con.Val) con.SetVal(toflt(con.Val()))
if con.Val.Ctype() != CTFLT { if con.Val().Ctype() != CTFLT {
Fatal("convconst ctype=%d %v", con.Val.Ctype(), t) Fatal("convconst ctype=%d %v", con.Val().Ctype(), t)
} }
if tt == TFLOAT32 { if tt == TFLOAT32 {
con.Val.U = truncfltlit(con.Val.U.(*Mpflt), t) con.SetVal(Val{truncfltlit(con.Val().U.(*Mpflt), t)})
} }
return return
} }
if Iscomplex[tt] { if Iscomplex[tt] {
con.Val = tocplx(con.Val) con.SetVal(tocplx(con.Val()))
if tt == TCOMPLEX64 { if tt == TCOMPLEX64 {
con.Val.U.(*Mpcplx).Real = *truncfltlit(&con.Val.U.(*Mpcplx).Real, Types[TFLOAT32]) con.Val().U.(*Mpcplx).Real = *truncfltlit(&con.Val().U.(*Mpcplx).Real, Types[TFLOAT32])
con.Val.U.(*Mpcplx).Imag = *truncfltlit(&con.Val.U.(*Mpcplx).Imag, Types[TFLOAT32]) con.Val().U.(*Mpcplx).Imag = *truncfltlit(&con.Val().U.(*Mpcplx).Imag, Types[TFLOAT32])
} }
return return
} }
...@@ -1634,13 +1634,13 @@ func isgoconst(n *Node) bool { ...@@ -1634,13 +1634,13 @@ func isgoconst(n *Node) bool {
} }
case OLITERAL: case OLITERAL:
if n.Val.Ctype() != CTNIL { if n.Val().Ctype() != CTNIL {
return true return true
} }
case ONAME: case ONAME:
l := n.Sym.Def l := n.Sym.Def
if l != nil && l.Op == OLITERAL && n.Val.Ctype() != CTNIL { if l != nil && l.Op == OLITERAL && n.Val().Ctype() != CTNIL {
return true return true
} }
......
...@@ -89,8 +89,8 @@ func subnode(nr *Node, ni *Node, nc *Node) { ...@@ -89,8 +89,8 @@ func subnode(nr *Node, ni *Node, nc *Node) {
t := Types[tc] t := Types[tc]
if nc.Op == OLITERAL { if nc.Op == OLITERAL {
nodfconst(nr, t, &nc.Val.U.(*Mpcplx).Real) nodfconst(nr, t, &nc.Val().U.(*Mpcplx).Real)
nodfconst(ni, t, &nc.Val.U.(*Mpcplx).Imag) nodfconst(ni, t, &nc.Val().U.(*Mpcplx).Imag)
return return
} }
...@@ -226,7 +226,7 @@ func nodfconst(n *Node, t *Type, fval *Mpflt) { ...@@ -226,7 +226,7 @@ func nodfconst(n *Node, t *Type, fval *Mpflt) {
n.Op = OLITERAL n.Op = OLITERAL
n.Addable = true n.Addable = true
ullmancalc(n) ullmancalc(n)
n.Val.U = fval n.SetVal(Val{fval})
n.Type = t n.Type = t
if !Isfloat[t.Etype] { if !Isfloat[t.Etype] {
......
...@@ -833,10 +833,10 @@ func structfield(n *Node) *Type { ...@@ -833,10 +833,10 @@ func structfield(n *Node) *Type {
f.Broke = 1 f.Broke = 1
} }
switch n.Val.Ctype() { switch n.Val().Ctype() {
case CTSTR: case CTSTR:
f.Note = new(string) f.Note = new(string)
*f.Note = n.Val.U.(string) *f.Note = n.Val().U.(string)
default: default:
Yyerror("field annotation must be string") Yyerror("field annotation must be string")
...@@ -942,7 +942,7 @@ func interfacefield(n *Node) *Type { ...@@ -942,7 +942,7 @@ func interfacefield(n *Node) *Type {
Fatal("interfacefield: oops %v\n", n) Fatal("interfacefield: oops %v\n", n)
} }
if n.Val.Ctype() != CTxxx { if n.Val().Ctype() != CTxxx {
Yyerror("interface method cannot have annotation") Yyerror("interface method cannot have annotation")
} }
......
...@@ -319,15 +319,15 @@ type NodeEscState struct { ...@@ -319,15 +319,15 @@ type NodeEscState struct {
} }
func (e *EscState) nodeEscState(n *Node) *NodeEscState { func (e *EscState) nodeEscState(n *Node) *NodeEscState {
if nE, ok := n.Opt.(*NodeEscState); ok { if nE, ok := n.Opt().(*NodeEscState); ok {
return nE return nE
} }
if n.Opt != nil { if n.Opt() != nil {
Fatal("nodeEscState: opt in use (%T)", n.Opt) Fatal("nodeEscState: opt in use (%T)", n.Opt())
} }
nE := new(NodeEscState) nE := new(NodeEscState)
nE.Curfn = Curfn nE.Curfn = Curfn
n.Opt = nE n.SetOpt(nE)
e.opts = append(e.opts, n) e.opts = append(e.opts, n)
return nE return nE
} }
...@@ -471,7 +471,7 @@ func escAnalyze(all *NodeList, recursive bool) { ...@@ -471,7 +471,7 @@ func escAnalyze(all *NodeList, recursive bool) {
} }
} }
for _, x := range e.opts { for _, x := range e.opts {
x.Opt = nil x.SetOpt(nil)
} }
} }
...@@ -669,7 +669,7 @@ func esc(e *EscState, n *Node, up *Node) { ...@@ -669,7 +669,7 @@ func esc(e *EscState, n *Node, up *Node) {
if Isfixedarray(n.Type) { if Isfixedarray(n.Type) {
escassign(e, n.List.Next.N, n.Right) escassign(e, n.List.Next.N, n.Right)
} else { } else {
escassign(e, n.List.Next.N, e.addDereference(n.Right)) escassignDereference(e, n.List.Next.N, n.Right)
} }
} }
...@@ -802,12 +802,12 @@ func esc(e *EscState, n *Node, up *Node) { ...@@ -802,12 +802,12 @@ func esc(e *EscState, n *Node, up *Node) {
} else { } else {
// append(slice1, slice2...) -- slice2 itself does not escape, but contents do. // append(slice1, slice2...) -- slice2 itself does not escape, but contents do.
slice2 := n.List.Next.N slice2 := n.List.Next.N
escassign(e, &e.theSink, e.addDereference(slice2)) // lose track of assign of dereference escassignDereference(e, &e.theSink, slice2) // lose track of assign of dereference
if Debug['m'] > 2 { if Debug['m'] > 2 {
Warnl(int(n.Lineno), "%v special treatment of append(slice1, slice2...) %v", e.curfnSym(n), Nconv(n, obj.FmtShort)) Warnl(int(n.Lineno), "%v special treatment of append(slice1, slice2...) %v", e.curfnSym(n), Nconv(n, obj.FmtShort))
} }
} }
escassign(e, &e.theSink, e.addDereference(n.List.N)) // The original elements are now leaked, too escassignDereference(e, &e.theSink, n.List.N) // The original elements are now leaked, too
case OCONV, OCONVNOP: case OCONV, OCONVNOP:
escassign(e, n, n.Left) escassign(e, n, n.Left)
...@@ -1191,6 +1191,9 @@ func describeEscape(em uint16) string { ...@@ -1191,6 +1191,9 @@ func describeEscape(em uint16) string {
// calls arguments, where the flow is encoded in "note". // calls arguments, where the flow is encoded in "note".
func escassignfromtag(e *EscState, note *string, dsts *NodeList, src *Node) uint16 { func escassignfromtag(e *EscState, note *string, dsts *NodeList, src *Node) uint16 {
em := parsetag(note) em := parsetag(note)
if src.Op == OLITERAL {
return em
}
if Debug['m'] > 2 { if Debug['m'] > 2 {
fmt.Printf("%v::assignfromtag:: src=%v, em=%s\n", fmt.Printf("%v::assignfromtag:: src=%v, em=%s\n",
...@@ -1578,6 +1581,9 @@ func funcOutputAndInput(dst, src *Node) bool { ...@@ -1578,6 +1581,9 @@ func funcOutputAndInput(dst, src *Node) bool {
} }
func escwalk(e *EscState, level Level, dst *Node, src *Node) { func escwalk(e *EscState, level Level, dst *Node, src *Node) {
if src.Op == OLITERAL {
return
}
srcE := e.nodeEscState(src) srcE := e.nodeEscState(src)
if srcE.Walkgen == e.walkgen { if srcE.Walkgen == e.walkgen {
// Esclevels are vectors, do not compare as integers, // Esclevels are vectors, do not compare as integers,
......
...@@ -216,9 +216,9 @@ func dumpexportconst(s *Sym) { ...@@ -216,9 +216,9 @@ func dumpexportconst(s *Sym) {
dumpexporttype(t) dumpexporttype(t)
if t != nil && !isideal(t) { if t != nil && !isideal(t) {
fmt.Fprintf(bout, "\tconst %v %v = %v\n", Sconv(s, obj.FmtSharp), Tconv(t, obj.FmtSharp), Vconv(&n.Val, obj.FmtSharp)) fmt.Fprintf(bout, "\tconst %v %v = %v\n", Sconv(s, obj.FmtSharp), Tconv(t, obj.FmtSharp), Vconv(n.Val(), obj.FmtSharp))
} else { } else {
fmt.Fprintf(bout, "\tconst %v = %v\n", Sconv(s, obj.FmtSharp), Vconv(&n.Val, obj.FmtSharp)) fmt.Fprintf(bout, "\tconst %v = %v\n", Sconv(s, obj.FmtSharp), Vconv(n.Val(), obj.FmtSharp))
} }
} }
...@@ -541,7 +541,7 @@ func dumpasmhdr() { ...@@ -541,7 +541,7 @@ func dumpasmhdr() {
} }
switch n.Op { switch n.Op {
case OLITERAL: case OLITERAL:
fmt.Fprintf(b, "#define const_%s %v\n", n.Sym.Name, Vconv(&n.Val, obj.FmtSharp)) fmt.Fprintf(b, "#define const_%s %v\n", n.Sym.Name, Vconv(n.Val(), obj.FmtSharp))
case OTYPE: case OTYPE:
t = n.Type t = n.Type
......
...@@ -262,7 +262,7 @@ func Jconv(n *Node, flag int) string { ...@@ -262,7 +262,7 @@ func Jconv(n *Node, flag int) string {
fmt.Fprintf(&buf, " esc(%d)", n.Esc) fmt.Fprintf(&buf, " esc(%d)", n.Esc)
} }
if e, ok := n.Opt.(*NodeEscState); ok && e.Escloopdepth != 0 { if e, ok := n.Opt().(*NodeEscState); ok && e.Escloopdepth != 0 {
fmt.Fprintf(&buf, " ld(%d)", e.Escloopdepth) fmt.Fprintf(&buf, " ld(%d)", e.Escloopdepth)
} }
...@@ -301,7 +301,7 @@ func Jconv(n *Node, flag int) string { ...@@ -301,7 +301,7 @@ func Jconv(n *Node, flag int) string {
} }
// Fmt "%V": Values // Fmt "%V": Values
func Vconv(v *Val, flag int) string { func Vconv(v Val, flag int) string {
switch v.Ctype() { switch v.Ctype() {
case CTINT: case CTINT:
if (flag&obj.FmtSharp != 0) || fmtmode == FExp { if (flag&obj.FmtSharp != 0) || fmtmode == FExp {
...@@ -1112,20 +1112,20 @@ func exprfmt(n *Node, prec int) string { ...@@ -1112,20 +1112,20 @@ func exprfmt(n *Node, prec int) string {
return Sconv(n.Sym, 0) return Sconv(n.Sym, 0)
} }
} }
if n.Val.Ctype() == CTNIL && n.Orig != nil && n.Orig != n { if n.Val().Ctype() == CTNIL && n.Orig != nil && n.Orig != n {
return exprfmt(n.Orig, prec) return exprfmt(n.Orig, prec)
} }
if n.Type != nil && n.Type != Types[n.Type.Etype] && n.Type != idealbool && n.Type != idealstring { if n.Type != nil && n.Type != Types[n.Type.Etype] && n.Type != idealbool && n.Type != idealstring {
// Need parens when type begins with what might // Need parens when type begins with what might
// be misinterpreted as a unary operator: * or <-. // be misinterpreted as a unary operator: * or <-.
if Isptr[n.Type.Etype] || (n.Type.Etype == TCHAN && n.Type.Chan == Crecv) { if Isptr[n.Type.Etype] || (n.Type.Etype == TCHAN && n.Type.Chan == Crecv) {
return fmt.Sprintf("(%v)(%v)", n.Type, Vconv(&n.Val, 0)) return fmt.Sprintf("(%v)(%v)", n.Type, Vconv(n.Val(), 0))
} else { } else {
return fmt.Sprintf("%v(%v)", n.Type, Vconv(&n.Val, 0)) return fmt.Sprintf("%v(%v)", n.Type, Vconv(n.Val(), 0))
} }
} }
return Vconv(&n.Val, 0) return Vconv(n.Val(), 0)
// Special case: name used as local variable in export. // Special case: name used as local variable in export.
// _ becomes ~b%d internally; print as _ for export // _ becomes ~b%d internally; print as _ for export
...@@ -1516,7 +1516,7 @@ func nodedump(n *Node, flag int) string { ...@@ -1516,7 +1516,7 @@ func nodedump(n *Node, flag int) string {
fmt.Fprintf(&buf, "%v-%v%v", Oconv(int(n.Op), 0), obj.Rconv(int(n.Reg)), Jconv(n, 0)) fmt.Fprintf(&buf, "%v-%v%v", Oconv(int(n.Op), 0), obj.Rconv(int(n.Reg)), Jconv(n, 0))
case OLITERAL: case OLITERAL:
fmt.Fprintf(&buf, "%v-%v%v", Oconv(int(n.Op), 0), Vconv(&n.Val, 0), Jconv(n, 0)) fmt.Fprintf(&buf, "%v-%v%v", Oconv(int(n.Op), 0), Vconv(n.Val(), 0), Jconv(n, 0))
case ONAME, ONONAME: case ONAME, ONONAME:
if n.Sym != nil { if n.Sym != nil {
...@@ -1541,7 +1541,7 @@ func nodedump(n *Node, flag int) string { ...@@ -1541,7 +1541,7 @@ func nodedump(n *Node, flag int) string {
} }
if n.Sym != nil && n.Op != ONAME { if n.Sym != nil && n.Op != ONAME {
fmt.Fprintf(&buf, " %v G%d", n.Sym, n.Name.Vargen) fmt.Fprintf(&buf, " %v", n.Sym)
} }
if n.Type != nil { if n.Type != nil {
......
...@@ -333,20 +333,20 @@ func Clearslim(n *Node) { ...@@ -333,20 +333,20 @@ func Clearslim(n *Node) {
switch Simtype[n.Type.Etype] { switch Simtype[n.Type.Etype] {
case TCOMPLEX64, TCOMPLEX128: case TCOMPLEX64, TCOMPLEX128:
z.Val.U = new(Mpcplx) z.SetVal(Val{new(Mpcplx)})
Mpmovecflt(&z.Val.U.(*Mpcplx).Real, 0.0) Mpmovecflt(&z.Val().U.(*Mpcplx).Real, 0.0)
Mpmovecflt(&z.Val.U.(*Mpcplx).Imag, 0.0) Mpmovecflt(&z.Val().U.(*Mpcplx).Imag, 0.0)
case TFLOAT32, TFLOAT64: case TFLOAT32, TFLOAT64:
var zero Mpflt var zero Mpflt
Mpmovecflt(&zero, 0.0) Mpmovecflt(&zero, 0.0)
z.Val.U = &zero z.SetVal(Val{&zero})
case TPTR32, TPTR64, TCHAN, TMAP: case TPTR32, TPTR64, TCHAN, TMAP:
z.Val.U = new(NilVal) z.SetVal(Val{new(NilVal)})
case TBOOL: case TBOOL:
z.Val.U = false z.SetVal(Val{false})
case TINT8, case TINT8,
TINT16, TINT16,
...@@ -356,8 +356,8 @@ func Clearslim(n *Node) { ...@@ -356,8 +356,8 @@ func Clearslim(n *Node) {
TUINT16, TUINT16,
TUINT32, TUINT32,
TUINT64: TUINT64:
z.Val.U = new(Mpint) z.SetVal(Val{new(Mpint)})
Mpmovecfix(z.Val.U.(*Mpint), 0) Mpmovecfix(z.Val().U.(*Mpint), 0)
default: default:
Fatal("clearslim called on type %v", n.Type) Fatal("clearslim called on type %v", n.Type)
...@@ -1119,7 +1119,7 @@ func componentgen_wb(nr, nl *Node, wb bool) bool { ...@@ -1119,7 +1119,7 @@ func componentgen_wb(nr, nl *Node, wb bool) bool {
nodl.Type = Ptrto(Types[TUINT8]) nodl.Type = Ptrto(Types[TUINT8])
Regalloc(&nodr, Types[Tptr], nil) Regalloc(&nodr, Types[Tptr], nil)
p := Thearch.Gins(Thearch.Optoas(OAS, Types[Tptr]), nil, &nodr) p := Thearch.Gins(Thearch.Optoas(OAS, Types[Tptr]), nil, &nodr)
Datastring(nr.Val.U.(string), &p.From) Datastring(nr.Val().U.(string), &p.From)
p.From.Type = obj.TYPE_ADDR p.From.Type = obj.TYPE_ADDR
Thearch.Gmove(&nodr, &nodl) Thearch.Gmove(&nodr, &nodl)
Regfree(&nodr) Regfree(&nodr)
...@@ -1127,7 +1127,7 @@ func componentgen_wb(nr, nl *Node, wb bool) bool { ...@@ -1127,7 +1127,7 @@ func componentgen_wb(nr, nl *Node, wb bool) bool {
// length // length
nodl.Type = Types[Simtype[TUINT]] nodl.Type = Types[Simtype[TUINT]]
nodl.Xoffset += int64(Array_nel) - int64(Array_array) nodl.Xoffset += int64(Array_nel) - int64(Array_array)
Nodconst(&nodr, nodl.Type, int64(len(nr.Val.U.(string)))) Nodconst(&nodr, nodl.Type, int64(len(nr.Val().U.(string))))
Thearch.Gmove(&nodr, &nodl) Thearch.Gmove(&nodr, &nodl)
return true return true
} }
......
...@@ -1638,44 +1638,44 @@ structdcl: ...@@ -1638,44 +1638,44 @@ structdcl:
} }
n = embedded(n.Sym, importpkg); n = embedded(n.Sym, importpkg);
n.Right = $2; n.Right = $2;
n.Val = $3; n.SetVal($3)
$$ = list1(n); $$ = list1(n);
break; break;
} }
for l=$1; l != nil; l=l.Next { for l=$1; l != nil; l=l.Next {
l.N = Nod(ODCLFIELD, l.N, $2); l.N = Nod(ODCLFIELD, l.N, $2);
l.N.Val = $3; l.N.SetVal($3)
} }
} }
| embed oliteral | embed oliteral
{ {
$1.Val = $2; $1.SetVal($2)
$$ = list1($1); $$ = list1($1);
} }
| '(' embed ')' oliteral | '(' embed ')' oliteral
{ {
$2.Val = $4; $2.SetVal($4)
$$ = list1($2); $$ = list1($2);
Yyerror("cannot parenthesize embedded type"); Yyerror("cannot parenthesize embedded type");
} }
| '*' embed oliteral | '*' embed oliteral
{ {
$2.Right = Nod(OIND, $2.Right, nil); $2.Right = Nod(OIND, $2.Right, nil);
$2.Val = $3; $2.SetVal($3)
$$ = list1($2); $$ = list1($2);
} }
| '(' '*' embed ')' oliteral | '(' '*' embed ')' oliteral
{ {
$3.Right = Nod(OIND, $3.Right, nil); $3.Right = Nod(OIND, $3.Right, nil);
$3.Val = $5; $3.SetVal($5)
$$ = list1($3); $$ = list1($3);
Yyerror("cannot parenthesize embedded type"); Yyerror("cannot parenthesize embedded type");
} }
| '*' '(' embed ')' oliteral | '*' '(' embed ')' oliteral
{ {
$3.Right = Nod(OIND, $3.Right, nil); $3.Right = Nod(OIND, $3.Right, nil);
$3.Val = $5; $3.SetVal($5)
$$ = list1($3); $$ = list1($3);
Yyerror("cannot parenthesize embedded type"); Yyerror("cannot parenthesize embedded type");
} }
...@@ -2151,7 +2151,7 @@ hidden_funarg: ...@@ -2151,7 +2151,7 @@ hidden_funarg:
if $1 != nil { if $1 != nil {
$$.Left = newname($1); $$.Left = newname($1);
} }
$$.Val = $3; $$.SetVal($3)
} }
| sym LDDD hidden_type oliteral | sym LDDD hidden_type oliteral
{ {
...@@ -2166,7 +2166,7 @@ hidden_funarg: ...@@ -2166,7 +2166,7 @@ hidden_funarg:
$$.Left = newname($1); $$.Left = newname($1);
} }
$$.Isddd = true; $$.Isddd = true;
$$.Val = $4; $$.SetVal($4)
} }
hidden_structdcl: hidden_structdcl:
...@@ -2177,7 +2177,7 @@ hidden_structdcl: ...@@ -2177,7 +2177,7 @@ hidden_structdcl:
if $1 != nil && $1.Name != "?" { if $1 != nil && $1.Name != "?" {
$$ = Nod(ODCLFIELD, newname($1), typenod($2)); $$ = Nod(ODCLFIELD, newname($1), typenod($2));
$$.Val = $3; $$.SetVal($3)
} else { } else {
s = $2.Sym; s = $2.Sym;
if s == nil && Isptr[$2.Etype] { if s == nil && Isptr[$2.Etype] {
...@@ -2189,7 +2189,7 @@ hidden_structdcl: ...@@ -2189,7 +2189,7 @@ hidden_structdcl:
} }
$$ = embedded(s, p); $$ = embedded(s, p);
$$.Right = typenod($2); $$.Right = typenod($2);
$$.Val = $3; $$.SetVal($3)
} }
} }
...@@ -2231,16 +2231,16 @@ hidden_literal: ...@@ -2231,16 +2231,16 @@ hidden_literal:
| '-' LLITERAL | '-' LLITERAL
{ {
$$ = nodlit($2); $$ = nodlit($2);
switch($$.Val.Ctype()){ switch($$.Val().Ctype()){
case CTINT, CTRUNE: case CTINT, CTRUNE:
mpnegfix($$.Val.U.(*Mpint)); mpnegfix($$.Val().U.(*Mpint));
break; break;
case CTFLT: case CTFLT:
mpnegflt($$.Val.U.(*Mpflt)); mpnegflt($$.Val().U.(*Mpflt));
break; break;
case CTCPLX: case CTCPLX:
mpnegflt(&$$.Val.U.(*Mpcplx).Real); mpnegflt(&$$.Val().U.(*Mpcplx).Real);
mpnegflt(&$$.Val.U.(*Mpcplx).Imag); mpnegflt(&$$.Val().U.(*Mpcplx).Imag);
break; break;
default: default:
Yyerror("bad negated constant"); Yyerror("bad negated constant");
...@@ -2258,14 +2258,14 @@ hidden_constant: ...@@ -2258,14 +2258,14 @@ hidden_constant:
hidden_literal hidden_literal
| '(' hidden_literal '+' hidden_literal ')' | '(' hidden_literal '+' hidden_literal ')'
{ {
if $2.Val.Ctype() == CTRUNE && $4.Val.Ctype() == CTINT { if $2.Val().Ctype() == CTRUNE && $4.Val().Ctype() == CTINT {
$$ = $2; $$ = $2;
mpaddfixfix($2.Val.U.(*Mpint), $4.Val.U.(*Mpint), 0); mpaddfixfix($2.Val().U.(*Mpint), $4.Val().U.(*Mpint), 0);
break; break;
} }
$4.Val.U.(*Mpcplx).Real = $4.Val.U.(*Mpcplx).Imag; $4.Val().U.(*Mpcplx).Real = $4.Val().U.(*Mpcplx).Imag;
Mpmovecflt(&$4.Val.U.(*Mpcplx).Imag, 0.0); Mpmovecflt(&$4.Val().U.(*Mpcplx).Imag, 0.0);
$$ = nodcplxlit($2.Val, $4.Val); $$ = nodcplxlit($2.Val(), $4.Val());
} }
hidden_import_list: hidden_import_list:
......
...@@ -408,26 +408,26 @@ func Naddr(a *obj.Addr, n *Node) { ...@@ -408,26 +408,26 @@ func Naddr(a *obj.Addr, n *Node) {
if Thearch.Thechar == '8' { if Thearch.Thechar == '8' {
a.Width = 0 a.Width = 0
} }
switch n.Val.Ctype() { switch n.Val().Ctype() {
default: default:
Fatal("naddr: const %v", Tconv(n.Type, obj.FmtLong)) Fatal("naddr: const %v", Tconv(n.Type, obj.FmtLong))
case CTFLT: case CTFLT:
a.Type = obj.TYPE_FCONST a.Type = obj.TYPE_FCONST
a.Val = mpgetflt(n.Val.U.(*Mpflt)) a.Val = mpgetflt(n.Val().U.(*Mpflt))
case CTINT, CTRUNE: case CTINT, CTRUNE:
a.Sym = nil a.Sym = nil
a.Type = obj.TYPE_CONST a.Type = obj.TYPE_CONST
a.Offset = Mpgetfix(n.Val.U.(*Mpint)) a.Offset = Mpgetfix(n.Val().U.(*Mpint))
case CTSTR: case CTSTR:
datagostring(n.Val.U.(string), a) datagostring(n.Val().U.(string), a)
case CTBOOL: case CTBOOL:
a.Sym = nil a.Sym = nil
a.Type = obj.TYPE_CONST a.Type = obj.TYPE_CONST
a.Offset = int64(obj.Bool2int(n.Val.U.(bool))) a.Offset = int64(obj.Bool2int(n.Val().U.(bool)))
case CTNIL: case CTNIL:
a.Sym = nil a.Sym = nil
......
...@@ -383,13 +383,13 @@ func dsymptr(s *Sym, off int, x *Sym, xoff int) int { ...@@ -383,13 +383,13 @@ func dsymptr(s *Sym, off int, x *Sym, xoff int) int {
func gdata(nam *Node, nr *Node, wid int) { func gdata(nam *Node, nr *Node, wid int) {
if nr.Op == OLITERAL { if nr.Op == OLITERAL {
switch nr.Val.Ctype() { switch nr.Val().Ctype() {
case CTCPLX: case CTCPLX:
gdatacomplex(nam, nr.Val.U.(*Mpcplx)) gdatacomplex(nam, nr.Val().U.(*Mpcplx))
return return
case CTSTR: case CTSTR:
gdatastring(nam, nr.Val.U.(string)) gdatastring(nam, nr.Val().U.(string))
return return
} }
} }
......
...@@ -998,7 +998,7 @@ func orderexpr(np **Node, order *Order, lhs *Node) { ...@@ -998,7 +998,7 @@ func orderexpr(np **Node, order *Order, lhs *Node) {
haslit := false haslit := false
for l := n.List; l != nil; l = l.Next { for l := n.List; l != nil; l = l.Next {
hasbyte = hasbyte || l.N.Op == OARRAYBYTESTR hasbyte = hasbyte || l.N.Op == OARRAYBYTESTR
haslit = haslit || l.N.Op == OLITERAL && len(l.N.Val.U.(string)) != 0 haslit = haslit || l.N.Op == OLITERAL && len(l.N.Val().U.(string)) != 0
} }
if haslit && hasbyte { if haslit && hasbyte {
......
...@@ -233,7 +233,7 @@ func getvariables(fn *Node) []*Node { ...@@ -233,7 +233,7 @@ func getvariables(fn *Node) []*Node {
// Later, when we want to find the index of a node in the variables list, // Later, when we want to find the index of a node in the variables list,
// we will check that n->curfn == curfn and n->opt > 0. Then n->opt - 1 // we will check that n->curfn == curfn and n->opt > 0. Then n->opt - 1
// is the index in the variables list. // is the index in the variables list.
ll.N.Opt = nil ll.N.SetOpt(nil)
// The compiler doesn't emit initializations for zero-width parameters or results. // The compiler doesn't emit initializations for zero-width parameters or results.
if ll.N.Type.Width == 0 { if ll.N.Type.Width == 0 {
...@@ -244,12 +244,12 @@ func getvariables(fn *Node) []*Node { ...@@ -244,12 +244,12 @@ func getvariables(fn *Node) []*Node {
switch ll.N.Class { switch ll.N.Class {
case PAUTO: case PAUTO:
if haspointers(ll.N.Type) { if haspointers(ll.N.Type) {
ll.N.Opt = int32(len(result)) ll.N.SetOpt(int32(len(result)))
result = append(result, ll.N) result = append(result, ll.N)
} }
case PPARAM, PPARAMOUT: case PPARAM, PPARAMOUT:
ll.N.Opt = int32(len(result)) ll.N.SetOpt(int32(len(result)))
result = append(result, ll.N) result = append(result, ll.N)
} }
} }
...@@ -621,7 +621,7 @@ func progeffects(prog *obj.Prog, vars []*Node, uevar Bvec, varkill Bvec, avarini ...@@ -621,7 +621,7 @@ func progeffects(prog *obj.Prog, vars []*Node, uevar Bvec, varkill Bvec, avarini
if from.Node != nil && from.Sym != nil && ((from.Node).(*Node)).Name.Curfn == Curfn { if from.Node != nil && from.Sym != nil && ((from.Node).(*Node)).Name.Curfn == Curfn {
switch ((from.Node).(*Node)).Class &^ PHEAP { switch ((from.Node).(*Node)).Class &^ PHEAP {
case PAUTO, PPARAM, PPARAMOUT: case PAUTO, PPARAM, PPARAMOUT:
pos, ok := from.Node.(*Node).Opt.(int32) // index in vars pos, ok := from.Node.(*Node).Opt().(int32) // index in vars
if !ok { if !ok {
goto Next goto Next
} }
...@@ -650,7 +650,7 @@ Next: ...@@ -650,7 +650,7 @@ Next:
if to.Node != nil && to.Sym != nil && ((to.Node).(*Node)).Name.Curfn == Curfn { if to.Node != nil && to.Sym != nil && ((to.Node).(*Node)).Name.Curfn == Curfn {
switch ((to.Node).(*Node)).Class &^ PHEAP { switch ((to.Node).(*Node)).Class &^ PHEAP {
case PAUTO, PPARAM, PPARAMOUT: case PAUTO, PPARAM, PPARAMOUT:
pos, ok := to.Node.(*Node).Opt.(int32) // index in vars pos, ok := to.Node.(*Node).Opt().(int32) // index in vars
if !ok { if !ok {
return return
} }
...@@ -1819,7 +1819,7 @@ func liveness(fn *Node, firstp *obj.Prog, argssym *Sym, livesym *Sym) { ...@@ -1819,7 +1819,7 @@ func liveness(fn *Node, firstp *obj.Prog, argssym *Sym, livesym *Sym) {
// Free everything. // Free everything.
for l := fn.Func.Dcl; l != nil; l = l.Next { for l := fn.Func.Dcl; l != nil; l = l.Next {
if l.N != nil { if l.N != nil {
l.N.Opt = nil l.N.SetOpt(nil)
} }
} }
freeliveness(lv) freeliveness(lv)
......
...@@ -593,7 +593,7 @@ func mergetemp(firstp *obj.Prog) { ...@@ -593,7 +593,7 @@ func mergetemp(firstp *obj.Prog) {
if canmerge(n) { if canmerge(n) {
v = &var_[nvar] v = &var_[nvar]
nvar++ nvar++
n.Opt = v n.SetOpt(v)
v.node = n v.node = n
} }
} }
...@@ -604,18 +604,18 @@ func mergetemp(firstp *obj.Prog) { ...@@ -604,18 +604,18 @@ func mergetemp(firstp *obj.Prog) {
// single-use (that's why we have so many!). // single-use (that's why we have so many!).
for f := g.Start; f != nil; f = f.Link { for f := g.Start; f != nil; f = f.Link {
p := f.Prog p := f.Prog
if p.From.Node != nil && ((p.From.Node).(*Node)).Opt != nil && p.To.Node != nil && ((p.To.Node).(*Node)).Opt != nil { if p.From.Node != nil && ((p.From.Node).(*Node)).Opt() != nil && p.To.Node != nil && ((p.To.Node).(*Node)).Opt() != nil {
Fatal("double node %v", p) Fatal("double node %v", p)
} }
v = nil v = nil
n, _ = p.From.Node.(*Node) n, _ = p.From.Node.(*Node)
if n != nil { if n != nil {
v, _ = n.Opt.(*TempVar) v, _ = n.Opt().(*TempVar)
} }
if v == nil { if v == nil {
n, _ = p.To.Node.(*Node) n, _ = p.To.Node.(*Node)
if n != nil { if n != nil {
v, _ = n.Opt.(*TempVar) v, _ = n.Opt().(*TempVar)
} }
} }
if v != nil { if v != nil {
...@@ -816,14 +816,14 @@ func mergetemp(firstp *obj.Prog) { ...@@ -816,14 +816,14 @@ func mergetemp(firstp *obj.Prog) {
p := f.Prog p := f.Prog
n, _ = p.From.Node.(*Node) n, _ = p.From.Node.(*Node)
if n != nil { if n != nil {
v, _ = n.Opt.(*TempVar) v, _ = n.Opt().(*TempVar)
if v != nil && v.merge != nil { if v != nil && v.merge != nil {
p.From.Node = v.merge.node p.From.Node = v.merge.node
} }
} }
n, _ = p.To.Node.(*Node) n, _ = p.To.Node.(*Node)
if n != nil { if n != nil {
v, _ = n.Opt.(*TempVar) v, _ = n.Opt().(*TempVar)
if v != nil && v.merge != nil { if v != nil && v.merge != nil {
p.To.Node = v.merge.node p.To.Node = v.merge.node
} }
...@@ -840,7 +840,7 @@ func mergetemp(firstp *obj.Prog) { ...@@ -840,7 +840,7 @@ func mergetemp(firstp *obj.Prog) {
Curfn.Func.Dcl.End = l Curfn.Func.Dcl.End = l
n = l.N n = l.N
v, _ = n.Opt.(*TempVar) v, _ = n.Opt().(*TempVar)
if v != nil && (v.merge != nil || v.removed != 0) { if v != nil && (v.merge != nil || v.removed != 0) {
*lp = l.Next *lp = l.Next
continue continue
...@@ -851,7 +851,7 @@ func mergetemp(firstp *obj.Prog) { ...@@ -851,7 +851,7 @@ func mergetemp(firstp *obj.Prog) {
// Clear aux structures. // Clear aux structures.
for i := 0; i < len(var_); i++ { for i := 0; i < len(var_); i++ {
var_[i].node.Opt = nil var_[i].node.SetOpt(nil)
} }
Flowend(g) Flowend(g)
......
...@@ -201,7 +201,7 @@ func walkvardef(n *Node, f *Flow, active int) { ...@@ -201,7 +201,7 @@ func walkvardef(n *Node, f *Flow, active int) {
if f1.Prog.As == obj.AVARKILL && f1.Prog.To.Node == n { if f1.Prog.As == obj.AVARKILL && f1.Prog.To.Node == n {
break break
} }
for v, _ = n.Opt.(*Var); v != nil; v = v.nextinnode { for v, _ = n.Opt().(*Var); v != nil; v = v.nextinnode {
bn = v.id bn = v.id
biset(&(f1.Data.(*Reg)).act, uint(bn)) biset(&(f1.Data.(*Reg)).act, uint(bn))
} }
...@@ -432,9 +432,9 @@ func mkvar(f *Flow, a *obj.Addr) Bits { ...@@ -432,9 +432,9 @@ func mkvar(f *Flow, a *obj.Addr) Bits {
// of Vars within the given Node, so that // of Vars within the given Node, so that
// we can start at a Var and find all the other // we can start at a Var and find all the other
// Vars in the same Go variable. // Vars in the same Go variable.
v.nextinnode, _ = node.Opt.(*Var) v.nextinnode, _ = node.Opt().(*Var)
node.Opt = v node.SetOpt(v)
bit := blsh(uint(i)) bit := blsh(uint(i))
if n == obj.NAME_EXTERN || n == obj.NAME_STATIC { if n == obj.NAME_EXTERN || n == obj.NAME_STATIC {
...@@ -563,7 +563,7 @@ func prop(f *Flow, ref Bits, cal Bits) { ...@@ -563,7 +563,7 @@ func prop(f *Flow, ref Bits, cal Bits) {
continue continue
} }
v = &vars[z*64+i] v = &vars[z*64+i]
if v.node.Opt == nil { // v represents fixed register, not Go variable if v.node.Opt() == nil { // v represents fixed register, not Go variable
continue continue
} }
...@@ -577,7 +577,7 @@ func prop(f *Flow, ref Bits, cal Bits) { ...@@ -577,7 +577,7 @@ func prop(f *Flow, ref Bits, cal Bits) {
// To avoid the quadratic behavior, we only turn on the bits if // To avoid the quadratic behavior, we only turn on the bits if
// v is the head of the list or if the head's bit is not yet turned on. // v is the head of the list or if the head's bit is not yet turned on.
// This will set the bits at most twice, keeping the overall loop linear. // This will set the bits at most twice, keeping the overall loop linear.
v1, _ = v.node.Opt.(*Var) v1, _ = v.node.Opt().(*Var)
if v == v1 || !btest(&cal, uint(v1.id)) { if v == v1 || !btest(&cal, uint(v1.id)) {
for ; v1 != nil; v1 = v1.nextinnode { for ; v1 != nil; v1 = v1.nextinnode {
...@@ -1072,7 +1072,7 @@ func regopt(firstp *obj.Prog) { ...@@ -1072,7 +1072,7 @@ func regopt(firstp *obj.Prog) {
g := Flowstart(firstp, func() interface{} { return new(Reg) }) g := Flowstart(firstp, func() interface{} { return new(Reg) })
if g == nil { if g == nil {
for i := 0; i < nvar; i++ { for i := 0; i < nvar; i++ {
vars[i].node.Opt = nil vars[i].node.SetOpt(nil)
} }
return return
} }
...@@ -1186,7 +1186,7 @@ func regopt(firstp *obj.Prog) { ...@@ -1186,7 +1186,7 @@ func regopt(firstp *obj.Prog) {
for f := firstf; f != nil; f = f.Link { for f := firstf; f != nil; f = f.Link {
p := f.Prog p := f.Prog
if p.As == obj.AVARDEF && Isfat(((p.To.Node).(*Node)).Type) && ((p.To.Node).(*Node)).Opt != nil { if p.As == obj.AVARDEF && Isfat(((p.To.Node).(*Node)).Type) && ((p.To.Node).(*Node)).Opt() != nil {
active++ active++
walkvardef(p.To.Node.(*Node), f, active) walkvardef(p.To.Node.(*Node), f, active)
} }
...@@ -1390,7 +1390,7 @@ loop2: ...@@ -1390,7 +1390,7 @@ loop2:
* free aux structures. peep allocates new ones. * free aux structures. peep allocates new ones.
*/ */
for i := 0; i < nvar; i++ { for i := 0; i < nvar; i++ {
vars[i].node.Opt = nil vars[i].node.SetOpt(nil)
} }
Flowend(g) Flowend(g)
firstf = nil firstf = nil
......
...@@ -441,7 +441,7 @@ func staticassign(l *Node, r *Node, out **NodeList) bool { ...@@ -441,7 +441,7 @@ func staticassign(l *Node, r *Node, out **NodeList) bool {
case OSTRARRAYBYTE: case OSTRARRAYBYTE:
if l.Class == PEXTERN && r.Left.Op == OLITERAL { 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)) slicebytes(l, sval, len(sval))
return true return true
} }
...@@ -453,7 +453,7 @@ func staticassign(l *Node, r *Node, out **NodeList) bool { ...@@ -453,7 +453,7 @@ func staticassign(l *Node, r *Node, out **NodeList) bool {
ta := typ(TARRAY) ta := typ(TARRAY)
ta.Type = r.Type.Type 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) a := staticname(ta, 1)
inittemps[r] = a inittemps[r] = a
n1 = *l n1 = *l
...@@ -522,7 +522,7 @@ func staticname(t *Type, ctxt int) *Node { ...@@ -522,7 +522,7 @@ func staticname(t *Type, ctxt int) *Node {
func isliteral(n *Node) bool { func isliteral(n *Node) bool {
if n.Op == OLITERAL { if n.Op == OLITERAL {
if n.Val.Ctype() != CTNIL { if n.Val().Ctype() != CTNIL {
return true return true
} }
} }
...@@ -726,7 +726,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init **NodeList) { ...@@ -726,7 +726,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init **NodeList) {
// make an array type // make an array type
t := shallow(n.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.Width = 0
t.Sym = nil t.Sym = nil
t.Haspointers = 0 t.Haspointers = 0
...@@ -1231,7 +1231,7 @@ func oaslit(n *Node, init **NodeList) bool { ...@@ -1231,7 +1231,7 @@ func oaslit(n *Node, init **NodeList) bool {
func getlit(lit *Node) int { func getlit(lit *Node) int {
if Smallintconst(lit) { if Smallintconst(lit) {
return int(Mpgetfix(lit.Val.U.(*Mpint))) return int(Mpgetfix(lit.Val().U.(*Mpint)))
} }
return -1 return -1
} }
...@@ -1295,7 +1295,7 @@ func initplan(n *Node) { ...@@ -1295,7 +1295,7 @@ func initplan(n *Node) {
if a.Op != OKEY || !Smallintconst(a.Left) { if a.Op != OKEY || !Smallintconst(a.Left) {
Fatal("initplan arraylit") 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: case OSTRUCTLIT:
...@@ -1356,7 +1356,7 @@ func addvalue(p *InitPlan, xoffset int64, key *Node, n *Node) { ...@@ -1356,7 +1356,7 @@ func addvalue(p *InitPlan, xoffset int64, key *Node, n *Node) {
func iszero(n *Node) bool { func iszero(n *Node) bool {
switch n.Op { switch n.Op {
case OLITERAL: case OLITERAL:
switch n.Val.Ctype() { switch n.Val().Ctype() {
default: default:
Dump("unexpected literal", n) Dump("unexpected literal", n)
Fatal("iszero") Fatal("iszero")
...@@ -1365,19 +1365,19 @@ func iszero(n *Node) bool { ...@@ -1365,19 +1365,19 @@ func iszero(n *Node) bool {
return true return true
case CTSTR: case CTSTR:
return n.Val.U.(string) == "" return n.Val().U.(string) == ""
case CTBOOL: case CTBOOL:
return !n.Val.U.(bool) return !n.Val().U.(bool)
case CTINT, CTRUNE: case CTINT, CTRUNE:
return mpcmpfixc(n.Val.U.(*Mpint), 0) == 0 return mpcmpfixc(n.Val().U.(*Mpint), 0) == 0
case CTFLT: case CTFLT:
return mpcmpfltc(n.Val.U.(*Mpflt), 0) == 0 return mpcmpfltc(n.Val().U.(*Mpflt), 0) == 0
case CTCPLX: 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: case OARRAYLIT:
...@@ -1515,10 +1515,10 @@ func gen_as_init(n *Node) bool { ...@@ -1515,10 +1515,10 @@ func gen_as_init(n *Node) bool {
gdata(&nam, nr, int(nr.Type.Width)) gdata(&nam, nr, int(nr.Type.Width))
case TCOMPLEX64, TCOMPLEX128: case TCOMPLEX64, TCOMPLEX128:
gdatacomplex(&nam, nr.Val.U.(*Mpcplx)) gdatacomplex(&nam, nr.Val().U.(*Mpcplx))
case TSTRING: case TSTRING:
gdatastring(&nam, nr.Val.U.(string)) gdatastring(&nam, nr.Val().U.(string))
} }
return true return true
......
...@@ -676,8 +676,8 @@ func sortinter(t *Type) *Type { ...@@ -676,8 +676,8 @@ func sortinter(t *Type) *Type {
func Nodintconst(v int64) *Node { func Nodintconst(v int64) *Node {
c := Nod(OLITERAL, nil, nil) c := Nod(OLITERAL, nil, nil)
c.Addable = true c.Addable = true
c.Val.U = new(Mpint) c.SetVal(Val{new(Mpint)})
Mpmovecfix(c.Val.U.(*Mpint), v) Mpmovecfix(c.Val().U.(*Mpint), v)
c.Type = Types[TIDEAL] c.Type = Types[TIDEAL]
ullmancalc(c) ullmancalc(c)
return c return c
...@@ -686,8 +686,8 @@ func Nodintconst(v int64) *Node { ...@@ -686,8 +686,8 @@ func Nodintconst(v int64) *Node {
func nodfltconst(v *Mpflt) *Node { func nodfltconst(v *Mpflt) *Node {
c := Nod(OLITERAL, nil, nil) c := Nod(OLITERAL, nil, nil)
c.Addable = true c.Addable = true
c.Val.U = newMpflt() c.SetVal(Val{newMpflt()})
mpmovefltflt(c.Val.U.(*Mpflt), v) mpmovefltflt(c.Val().U.(*Mpflt), v)
c.Type = Types[TIDEAL] c.Type = Types[TIDEAL]
ullmancalc(c) ullmancalc(c)
return c return c
...@@ -698,8 +698,8 @@ func Nodconst(n *Node, t *Type, v int64) { ...@@ -698,8 +698,8 @@ func Nodconst(n *Node, t *Type, v int64) {
n.Op = OLITERAL n.Op = OLITERAL
n.Addable = true n.Addable = true
ullmancalc(n) ullmancalc(n)
n.Val.U = new(Mpint) n.SetVal(Val{new(Mpint)})
Mpmovecfix(n.Val.U.(*Mpint), v) Mpmovecfix(n.Val().U.(*Mpint), v)
n.Type = t n.Type = t
if Isfloat[t.Etype] { if Isfloat[t.Etype] {
...@@ -709,14 +709,14 @@ func Nodconst(n *Node, t *Type, v int64) { ...@@ -709,14 +709,14 @@ func Nodconst(n *Node, t *Type, v int64) {
func nodnil() *Node { func nodnil() *Node {
c := Nodintconst(0) c := Nodintconst(0)
c.Val.U = new(NilVal) c.SetVal(Val{new(NilVal)})
c.Type = Types[TNIL] c.Type = Types[TNIL]
return c return c
} }
func Nodbool(b bool) *Node { func Nodbool(b bool) *Node {
c := Nodintconst(0) c := Nodintconst(0)
c.Val.U = b c.SetVal(Val{b})
c.Type = idealbool c.Type = idealbool
return c return c
} }
...@@ -730,7 +730,7 @@ func aindex(b *Node, t *Type) *Type { ...@@ -730,7 +730,7 @@ func aindex(b *Node, t *Type) *Type {
Yyerror("array bound must be an integer expression") Yyerror("array bound must be an integer expression")
case CTINT, CTRUNE: case CTINT, CTRUNE:
bound = Mpgetfix(b.Val.U.(*Mpint)) bound = Mpgetfix(b.Val().U.(*Mpint))
if bound < 0 { if bound < 0 {
Yyerror("array bound must be non negative") Yyerror("array bound must be non negative")
} }
...@@ -804,7 +804,7 @@ func isnil(n *Node) bool { ...@@ -804,7 +804,7 @@ func isnil(n *Node) bool {
if n.Op != OLITERAL { if n.Op != OLITERAL {
return false return false
} }
if n.Val.Ctype() != CTNIL { if n.Val().Ctype() != CTNIL {
return false return false
} }
return true return true
...@@ -3156,7 +3156,7 @@ func powtwo(n *Node) int { ...@@ -3156,7 +3156,7 @@ func powtwo(n *Node) int {
return -1 return -1
} }
v := uint64(Mpgetfix(n.Val.U.(*Mpint))) v := uint64(Mpgetfix(n.Val().U.(*Mpint)))
b := uint64(1) b := uint64(1)
for i := 0; i < 64; i++ { for i := 0; i < 64; i++ {
if b == v { if b == v {
......
...@@ -217,7 +217,7 @@ func (s *exprSwitch) walk(sw *Node) { ...@@ -217,7 +217,7 @@ func (s *exprSwitch) walk(sw *Node) {
s.kind = switchKindExpr s.kind = switchKindExpr
if Isconst(cond, CTBOOL) { if Isconst(cond, CTBOOL) {
s.kind = switchKindTrue s.kind = switchKindTrue
if !cond.Val.U.(bool) { if !cond.Val().U.(bool) {
s.kind = switchKindFalse s.kind = switchKindFalse
} }
} }
...@@ -742,11 +742,11 @@ func exprcmp(c1, c2 *caseClause) int { ...@@ -742,11 +742,11 @@ func exprcmp(c1, c2 *caseClause) int {
n2 := c2.node.Left n2 := c2.node.Left
// sort by type (for switches on interface) // sort by type (for switches on interface)
ct := int(n1.Val.Ctype()) ct := int(n1.Val().Ctype())
if ct > int(n2.Val.Ctype()) { if ct > int(n2.Val().Ctype()) {
return +1 return +1
} }
if ct < int(n2.Val.Ctype()) { if ct < int(n2.Val().Ctype()) {
return -1 return -1
} }
if !Eqtype(n1.Type, n2.Type) { if !Eqtype(n1.Type, n2.Type) {
...@@ -760,16 +760,16 @@ func exprcmp(c1, c2 *caseClause) int { ...@@ -760,16 +760,16 @@ func exprcmp(c1, c2 *caseClause) int {
// sort by constant value to enable binary search // sort by constant value to enable binary search
switch ct { switch ct {
case CTFLT: case CTFLT:
return mpcmpfltflt(n1.Val.U.(*Mpflt), n2.Val.U.(*Mpflt)) return mpcmpfltflt(n1.Val().U.(*Mpflt), n2.Val().U.(*Mpflt))
case CTINT, CTRUNE: case CTINT, CTRUNE:
return Mpcmpfixfix(n1.Val.U.(*Mpint), n2.Val.U.(*Mpint)) return Mpcmpfixfix(n1.Val().U.(*Mpint), n2.Val().U.(*Mpint))
case CTSTR: case CTSTR:
// Sort strings by length and then by value. // Sort strings by length and then by value.
// It is much cheaper to compare lengths than values, // It is much cheaper to compare lengths than values,
// and all we need here is consistency. // and all we need here is consistency.
// We respect this sorting in exprSwitch.walkCases. // We respect this sorting in exprSwitch.walkCases.
a := n1.Val.U.(string) a := n1.Val().U.(string)
b := n2.Val.U.(string) b := n2.Val().U.(string)
if len(a) < len(b) { if len(a) < len(b) {
return -1 return -1
} }
......
...@@ -30,12 +30,8 @@ type Node struct { ...@@ -30,12 +30,8 @@ type Node struct {
// ONAME // ONAME
Name *Name Name *Name
Sym *Sym // various Sym *Sym // various
E interface{} // Opt or Val, see methods below
Opt interface{} // for optimization passes
// OLITERAL
Val Val
Xoffset int64 Xoffset int64
...@@ -69,6 +65,49 @@ type Node struct { ...@@ -69,6 +65,49 @@ type Node struct {
Assigned bool // is the variable ever assigned to Assigned bool // is the variable ever assigned to
Likely int8 // likeliness of if statement Likely int8 // likeliness of if statement
Hasbreak bool // has break statement Hasbreak bool // has break statement
hasVal int8 // +1 for Val, -1 for Opt, 0 for not yet set
}
// Val returns the Val for the node.
func (n *Node) Val() Val {
if n.hasVal != +1 {
return Val{}
}
return Val{n.E}
}
// SetVal sets the Val for the node, which must not have been used with SetOpt.
func (n *Node) SetVal(v Val) {
if n.hasVal == -1 {
Debug['h'] = 1
Dump("have Opt", n)
Fatal("have Opt")
}
n.hasVal = +1
n.E = v.U
}
// Opt returns the optimizer data for the node.
func (n *Node) Opt() interface{} {
if n.hasVal != -1 {
return nil
}
return n.E
}
// SetOpt sets the optimizer data for the node, which must not have been used with SetVal.
// SetOpt(nil) is ignored for Vals to simplify call sites that are clearing Opts.
func (n *Node) SetOpt(x interface{}) {
if x == nil && n.hasVal >= 0 {
return
}
if n.hasVal == +1 {
Debug['h'] = 1
Dump("have Val", n)
Fatal("have Val")
}
n.hasVal = -1
n.E = x
} }
// Name holds Node fields used only by named nodes (ONAME, OPACK, some OLITERAL). // Name holds Node fields used only by named nodes (ONAME, OPACK, some OLITERAL).
......
...@@ -301,7 +301,7 @@ OpSwitch: ...@@ -301,7 +301,7 @@ OpSwitch:
case OLITERAL: case OLITERAL:
ok |= Erv ok |= Erv
if n.Type == nil && n.Val.Ctype() == CTSTR { if n.Type == nil && n.Val().Ctype() == CTSTR {
n.Type = idealstring n.Type = idealstring
} }
break OpSwitch break OpSwitch
...@@ -377,10 +377,10 @@ OpSwitch: ...@@ -377,10 +377,10 @@ OpSwitch:
var v Val var v Val
switch consttype(l) { switch consttype(l) {
case CTINT, CTRUNE: case CTINT, CTRUNE:
v = l.Val v = l.Val()
case CTFLT: case CTFLT:
v = toint(l.Val) v = toint(l.Val())
default: default:
if l.Type != nil && Isint[l.Type.Etype] && l.Op != OLITERAL { if l.Type != nil && Isint[l.Type.Etype] && l.Op != OLITERAL {
...@@ -756,12 +756,12 @@ OpSwitch: ...@@ -756,12 +756,12 @@ OpSwitch:
} }
if et == TINTER { if et == TINTER {
if l.Op == OLITERAL && l.Val.Ctype() == CTNIL { if l.Op == OLITERAL && l.Val().Ctype() == CTNIL {
// swap for back end // swap for back end
n.Left = r n.Left = r
n.Right = l n.Right = l
} else if r.Op == OLITERAL && r.Val.Ctype() == CTNIL { } else if r.Op == OLITERAL && r.Val().Ctype() == CTNIL {
} else // leave alone for back end } else // leave alone for back end
if Isinter(r.Type) == Isinter(l.Type) { if Isinter(r.Type) == Isinter(l.Type) {
n.Etype = n.Op n.Etype = n.Op
...@@ -770,7 +770,7 @@ OpSwitch: ...@@ -770,7 +770,7 @@ OpSwitch:
} }
if (op == ODIV || op == OMOD) && Isconst(r, CTINT) { if (op == ODIV || op == OMOD) && Isconst(r, CTINT) {
if mpcmpfixc(r.Val.U.(*Mpint), 0) == 0 { if mpcmpfixc(r.Val().U.(*Mpint), 0) == 0 {
Yyerror("division by zero") Yyerror("division by zero")
n.Type = nil n.Type = nil
return return
...@@ -1046,14 +1046,14 @@ OpSwitch: ...@@ -1046,14 +1046,14 @@ OpSwitch:
} }
if Isconst(n.Right, CTINT) { if Isconst(n.Right, CTINT) {
x := Mpgetfix(n.Right.Val.U.(*Mpint)) x := Mpgetfix(n.Right.Val().U.(*Mpint))
if x < 0 { if x < 0 {
Yyerror("invalid %s index %v (index must be non-negative)", why, n.Right) Yyerror("invalid %s index %v (index must be non-negative)", why, n.Right)
} else if Isfixedarray(t) && t.Bound > 0 && x >= t.Bound { } else if Isfixedarray(t) && t.Bound > 0 && x >= t.Bound {
Yyerror("invalid array index %v (out of bounds for %d-element array)", n.Right, t.Bound) Yyerror("invalid array index %v (out of bounds for %d-element array)", n.Right, t.Bound)
} else if Isconst(n.Left, CTSTR) && x >= int64(len(n.Left.Val.U.(string))) { } else if Isconst(n.Left, CTSTR) && x >= int64(len(n.Left.Val().U.(string))) {
Yyerror("invalid string index %v (out of bounds for %d-byte string)", n.Right, len(n.Left.Val.U.(string))) Yyerror("invalid string index %v (out of bounds for %d-byte string)", n.Right, len(n.Left.Val().U.(string)))
} else if Mpcmpfixfix(n.Right.Val.U.(*Mpint), Maxintval[TINT]) > 0 { } else if Mpcmpfixfix(n.Right.Val().U.(*Mpint), Maxintval[TINT]) > 0 {
Yyerror("invalid %s index %v (index too large)", why, n.Right) Yyerror("invalid %s index %v (index too large)", why, n.Right)
} }
} }
...@@ -1438,9 +1438,9 @@ OpSwitch: ...@@ -1438,9 +1438,9 @@ OpSwitch:
if Isconst(l, CTCPLX) { if Isconst(l, CTCPLX) {
r := n r := n
if n.Op == OREAL { if n.Op == OREAL {
n = nodfltconst(&l.Val.U.(*Mpcplx).Real) n = nodfltconst(&l.Val().U.(*Mpcplx).Real)
} else { } else {
n = nodfltconst(&l.Val.U.(*Mpcplx).Imag) n = nodfltconst(&l.Val().U.(*Mpcplx).Imag)
} }
n.Orig = r n.Orig = r
} }
...@@ -1454,7 +1454,7 @@ OpSwitch: ...@@ -1454,7 +1454,7 @@ OpSwitch:
case TSTRING: case TSTRING:
if Isconst(l, CTSTR) { if Isconst(l, CTSTR) {
r := Nod(OXXX, nil, nil) r := Nod(OXXX, nil, nil)
Nodconst(r, Types[TINT], int64(len(l.Val.U.(string)))) Nodconst(r, Types[TINT], int64(len(l.Val().U.(string))))
r.Orig = n r.Orig = n
n = r n = r
} }
...@@ -1547,7 +1547,7 @@ OpSwitch: ...@@ -1547,7 +1547,7 @@ OpSwitch:
if l.Op == OLITERAL && r.Op == OLITERAL { if l.Op == OLITERAL && r.Op == OLITERAL {
// make it a complex literal // make it a complex literal
r = nodcplxlit(l.Val, r.Val) r = nodcplxlit(l.Val(), r.Val())
r.Orig = n r.Orig = n
n = r n = r
...@@ -1788,7 +1788,7 @@ OpSwitch: ...@@ -1788,7 +1788,7 @@ OpSwitch:
n.Orig = r n.Orig = r
*r = *n *r = *n
n.Op = OLITERAL n.Op = OLITERAL
n.Val = n.Left.Val n.SetVal(n.Left.Val())
} }
// do not use stringtoarraylit. // do not use stringtoarraylit.
...@@ -1862,7 +1862,7 @@ OpSwitch: ...@@ -1862,7 +1862,7 @@ OpSwitch:
n.Type = nil n.Type = nil
return return
} }
if Isconst(l, CTINT) && r != nil && Isconst(r, CTINT) && Mpcmpfixfix(l.Val.U.(*Mpint), r.Val.U.(*Mpint)) > 0 { if Isconst(l, CTINT) && r != nil && Isconst(r, CTINT) && Mpcmpfixfix(l.Val().U.(*Mpint), r.Val().U.(*Mpint)) > 0 {
Yyerror("len larger than cap in make(%v)", t) Yyerror("len larger than cap in make(%v)", t)
n.Type = nil n.Type = nil
return return
...@@ -2258,16 +2258,16 @@ func checksliceindex(l *Node, r *Node, tp *Type) int { ...@@ -2258,16 +2258,16 @@ func checksliceindex(l *Node, r *Node, tp *Type) int {
} }
if r.Op == OLITERAL { if r.Op == OLITERAL {
if Mpgetfix(r.Val.U.(*Mpint)) < 0 { if Mpgetfix(r.Val().U.(*Mpint)) < 0 {
Yyerror("invalid slice index %v (index must be non-negative)", r) Yyerror("invalid slice index %v (index must be non-negative)", r)
return -1 return -1
} else if tp != nil && tp.Bound > 0 && Mpgetfix(r.Val.U.(*Mpint)) > tp.Bound { } else if tp != nil && tp.Bound > 0 && Mpgetfix(r.Val().U.(*Mpint)) > tp.Bound {
Yyerror("invalid slice index %v (out of bounds for %d-element array)", r, tp.Bound) Yyerror("invalid slice index %v (out of bounds for %d-element array)", r, tp.Bound)
return -1 return -1
} else if Isconst(l, CTSTR) && Mpgetfix(r.Val.U.(*Mpint)) > int64(len(l.Val.U.(string))) { } else if Isconst(l, CTSTR) && Mpgetfix(r.Val().U.(*Mpint)) > int64(len(l.Val().U.(string))) {
Yyerror("invalid slice index %v (out of bounds for %d-byte string)", r, len(l.Val.U.(string))) Yyerror("invalid slice index %v (out of bounds for %d-byte string)", r, len(l.Val().U.(string)))
return -1 return -1
} else if Mpcmpfixfix(r.Val.U.(*Mpint), Maxintval[TINT]) > 0 { } else if Mpcmpfixfix(r.Val().U.(*Mpint), Maxintval[TINT]) > 0 {
Yyerror("invalid slice index %v (index too large)", r) Yyerror("invalid slice index %v (index too large)", r)
return -1 return -1
} }
...@@ -2277,7 +2277,7 @@ func checksliceindex(l *Node, r *Node, tp *Type) int { ...@@ -2277,7 +2277,7 @@ func checksliceindex(l *Node, r *Node, tp *Type) int {
} }
func checksliceconst(lo *Node, hi *Node) int { func checksliceconst(lo *Node, hi *Node) int {
if lo != nil && hi != nil && lo.Op == OLITERAL && hi.Op == OLITERAL && Mpcmpfixfix(lo.Val.U.(*Mpint), hi.Val.U.(*Mpint)) > 0 { if lo != nil && hi != nil && lo.Op == OLITERAL && hi.Op == OLITERAL && Mpcmpfixfix(lo.Val().U.(*Mpint), hi.Val().U.(*Mpint)) > 0 {
Yyerror("invalid slice index: %v > %v", lo, hi) Yyerror("invalid slice index: %v > %v", lo, hi)
return -1 return -1
} }
...@@ -2833,15 +2833,15 @@ func keydup(n *Node, hash map[uint32][]*Node) { ...@@ -2833,15 +2833,15 @@ func keydup(n *Node, hash map[uint32][]*Node) {
} }
var h uint32 var h uint32
switch n.Val.Ctype() { switch n.Val().Ctype() {
default: // unknown, bool, nil default: // unknown, bool, nil
h = 23 h = 23
case CTINT, CTRUNE: case CTINT, CTRUNE:
h = uint32(Mpgetfix(n.Val.U.(*Mpint))) h = uint32(Mpgetfix(n.Val().U.(*Mpint)))
case CTFLT: case CTFLT:
d := mpgetflt(n.Val.U.(*Mpflt)) d := mpgetflt(n.Val().U.(*Mpflt))
x := math.Float64bits(d) x := math.Float64bits(d)
for i := 0; i < 8; i++ { for i := 0; i < 8; i++ {
h = h*PRIME1 + uint32(x&0xFF) h = h*PRIME1 + uint32(x&0xFF)
...@@ -2850,8 +2850,8 @@ func keydup(n *Node, hash map[uint32][]*Node) { ...@@ -2850,8 +2850,8 @@ func keydup(n *Node, hash map[uint32][]*Node) {
case CTSTR: case CTSTR:
h = 0 h = 0
s := n.Val.U.(string) s := n.Val().U.(string)
for i := len(n.Val.U.(string)); i > 0; i-- { for i := len(n.Val().U.(string)); i > 0; i-- {
h = h*PRIME1 + uint32(s[0]) h = h*PRIME1 + uint32(s[0])
s = s[1:] s = s[1:]
} }
...@@ -2866,12 +2866,12 @@ func keydup(n *Node, hash map[uint32][]*Node) { ...@@ -2866,12 +2866,12 @@ func keydup(n *Node, hash map[uint32][]*Node) {
if Eqtype(a.Left.Type, n.Type) { if Eqtype(a.Left.Type, n.Type) {
cmp.Right = a.Left cmp.Right = a.Left
evconst(&cmp) evconst(&cmp)
b = uint32(obj.Bool2int(cmp.Val.U.(bool))) b = uint32(obj.Bool2int(cmp.Val().U.(bool)))
} }
} else if Eqtype(a.Type, n.Type) { } else if Eqtype(a.Type, n.Type) {
cmp.Right = a cmp.Right = a
evconst(&cmp) evconst(&cmp)
b = uint32(obj.Bool2int(cmp.Val.U.(bool))) b = uint32(obj.Bool2int(cmp.Val().U.(bool)))
} }
if b != 0 { if b != 0 {
...@@ -2888,7 +2888,7 @@ func indexdup(n *Node, hash map[int64]*Node) { ...@@ -2888,7 +2888,7 @@ func indexdup(n *Node, hash map[int64]*Node) {
Fatal("indexdup: not OLITERAL") Fatal("indexdup: not OLITERAL")
} }
v := Mpgetfix(n.Val.U.(*Mpint)) v := Mpgetfix(n.Val().U.(*Mpint))
if hash[v] != nil { if hash[v] != nil {
Yyerror("duplicate index in array literal: %d", v) Yyerror("duplicate index in array literal: %d", v)
return return
...@@ -3488,11 +3488,11 @@ func typecheckfunc(n *Node) { ...@@ -3488,11 +3488,11 @@ func typecheckfunc(n *Node) {
func stringtoarraylit(np **Node) { func stringtoarraylit(np **Node) {
n := *np n := *np
if n.Left.Op != OLITERAL || n.Left.Val.Ctype() != CTSTR { if n.Left.Op != OLITERAL || n.Left.Val().Ctype() != CTSTR {
Fatal("stringtoarraylit %v", n) Fatal("stringtoarraylit %v", n)
} }
s := n.Left.Val.U.(string) s := n.Left.Val().U.(string)
var l *NodeList var l *NodeList
if n.Type.Type.Etype == TUINT8 { if n.Type.Type.Etype == TUINT8 {
// []byte // []byte
...@@ -3767,7 +3767,7 @@ func typecheckdef(n *Node) *Node { ...@@ -3767,7 +3767,7 @@ func typecheckdef(n *Node) *Node {
Convlit(&e, t) Convlit(&e, t)
} }
n.Val = e.Val n.SetVal(e.Val())
n.Type = e.Type n.Type = e.Type
case ONAME: case ONAME:
...@@ -3847,15 +3847,15 @@ ret: ...@@ -3847,15 +3847,15 @@ ret:
func checkmake(t *Type, arg string, n *Node) int { func checkmake(t *Type, arg string, n *Node) int {
if n.Op == OLITERAL { if n.Op == OLITERAL {
switch n.Val.Ctype() { switch n.Val().Ctype() {
case CTINT, CTRUNE, CTFLT, CTCPLX: case CTINT, CTRUNE, CTFLT, CTCPLX:
n.Val = toint(n.Val) n.SetVal(toint(n.Val()))
if mpcmpfixc(n.Val.U.(*Mpint), 0) < 0 { if mpcmpfixc(n.Val().U.(*Mpint), 0) < 0 {
Yyerror("negative %s argument in make(%v)", arg, t) Yyerror("negative %s argument in make(%v)", arg, t)
return -1 return -1
} }
if Mpcmpfixfix(n.Val.U.(*Mpint), Maxintval[TINT]) > 0 { if Mpcmpfixfix(n.Val().U.(*Mpint), Maxintval[TINT]) > 0 {
Yyerror("%s argument too large in make(%v)", arg, t) Yyerror("%s argument too large in make(%v)", arg, t)
return -1 return -1
} }
......
...@@ -142,7 +142,7 @@ ret: ...@@ -142,7 +142,7 @@ ret:
Mpmovecfix(val.U.(*Mpint), v) Mpmovecfix(val.U.(*Mpint), v)
n := Nod(OLITERAL, nil, nil) n := Nod(OLITERAL, nil, nil)
n.Orig = nn n.Orig = nn
n.Val = val n.SetVal(val)
n.Type = Types[TUINTPTR] n.Type = Types[TUINTPTR]
nn.Type = Types[TUINTPTR] nn.Type = Types[TUINTPTR]
return n return n
......
...@@ -363,7 +363,7 @@ func isSmallMakeSlice(n *Node) bool { ...@@ -363,7 +363,7 @@ func isSmallMakeSlice(n *Node) bool {
} }
t := n.Type t := n.Type
return Smallintconst(l) && Smallintconst(r) && (t.Type.Width == 0 || Mpgetfix(r.Val.U.(*Mpint)) < (1<<16)/t.Type.Width) return Smallintconst(l) && Smallintconst(r) && (t.Type.Width == 0 || Mpgetfix(r.Val().U.(*Mpint)) < (1<<16)/t.Type.Width)
} }
/* /*
...@@ -1220,7 +1220,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1220,7 +1220,7 @@ func walkexpr(np **Node, init **NodeList) {
Yyerror("index out of bounds") Yyerror("index out of bounds")
} }
} else if Isconst(n.Left, CTSTR) { } else if Isconst(n.Left, CTSTR) {
n.Bounded = bounded(r, int64(len(n.Left.Val.U.(string)))) n.Bounded = bounded(r, int64(len(n.Left.Val().U.(string))))
if Debug['m'] != 0 && n.Bounded && !Isconst(n.Right, CTINT) { if Debug['m'] != 0 && n.Bounded && !Isconst(n.Right, CTINT) {
Warn("index bounds check elided") Warn("index bounds check elided")
} }
...@@ -1231,16 +1231,16 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1231,16 +1231,16 @@ func walkexpr(np **Node, init **NodeList) {
// replace "abc"[1] with 'b'. // replace "abc"[1] with 'b'.
// delayed until now because "abc"[1] is not // delayed until now because "abc"[1] is not
// an ideal constant. // an ideal constant.
v := Mpgetfix(n.Right.Val.U.(*Mpint)) v := Mpgetfix(n.Right.Val().U.(*Mpint))
Nodconst(n, n.Type, int64(n.Left.Val.U.(string)[v])) Nodconst(n, n.Type, int64(n.Left.Val().U.(string)[v]))
n.Typecheck = 1 n.Typecheck = 1
} }
} }
} }
if Isconst(n.Right, CTINT) { if Isconst(n.Right, CTINT) {
if Mpcmpfixfix(n.Right.Val.U.(*Mpint), &mpzero) < 0 || Mpcmpfixfix(n.Right.Val.U.(*Mpint), Maxintval[TINT]) > 0 { if Mpcmpfixfix(n.Right.Val().U.(*Mpint), &mpzero) < 0 || Mpcmpfixfix(n.Right.Val().U.(*Mpint), Maxintval[TINT]) > 0 {
Yyerror("index out of bounds") Yyerror("index out of bounds")
} }
} }
...@@ -1355,7 +1355,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -1355,7 +1355,7 @@ func walkexpr(np **Node, init **NodeList) {
// comparing the lengths instead will yield the same result // comparing the lengths instead will yield the same result
// without the function call. // without the function call.
case OCMPSTR: case OCMPSTR:
if (Isconst(n.Left, CTSTR) && len(n.Left.Val.U.(string)) == 0) || (Isconst(n.Right, CTSTR) && len(n.Right.Val.U.(string)) == 0) { if (Isconst(n.Left, CTSTR) && len(n.Left.Val().U.(string)) == 0) || (Isconst(n.Right, CTSTR) && len(n.Right.Val().U.(string)) == 0) {
r := Nod(int(n.Etype), Nod(OLEN, n.Left, nil), Nod(OLEN, n.Right, nil)) r := Nod(int(n.Etype), Nod(OLEN, n.Left, nil), Nod(OLEN, n.Right, nil))
typecheck(&r, Erv) typecheck(&r, Erv)
walkexpr(&r, init) walkexpr(&r, init)
...@@ -2027,7 +2027,7 @@ func walkprint(nn *Node, init **NodeList) *Node { ...@@ -2027,7 +2027,7 @@ func walkprint(nn *Node, init **NodeList) *Node {
n = l.N n = l.N
if n.Op == OLITERAL { if n.Op == OLITERAL {
switch n.Val.Ctype() { switch n.Val().Ctype() {
case CTRUNE: case CTRUNE:
defaultlit(&n, runetype) defaultlit(&n, runetype)
...@@ -2828,7 +2828,7 @@ func addstr(n *Node, init **NodeList) *Node { ...@@ -2828,7 +2828,7 @@ func addstr(n *Node, init **NodeList) *Node {
sz := int64(0) sz := int64(0)
for l := n.List; l != nil; l = l.Next { for l := n.List; l != nil; l = l.Next {
if n.Op == OLITERAL { if n.Op == OLITERAL {
sz += int64(len(n.Val.U.(string))) sz += int64(len(n.Val().U.(string)))
} }
} }
...@@ -3383,7 +3383,7 @@ func samecheap(a *Node, b *Node) bool { ...@@ -3383,7 +3383,7 @@ func samecheap(a *Node, b *Node) bool {
case OINDEX: case OINDEX:
ar = a.Right ar = a.Right
br = b.Right br = b.Right
if !Isconst(ar, CTINT) || !Isconst(br, CTINT) || Mpcmpfixfix(ar.Val.U.(*Mpint), br.Val.U.(*Mpint)) != 0 { if !Isconst(ar, CTINT) || !Isconst(br, CTINT) || Mpcmpfixfix(ar.Val().U.(*Mpint), br.Val().U.(*Mpint)) != 0 {
return false return false
} }
} }
...@@ -3419,9 +3419,9 @@ func walkrotate(np **Node) { ...@@ -3419,9 +3419,9 @@ func walkrotate(np **Node) {
w := int(l.Type.Width * 8) w := int(l.Type.Width * 8)
if Smallintconst(l.Right) && Smallintconst(r.Right) { if Smallintconst(l.Right) && Smallintconst(r.Right) {
sl := int(Mpgetfix(l.Right.Val.U.(*Mpint))) sl := int(Mpgetfix(l.Right.Val().U.(*Mpint)))
if sl >= 0 { if sl >= 0 {
sr := int(Mpgetfix(r.Right.Val.U.(*Mpint))) sr := int(Mpgetfix(r.Right.Val().U.(*Mpint)))
if sr >= 0 && sl+sr == w { if sr >= 0 && sl+sr == w {
// Rewrite left shift half to left rotate. // Rewrite left shift half to left rotate.
if l.Op == OLSH { if l.Op == OLSH {
...@@ -3432,7 +3432,7 @@ func walkrotate(np **Node) { ...@@ -3432,7 +3432,7 @@ func walkrotate(np **Node) {
n.Op = OLROT n.Op = OLROT
// Remove rotate 0 and rotate w. // Remove rotate 0 and rotate w.
s := int(Mpgetfix(n.Right.Val.U.(*Mpint))) s := int(Mpgetfix(n.Right.Val().U.(*Mpint)))
if s == 0 || s == w { if s == 0 || s == w {
n = n.Left n = n.Left
...@@ -3475,7 +3475,7 @@ func walkmul(np **Node, init **NodeList) { ...@@ -3475,7 +3475,7 @@ func walkmul(np **Node, init **NodeList) {
// x*0 is 0 (and side effects of x). // x*0 is 0 (and side effects of x).
var pow int var pow int
var w int var w int
if Mpgetfix(nr.Val.U.(*Mpint)) == 0 { if Mpgetfix(nr.Val().U.(*Mpint)) == 0 {
cheapexpr(nl, init) cheapexpr(nl, init)
Nodconst(n, n.Type, 0) Nodconst(n, n.Type, 0)
goto ret goto ret
...@@ -3568,10 +3568,10 @@ func walkdiv(np **Node, init **NodeList) { ...@@ -3568,10 +3568,10 @@ func walkdiv(np **Node, init **NodeList) {
m.W = w m.W = w
if Issigned[nl.Type.Etype] { if Issigned[nl.Type.Etype] {
m.Sd = Mpgetfix(nr.Val.U.(*Mpint)) m.Sd = Mpgetfix(nr.Val().U.(*Mpint))
Smagic(&m) Smagic(&m)
} else { } else {
m.Ud = uint64(Mpgetfix(nr.Val.U.(*Mpint))) m.Ud = uint64(Mpgetfix(nr.Val().U.(*Mpint)))
Umagic(&m) Umagic(&m)
} }
...@@ -3765,7 +3765,7 @@ func walkdiv(np **Node, init **NodeList) { ...@@ -3765,7 +3765,7 @@ func walkdiv(np **Node, init **NodeList) {
// n = nl & (nr-1) // n = nl & (nr-1)
n.Op = OAND n.Op = OAND
Nodconst(nc, nl.Type, Mpgetfix(nr.Val.U.(*Mpint))-1) Nodconst(nc, nl.Type, Mpgetfix(nr.Val().U.(*Mpint))-1)
} else { } else {
// n = nl >> pow // n = nl >> pow
n.Op = ORSH n.Op = ORSH
...@@ -3795,7 +3795,7 @@ func bounded(n *Node, max int64) bool { ...@@ -3795,7 +3795,7 @@ func bounded(n *Node, max int64) bool {
bits := int32(8 * n.Type.Width) bits := int32(8 * n.Type.Width)
if Smallintconst(n) { if Smallintconst(n) {
v := Mpgetfix(n.Val.U.(*Mpint)) v := Mpgetfix(n.Val().U.(*Mpint))
return 0 <= v && v < max return 0 <= v && v < max
} }
...@@ -3803,9 +3803,9 @@ func bounded(n *Node, max int64) bool { ...@@ -3803,9 +3803,9 @@ func bounded(n *Node, max int64) bool {
case OAND: case OAND:
v := int64(-1) v := int64(-1)
if Smallintconst(n.Left) { if Smallintconst(n.Left) {
v = Mpgetfix(n.Left.Val.U.(*Mpint)) v = Mpgetfix(n.Left.Val().U.(*Mpint))
} else if Smallintconst(n.Right) { } else if Smallintconst(n.Right) {
v = Mpgetfix(n.Right.Val.U.(*Mpint)) v = Mpgetfix(n.Right.Val().U.(*Mpint))
} }
if 0 <= v && v < max { if 0 <= v && v < max {
...@@ -3814,7 +3814,7 @@ func bounded(n *Node, max int64) bool { ...@@ -3814,7 +3814,7 @@ func bounded(n *Node, max int64) bool {
case OMOD: case OMOD:
if !sign && Smallintconst(n.Right) { if !sign && Smallintconst(n.Right) {
v := Mpgetfix(n.Right.Val.U.(*Mpint)) v := Mpgetfix(n.Right.Val().U.(*Mpint))
if 0 <= v && v <= max { if 0 <= v && v <= max {
return true return true
} }
...@@ -3822,7 +3822,7 @@ func bounded(n *Node, max int64) bool { ...@@ -3822,7 +3822,7 @@ func bounded(n *Node, max int64) bool {
case ODIV: case ODIV:
if !sign && Smallintconst(n.Right) { if !sign && Smallintconst(n.Right) {
v := Mpgetfix(n.Right.Val.U.(*Mpint)) v := Mpgetfix(n.Right.Val().U.(*Mpint))
for bits > 0 && v >= 2 { for bits > 0 && v >= 2 {
bits-- bits--
v >>= 1 v >>= 1
...@@ -3831,7 +3831,7 @@ func bounded(n *Node, max int64) bool { ...@@ -3831,7 +3831,7 @@ func bounded(n *Node, max int64) bool {
case ORSH: case ORSH:
if !sign && Smallintconst(n.Right) { if !sign && Smallintconst(n.Right) {
v := Mpgetfix(n.Right.Val.U.(*Mpint)) v := Mpgetfix(n.Right.Val().U.(*Mpint))
if v > int64(bits) { if v > int64(bits) {
return true return true
} }
...@@ -3965,17 +3965,17 @@ func candiscard(n *Node) bool { ...@@ -3965,17 +3965,17 @@ func candiscard(n *Node) bool {
// Discardable as long as we know it's not division by zero. // Discardable as long as we know it's not division by zero.
case ODIV, OMOD: case ODIV, OMOD:
if Isconst(n.Right, CTINT) && mpcmpfixc(n.Right.Val.U.(*Mpint), 0) != 0 { if Isconst(n.Right, CTINT) && mpcmpfixc(n.Right.Val().U.(*Mpint), 0) != 0 {
break break
} }
if Isconst(n.Right, CTFLT) && mpcmpfltc(n.Right.Val.U.(*Mpflt), 0) != 0 { if Isconst(n.Right, CTFLT) && mpcmpfltc(n.Right.Val().U.(*Mpflt), 0) != 0 {
break break
} }
return false return false
// Discardable as long as we know it won't fail because of a bad size. // Discardable as long as we know it won't fail because of a bad size.
case OMAKECHAN, OMAKEMAP: case OMAKECHAN, OMAKEMAP:
if Isconst(n.Left, CTINT) && mpcmpfixc(n.Left.Val.U.(*Mpint), 0) == 0 { if Isconst(n.Left, CTINT) && mpcmpfixc(n.Left.Val().U.(*Mpint), 0) == 0 {
break break
} }
return false return false
......
...@@ -2797,28 +2797,28 @@ yydefault: ...@@ -2797,28 +2797,28 @@ yydefault:
} }
n = embedded(n.Sym, importpkg) n = embedded(n.Sym, importpkg)
n.Right = yyDollar[2].node n.Right = yyDollar[2].node
n.Val = yyDollar[3].val n.SetVal(yyDollar[3].val)
yyVAL.list = list1(n) yyVAL.list = list1(n)
break break
} }
for l = yyDollar[1].list; l != nil; l = l.Next { for l = yyDollar[1].list; l != nil; l = l.Next {
l.N = Nod(ODCLFIELD, l.N, yyDollar[2].node) l.N = Nod(ODCLFIELD, l.N, yyDollar[2].node)
l.N.Val = yyDollar[3].val l.N.SetVal(yyDollar[3].val)
} }
} }
case 231: case 231:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
//line go.y:1652 //line go.y:1652
{ {
yyDollar[1].node.Val = yyDollar[2].val yyDollar[1].node.SetVal(yyDollar[2].val)
yyVAL.list = list1(yyDollar[1].node) yyVAL.list = list1(yyDollar[1].node)
} }
case 232: case 232:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
//line go.y:1657 //line go.y:1657
{ {
yyDollar[2].node.Val = yyDollar[4].val yyDollar[2].node.SetVal(yyDollar[4].val)
yyVAL.list = list1(yyDollar[2].node) yyVAL.list = list1(yyDollar[2].node)
Yyerror("cannot parenthesize embedded type") Yyerror("cannot parenthesize embedded type")
} }
...@@ -2827,7 +2827,7 @@ yydefault: ...@@ -2827,7 +2827,7 @@ yydefault:
//line go.y:1663 //line go.y:1663
{ {
yyDollar[2].node.Right = Nod(OIND, yyDollar[2].node.Right, nil) yyDollar[2].node.Right = Nod(OIND, yyDollar[2].node.Right, nil)
yyDollar[2].node.Val = yyDollar[3].val yyDollar[2].node.SetVal(yyDollar[3].val)
yyVAL.list = list1(yyDollar[2].node) yyVAL.list = list1(yyDollar[2].node)
} }
case 234: case 234:
...@@ -2835,7 +2835,7 @@ yydefault: ...@@ -2835,7 +2835,7 @@ yydefault:
//line go.y:1669 //line go.y:1669
{ {
yyDollar[3].node.Right = Nod(OIND, yyDollar[3].node.Right, nil) yyDollar[3].node.Right = Nod(OIND, yyDollar[3].node.Right, nil)
yyDollar[3].node.Val = yyDollar[5].val yyDollar[3].node.SetVal(yyDollar[5].val)
yyVAL.list = list1(yyDollar[3].node) yyVAL.list = list1(yyDollar[3].node)
Yyerror("cannot parenthesize embedded type") Yyerror("cannot parenthesize embedded type")
} }
...@@ -2844,7 +2844,7 @@ yydefault: ...@@ -2844,7 +2844,7 @@ yydefault:
//line go.y:1676 //line go.y:1676
{ {
yyDollar[3].node.Right = Nod(OIND, yyDollar[3].node.Right, nil) yyDollar[3].node.Right = Nod(OIND, yyDollar[3].node.Right, nil)
yyDollar[3].node.Val = yyDollar[5].val yyDollar[3].node.SetVal(yyDollar[5].val)
yyVAL.list = list1(yyDollar[3].node) yyVAL.list = list1(yyDollar[3].node)
Yyerror("cannot parenthesize embedded type") Yyerror("cannot parenthesize embedded type")
} }
...@@ -3360,7 +3360,7 @@ yydefault: ...@@ -3360,7 +3360,7 @@ yydefault:
if yyDollar[1].sym != nil { if yyDollar[1].sym != nil {
yyVAL.node.Left = newname(yyDollar[1].sym) yyVAL.node.Left = newname(yyDollar[1].sym)
} }
yyVAL.node.Val = yyDollar[3].val yyVAL.node.SetVal(yyDollar[3].val)
} }
case 331: case 331:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
...@@ -3377,7 +3377,7 @@ yydefault: ...@@ -3377,7 +3377,7 @@ yydefault:
yyVAL.node.Left = newname(yyDollar[1].sym) yyVAL.node.Left = newname(yyDollar[1].sym)
} }
yyVAL.node.Isddd = true yyVAL.node.Isddd = true
yyVAL.node.Val = yyDollar[4].val yyVAL.node.SetVal(yyDollar[4].val)
} }
case 332: case 332:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
...@@ -3388,7 +3388,7 @@ yydefault: ...@@ -3388,7 +3388,7 @@ yydefault:
if yyDollar[1].sym != nil && yyDollar[1].sym.Name != "?" { if yyDollar[1].sym != nil && yyDollar[1].sym.Name != "?" {
yyVAL.node = Nod(ODCLFIELD, newname(yyDollar[1].sym), typenod(yyDollar[2].typ)) yyVAL.node = Nod(ODCLFIELD, newname(yyDollar[1].sym), typenod(yyDollar[2].typ))
yyVAL.node.Val = yyDollar[3].val yyVAL.node.SetVal(yyDollar[3].val)
} else { } else {
s = yyDollar[2].typ.Sym s = yyDollar[2].typ.Sym
if s == nil && Isptr[yyDollar[2].typ.Etype] { if s == nil && Isptr[yyDollar[2].typ.Etype] {
...@@ -3400,7 +3400,7 @@ yydefault: ...@@ -3400,7 +3400,7 @@ yydefault:
} }
yyVAL.node = embedded(s, p) yyVAL.node = embedded(s, p)
yyVAL.node.Right = typenod(yyDollar[2].typ) yyVAL.node.Right = typenod(yyDollar[2].typ)
yyVAL.node.Val = yyDollar[3].val yyVAL.node.SetVal(yyDollar[3].val)
} }
} }
case 333: case 333:
...@@ -3444,16 +3444,16 @@ yydefault: ...@@ -3444,16 +3444,16 @@ yydefault:
//line go.y:2232 //line go.y:2232
{ {
yyVAL.node = nodlit(yyDollar[2].val) yyVAL.node = nodlit(yyDollar[2].val)
switch yyVAL.node.Val.Ctype() { switch yyVAL.node.Val().Ctype() {
case CTINT, CTRUNE: case CTINT, CTRUNE:
mpnegfix(yyVAL.node.Val.U.(*Mpint)) mpnegfix(yyVAL.node.Val().U.(*Mpint))
break break
case CTFLT: case CTFLT:
mpnegflt(yyVAL.node.Val.U.(*Mpflt)) mpnegflt(yyVAL.node.Val().U.(*Mpflt))
break break
case CTCPLX: case CTCPLX:
mpnegflt(&yyVAL.node.Val.U.(*Mpcplx).Real) mpnegflt(&yyVAL.node.Val().U.(*Mpcplx).Real)
mpnegflt(&yyVAL.node.Val.U.(*Mpcplx).Imag) mpnegflt(&yyVAL.node.Val().U.(*Mpcplx).Imag)
break break
default: default:
Yyerror("bad negated constant") Yyerror("bad negated constant")
...@@ -3472,14 +3472,14 @@ yydefault: ...@@ -3472,14 +3472,14 @@ yydefault:
yyDollar = yyS[yypt-5 : yypt+1] yyDollar = yyS[yypt-5 : yypt+1]
//line go.y:2260 //line go.y:2260
{ {
if yyDollar[2].node.Val.Ctype() == CTRUNE && yyDollar[4].node.Val.Ctype() == CTINT { if yyDollar[2].node.Val().Ctype() == CTRUNE && yyDollar[4].node.Val().Ctype() == CTINT {
yyVAL.node = yyDollar[2].node yyVAL.node = yyDollar[2].node
mpaddfixfix(yyDollar[2].node.Val.U.(*Mpint), yyDollar[4].node.Val.U.(*Mpint), 0) mpaddfixfix(yyDollar[2].node.Val().U.(*Mpint), yyDollar[4].node.Val().U.(*Mpint), 0)
break break
} }
yyDollar[4].node.Val.U.(*Mpcplx).Real = yyDollar[4].node.Val.U.(*Mpcplx).Imag yyDollar[4].node.Val().U.(*Mpcplx).Real = yyDollar[4].node.Val().U.(*Mpcplx).Imag
Mpmovecflt(&yyDollar[4].node.Val.U.(*Mpcplx).Imag, 0.0) Mpmovecflt(&yyDollar[4].node.Val().U.(*Mpcplx).Imag, 0.0)
yyVAL.node = nodcplxlit(yyDollar[2].node.Val, yyDollar[4].node.Val) yyVAL.node = nodcplxlit(yyDollar[2].node.Val(), yyDollar[4].node.Val())
} }
case 346: case 346:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment