Commit e7fe9f56 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/internal/gc: convert Bval to bool

No functional changes. Passes toolstash -cmp.

Change-Id: I4fba0c248645c3910ee3f7fc99dacafb676c5dc2
Reviewed-on: https://go-review.googlesource.com/8911Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent a23a341e
......@@ -447,7 +447,7 @@ func intLiteral(n *gc.Node) (x int64, ok bool) {
case gc.CTINT, gc.CTRUNE:
return gc.Mpgetfix(n.Val.U.Xval), true
case gc.CTBOOL:
return int64(n.Val.U.Bval), true
return int64(bool2int(n.Val.U.Bval)), true
}
return
}
......
......@@ -526,7 +526,7 @@ func intLiteral(n *gc.Node) (x int64, ok bool) {
case gc.CTINT, gc.CTRUNE:
return gc.Mpgetfix(n.Val.U.Xval), true
case gc.CTBOOL:
return int64(n.Val.U.Bval), true
return int64(bool2int(n.Val.U.Bval)), true
}
return
}
......
......@@ -1690,7 +1690,7 @@ func Bgen(n *Node, true_ bool, likely int, to *obj.Prog) {
// need to ask if it is bool?
case OLITERAL:
if !true_ == (n.Val.U.Bval == 0) {
if true_ == n.Val.U.Bval {
Patch(Gbranch(obj.AJMP, nil, likely), to)
}
return
......
......@@ -650,7 +650,7 @@ func evconst(n *Node) {
mpnegflt(&v.U.Cval.Imag)
case ONOT<<16 | CTBOOL:
if v.U.Bval == 0 {
if !v.U.Bval {
goto settrue
}
goto setfalse
......@@ -990,13 +990,13 @@ func evconst(n *Node) {
goto setfalse
case OOROR<<16 | CTBOOL:
if v.U.Bval != 0 || rv.U.Bval != 0 {
if v.U.Bval || rv.U.Bval {
goto settrue
}
goto setfalse
case OANDAND<<16 | CTBOOL:
if v.U.Bval != 0 && rv.U.Bval != 0 {
if v.U.Bval && rv.U.Bval {
goto settrue
}
goto setfalse
......@@ -1418,7 +1418,7 @@ func Convconst(con *Node, t *Type, val *Val) {
i = Mpgetfix(val.U.Xval)
case CTBOOL:
i = int64(val.U.Bval)
i = int64(bool2int(val.U.Bval))
case CTNIL:
i = 0
......
......@@ -344,7 +344,7 @@ func Vconv(v *Val, flag int) string {
return strconv.Quote(v.U.Sval)
case CTBOOL:
if v.U.Bval != 0 {
if v.U.Bval {
return "true"
}
return "false"
......
......@@ -85,7 +85,7 @@ type Val struct {
Ctype int16
U struct {
Reg int16 // OREGISTER
Bval int16 // bool value CTBOOL
Bval bool // bool value CTBOOL
Xval *Mpint // int CTINT, rune CTRUNE
Fval *Mpflt // float CTFLT
Cval *Mpcplx // float CTCPLX
......
......@@ -417,7 +417,7 @@ func Naddr(a *obj.Addr, n *Node) {
case CTBOOL:
a.Sym = nil
a.Type = obj.TYPE_CONST
a.Offset = int64(n.Val.U.Bval)
a.Offset = int64(bool2int(n.Val.U.Bval))
case CTNIL:
a.Sym = nil
......
......@@ -1363,7 +1363,7 @@ func iszero(n *Node) bool {
return n.Val.U.Sval == ""
case CTBOOL:
return n.Val.U.Bval == 0
return !n.Val.U.Bval
case CTINT, CTRUNE:
return mpcmpfixc(n.Val.U.Xval, 0) == 0
......
......@@ -710,7 +710,7 @@ func nodnil() *Node {
func Nodbool(b bool) *Node {
c := Nodintconst(0)
c.Val.Ctype = CTBOOL
c.Val.U.Bval = int16(bool2int(b))
c.Val.U.Bval = b
c.Type = idealbool
return c
}
......
......@@ -218,7 +218,7 @@ func (s *exprSwitch) walk(sw *Node) {
s.kind = switchKindExpr
if Isconst(sw.Ntest, CTBOOL) {
s.kind = switchKindTrue
if sw.Ntest.Val.U.Bval == 0 {
if !sw.Ntest.Val.U.Bval {
s.kind = switchKindFalse
}
}
......
......@@ -2826,12 +2826,12 @@ func keydup(n *Node, hash []*Node) {
if Eqtype(a.Left.Type, n.Type) {
cmp.Right = a.Left
evconst(&cmp)
b = uint32(cmp.Val.U.Bval)
b = uint32(bool2int(cmp.Val.U.Bval))
}
} else if Eqtype(a.Type, n.Type) {
cmp.Right = a
evconst(&cmp)
b = uint32(cmp.Val.U.Bval)
b = uint32(bool2int(cmp.Val.U.Bval))
}
if b != 0 {
......
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