mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/{5,6,8,9}g, cmd/internal/gc: use bools for is* and okfor*
No functional changes. This diff was generated as follows: * Manually edit cmd/internal/gc/go.go to update types and group variables. * Manually edit initialization in cmd/internal/gc/align.go--localized s/1/true. * Manually fix the handling of sign in cmd/internal/gc/walk.go in func bounded (near line 4000). * Manually update go.y and regenerate y.go. * Run gofmt -r many times to do the rest, using https://gist.github.com/josharian/0f61dbb2dff81f938e70. toolstash -cmp on the stdlib comes back green. Change-Id: I19766ed551714e51b325133e7138818d117b3a9a Reviewed-on: https://go-review.googlesource.com/6530 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
85c6f71b08
commit
25da594c6a
32 changed files with 294 additions and 304 deletions
|
|
@ -107,7 +107,7 @@ func cgen(n *gc.Node, res *gc.Node) {
|
||||||
|
|
||||||
// if both are addressable, move
|
// if both are addressable, move
|
||||||
if n.Addable != 0 && res.Addable != 0 {
|
if n.Addable != 0 && res.Addable != 0 {
|
||||||
if gc.Is64(n.Type) || gc.Is64(res.Type) || n.Op == gc.OREGISTER || res.Op == gc.OREGISTER || gc.Iscomplex[n.Type.Etype] != 0 || gc.Iscomplex[res.Type.Etype] != 0 {
|
if gc.Is64(n.Type) || gc.Is64(res.Type) || n.Op == gc.OREGISTER || res.Op == gc.OREGISTER || gc.Iscomplex[n.Type.Etype] || gc.Iscomplex[res.Type.Etype] {
|
||||||
gmove(n, res)
|
gmove(n, res)
|
||||||
} else {
|
} else {
|
||||||
var n1 gc.Node
|
var n1 gc.Node
|
||||||
|
|
@ -148,7 +148,7 @@ func cgen(n *gc.Node, res *gc.Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if n is sudoaddable generate addr and move
|
// if n is sudoaddable generate addr and move
|
||||||
if !gc.Is64(n.Type) && !gc.Is64(res.Type) && gc.Iscomplex[n.Type.Etype] == 0 && gc.Iscomplex[res.Type.Etype] == 0 {
|
if !gc.Is64(n.Type) && !gc.Is64(res.Type) && !gc.Iscomplex[n.Type.Etype] && !gc.Iscomplex[res.Type.Etype] {
|
||||||
a := optoas(gc.OAS, n.Type)
|
a := optoas(gc.OAS, n.Type)
|
||||||
var w int
|
var w int
|
||||||
var addr obj.Addr
|
var addr obj.Addr
|
||||||
|
|
@ -220,7 +220,7 @@ func cgen(n *gc.Node, res *gc.Node) {
|
||||||
var f0 gc.Node
|
var f0 gc.Node
|
||||||
var n1 gc.Node
|
var n1 gc.Node
|
||||||
var n2 gc.Node
|
var n2 gc.Node
|
||||||
if nl != nil && gc.Isfloat[n.Type.Etype] != 0 && gc.Isfloat[nl.Type.Etype] != 0 {
|
if nl != nil && gc.Isfloat[n.Type.Etype] && gc.Isfloat[nl.Type.Etype] {
|
||||||
// floating-point.
|
// floating-point.
|
||||||
regalloc(&f0, nl.Type, res)
|
regalloc(&f0, nl.Type, res)
|
||||||
|
|
||||||
|
|
@ -338,7 +338,7 @@ func cgen(n *gc.Node, res *gc.Node) {
|
||||||
regalloc(&n1, nl.Type, res)
|
regalloc(&n1, nl.Type, res)
|
||||||
gmove(nl, &n1)
|
gmove(nl, &n1)
|
||||||
} else {
|
} else {
|
||||||
if n.Type.Width > int64(gc.Widthptr) || gc.Is64(nl.Type) || gc.Isfloat[nl.Type.Etype] != 0 {
|
if n.Type.Width > int64(gc.Widthptr) || gc.Is64(nl.Type) || gc.Isfloat[nl.Type.Etype] {
|
||||||
gc.Tempname(&n1, nl.Type)
|
gc.Tempname(&n1, nl.Type)
|
||||||
} else {
|
} else {
|
||||||
regalloc(&n1, nl.Type, res)
|
regalloc(&n1, nl.Type, res)
|
||||||
|
|
@ -347,7 +347,7 @@ func cgen(n *gc.Node, res *gc.Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var n2 gc.Node
|
var n2 gc.Node
|
||||||
if n.Type.Width > int64(gc.Widthptr) || gc.Is64(n.Type) || gc.Isfloat[n.Type.Etype] != 0 {
|
if n.Type.Width > int64(gc.Widthptr) || gc.Is64(n.Type) || gc.Isfloat[n.Type.Etype] {
|
||||||
gc.Tempname(&n2, n.Type)
|
gc.Tempname(&n2, n.Type)
|
||||||
} else {
|
} else {
|
||||||
regalloc(&n2, n.Type, nil)
|
regalloc(&n2, n.Type, nil)
|
||||||
|
|
@ -1269,7 +1269,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
|
||||||
gc.OGE:
|
gc.OGE:
|
||||||
a := int(n.Op)
|
a := int(n.Op)
|
||||||
if !true_ {
|
if !true_ {
|
||||||
if gc.Isfloat[nl.Type.Etype] != 0 {
|
if gc.Isfloat[nl.Type.Etype] {
|
||||||
// brcom is not valid on floats when NaN is involved.
|
// brcom is not valid on floats when NaN is involved.
|
||||||
p1 := gc.Gbranch(arm.AB, nil, 0)
|
p1 := gc.Gbranch(arm.AB, nil, 0)
|
||||||
|
|
||||||
|
|
@ -1328,7 +1328,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if gc.Iscomplex[nl.Type.Etype] != 0 {
|
if gc.Iscomplex[nl.Type.Etype] {
|
||||||
gc.Complexbool(a, nl, nr, true_, likely, to)
|
gc.Complexbool(a, nl, nr, true_, likely, to)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
@ -1408,7 +1408,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
|
||||||
gmove(&tmp, &n2)
|
gmove(&tmp, &n2)
|
||||||
|
|
||||||
gcmp(optoas(gc.OCMP, nr.Type), &n1, &n2)
|
gcmp(optoas(gc.OCMP, nr.Type), &n1, &n2)
|
||||||
if gc.Isfloat[nl.Type.Etype] != 0 {
|
if gc.Isfloat[nl.Type.Etype] {
|
||||||
if n.Op == gc.ONE {
|
if n.Op == gc.ONE {
|
||||||
p1 := gc.Gbranch(arm.ABVS, nr.Type, likely)
|
p1 := gc.Gbranch(arm.ABVS, nr.Type, likely)
|
||||||
gc.Patch(gc.Gbranch(a, nr.Type, likely), to)
|
gc.Patch(gc.Gbranch(a, nr.Type, likely), to)
|
||||||
|
|
@ -1441,7 +1441,7 @@ func stkof(n *gc.Node) int32 {
|
||||||
|
|
||||||
case gc.ODOT:
|
case gc.ODOT:
|
||||||
t := n.Left.Type
|
t := n.Left.Type
|
||||||
if gc.Isptr[t.Etype] != 0 {
|
if gc.Isptr[t.Etype] {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
off := stkof(n.Left)
|
off := stkof(n.Left)
|
||||||
|
|
@ -1468,7 +1468,7 @@ func stkof(n *gc.Node) int32 {
|
||||||
gc.OCALLINTER,
|
gc.OCALLINTER,
|
||||||
gc.OCALLFUNC:
|
gc.OCALLFUNC:
|
||||||
t := n.Left.Type
|
t := n.Left.Type
|
||||||
if gc.Isptr[t.Etype] != 0 {
|
if gc.Isptr[t.Etype] {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -383,7 +383,7 @@ func cgen_callret(n *gc.Node, res *gc.Node) {
|
||||||
*/
|
*/
|
||||||
func cgen_aret(n *gc.Node, res *gc.Node) {
|
func cgen_aret(n *gc.Node, res *gc.Node) {
|
||||||
t := n.Left.Type
|
t := n.Left.Type
|
||||||
if gc.Isptr[t.Etype] != 0 {
|
if gc.Isptr[t.Etype] {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -466,7 +466,7 @@ func cgen_hmul(nl *gc.Node, nr *gc.Node, res *gc.Node) {
|
||||||
case gc.TINT32,
|
case gc.TINT32,
|
||||||
gc.TUINT32:
|
gc.TUINT32:
|
||||||
var p *obj.Prog
|
var p *obj.Prog
|
||||||
if gc.Issigned[t.Etype] != 0 {
|
if gc.Issigned[t.Etype] {
|
||||||
p = gins(arm.AMULL, &n2, nil)
|
p = gins(arm.AMULL, &n2, nil)
|
||||||
} else {
|
} else {
|
||||||
p = gins(arm.AMULLU, &n2, nil)
|
p = gins(arm.AMULLU, &n2, nil)
|
||||||
|
|
@ -532,13 +532,13 @@ func cgen_shift(op int, bounded bool, nl *gc.Node, nr *gc.Node, res *gc.Node) {
|
||||||
if sc == 0 {
|
if sc == 0 {
|
||||||
} else // nothing to do
|
} else // nothing to do
|
||||||
if sc >= uint64(nl.Type.Width*8) {
|
if sc >= uint64(nl.Type.Width*8) {
|
||||||
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] != 0 {
|
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] {
|
||||||
gshift(arm.AMOVW, &n1, arm.SHIFT_AR, int32(w), &n1)
|
gshift(arm.AMOVW, &n1, arm.SHIFT_AR, int32(w), &n1)
|
||||||
} else {
|
} else {
|
||||||
gins(arm.AEOR, &n1, &n1)
|
gins(arm.AEOR, &n1, &n1)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] != 0 {
|
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] {
|
||||||
gshift(arm.AMOVW, &n1, arm.SHIFT_AR, int32(sc), &n1)
|
gshift(arm.AMOVW, &n1, arm.SHIFT_AR, int32(sc), &n1)
|
||||||
} else if op == gc.ORSH {
|
} else if op == gc.ORSH {
|
||||||
gshift(arm.AMOVW, &n1, arm.SHIFT_LR, int32(sc), &n1) // OLSH
|
gshift(arm.AMOVW, &n1, arm.SHIFT_LR, int32(sc), &n1) // OLSH
|
||||||
|
|
@ -617,7 +617,7 @@ func cgen_shift(op int, bounded bool, nl *gc.Node, nr *gc.Node, res *gc.Node) {
|
||||||
if op == gc.ORSH {
|
if op == gc.ORSH {
|
||||||
var p1 *obj.Prog
|
var p1 *obj.Prog
|
||||||
var p2 *obj.Prog
|
var p2 *obj.Prog
|
||||||
if gc.Issigned[nl.Type.Etype] != 0 {
|
if gc.Issigned[nl.Type.Etype] {
|
||||||
p1 = gshift(arm.AMOVW, &n2, arm.SHIFT_AR, int32(w)-1, &n2)
|
p1 = gshift(arm.AMOVW, &n2, arm.SHIFT_AR, int32(w)-1, &n2)
|
||||||
p2 = gregshift(arm.AMOVW, &n2, arm.SHIFT_AR, &n1, &n2)
|
p2 = gregshift(arm.AMOVW, &n2, arm.SHIFT_AR, &n1, &n2)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ func gmove(f *gc.Node, t *gc.Node) {
|
||||||
tt := gc.Simsimtype(t.Type)
|
tt := gc.Simsimtype(t.Type)
|
||||||
cvt := t.Type
|
cvt := t.Type
|
||||||
|
|
||||||
if gc.Iscomplex[ft] != 0 || gc.Iscomplex[tt] != 0 {
|
if gc.Iscomplex[ft] || gc.Iscomplex[tt] {
|
||||||
gc.Complexmove(f, t)
|
gc.Complexmove(f, t)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ func cgen(n *gc.Node, res *gc.Node) {
|
||||||
f = 0
|
f = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if gc.Iscomplex[n.Type.Etype] == 0 {
|
if !gc.Iscomplex[n.Type.Etype] {
|
||||||
a := optoas(gc.OAS, res.Type)
|
a := optoas(gc.OAS, res.Type)
|
||||||
var addr obj.Addr
|
var addr obj.Addr
|
||||||
if sudoaddable(a, res, &addr) {
|
if sudoaddable(a, res, &addr) {
|
||||||
|
|
@ -202,7 +202,7 @@ func cgen(n *gc.Node, res *gc.Node) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if gc.Iscomplex[n.Type.Etype] == 0 {
|
if !gc.Iscomplex[n.Type.Etype] {
|
||||||
a := optoas(gc.OAS, n.Type)
|
a := optoas(gc.OAS, n.Type)
|
||||||
var addr obj.Addr
|
var addr obj.Addr
|
||||||
if sudoaddable(a, n, &addr) {
|
if sudoaddable(a, n, &addr) {
|
||||||
|
|
@ -269,7 +269,7 @@ func cgen(n *gc.Node, res *gc.Node) {
|
||||||
return
|
return
|
||||||
|
|
||||||
case gc.OMINUS:
|
case gc.OMINUS:
|
||||||
if gc.Isfloat[nl.Type.Etype] != 0 {
|
if gc.Isfloat[nl.Type.Etype] {
|
||||||
nr = gc.Nodintconst(-1)
|
nr = gc.Nodintconst(-1)
|
||||||
gc.Convlit(&nr, n.Type)
|
gc.Convlit(&nr, n.Type)
|
||||||
a = optoas(gc.OMUL, nl.Type)
|
a = optoas(gc.OMUL, nl.Type)
|
||||||
|
|
@ -489,7 +489,7 @@ func cgen(n *gc.Node, res *gc.Node) {
|
||||||
|
|
||||||
case gc.OMOD,
|
case gc.OMOD,
|
||||||
gc.ODIV:
|
gc.ODIV:
|
||||||
if gc.Isfloat[n.Type.Etype] != 0 {
|
if gc.Isfloat[n.Type.Etype] {
|
||||||
a = optoas(int(n.Op), nl.Type)
|
a = optoas(int(n.Op), nl.Type)
|
||||||
goto abop
|
goto abop
|
||||||
}
|
}
|
||||||
|
|
@ -777,7 +777,7 @@ func agenr(n *gc.Node, a *gc.Node, res *gc.Node) {
|
||||||
// type of the index
|
// type of the index
|
||||||
t := gc.Types[gc.TUINT64]
|
t := gc.Types[gc.TUINT64]
|
||||||
|
|
||||||
if gc.Issigned[n1.Type.Etype] != 0 {
|
if gc.Issigned[n1.Type.Etype] {
|
||||||
t = gc.Types[gc.TINT64]
|
t = gc.Types[gc.TINT64]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1053,10 +1053,10 @@ func igen(n *gc.Node, a *gc.Node, res *gc.Node) {
|
||||||
// Could do the same for slice except that we need
|
// Could do the same for slice except that we need
|
||||||
// to use the real index for the bounds checking.
|
// to use the real index for the bounds checking.
|
||||||
case gc.OINDEX:
|
case gc.OINDEX:
|
||||||
if gc.Isfixedarray(n.Left.Type) || (gc.Isptr[n.Left.Type.Etype] != 0 && gc.Isfixedarray(n.Left.Left.Type)) {
|
if gc.Isfixedarray(n.Left.Type) || (gc.Isptr[n.Left.Type.Etype] && gc.Isfixedarray(n.Left.Left.Type)) {
|
||||||
if gc.Isconst(n.Right, gc.CTINT) {
|
if gc.Isconst(n.Right, gc.CTINT) {
|
||||||
// Compute &a.
|
// Compute &a.
|
||||||
if gc.Isptr[n.Left.Type.Etype] == 0 {
|
if !gc.Isptr[n.Left.Type.Etype] {
|
||||||
igen(n.Left, a, res)
|
igen(n.Left, a, res)
|
||||||
} else {
|
} else {
|
||||||
var n1 gc.Node
|
var n1 gc.Node
|
||||||
|
|
@ -1200,7 +1200,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
|
||||||
gc.OGE:
|
gc.OGE:
|
||||||
a := int(n.Op)
|
a := int(n.Op)
|
||||||
if !true_ {
|
if !true_ {
|
||||||
if gc.Isfloat[nr.Type.Etype] != 0 {
|
if gc.Isfloat[nr.Type.Etype] {
|
||||||
// brcom is not valid on floats when NaN is involved.
|
// brcom is not valid on floats when NaN is involved.
|
||||||
p1 := gc.Gbranch(obj.AJMP, nil, 0)
|
p1 := gc.Gbranch(obj.AJMP, nil, 0)
|
||||||
|
|
||||||
|
|
@ -1266,7 +1266,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if gc.Iscomplex[nl.Type.Etype] != 0 {
|
if gc.Iscomplex[nl.Type.Etype] {
|
||||||
gc.Complexbool(a, nl, nr, true_, likely, to)
|
gc.Complexbool(a, nl, nr, true_, likely, to)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
@ -1309,7 +1309,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
|
||||||
l := &n1
|
l := &n1
|
||||||
|
|
||||||
r := &n2
|
r := &n2
|
||||||
if gc.Isfloat[nl.Type.Etype] != 0 && (a == gc.OGT || a == gc.OGE) {
|
if gc.Isfloat[nl.Type.Etype] && (a == gc.OGT || a == gc.OGE) {
|
||||||
l = &n2
|
l = &n2
|
||||||
r = &n1
|
r = &n1
|
||||||
a = gc.Brrev(a)
|
a = gc.Brrev(a)
|
||||||
|
|
@ -1317,7 +1317,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
|
||||||
|
|
||||||
gins(optoas(gc.OCMP, nr.Type), l, r)
|
gins(optoas(gc.OCMP, nr.Type), l, r)
|
||||||
|
|
||||||
if gc.Isfloat[nr.Type.Etype] != 0 && (n.Op == gc.OEQ || n.Op == gc.ONE) {
|
if gc.Isfloat[nr.Type.Etype] && (n.Op == gc.OEQ || n.Op == gc.ONE) {
|
||||||
if n.Op == gc.OEQ {
|
if n.Op == gc.OEQ {
|
||||||
// neither NE nor P
|
// neither NE nor P
|
||||||
p1 := gc.Gbranch(x86.AJNE, nil, -likely)
|
p1 := gc.Gbranch(x86.AJNE, nil, -likely)
|
||||||
|
|
@ -1369,7 +1369,7 @@ func stkof(n *gc.Node) int64 {
|
||||||
|
|
||||||
case gc.ODOT:
|
case gc.ODOT:
|
||||||
t := n.Left.Type
|
t := n.Left.Type
|
||||||
if gc.Isptr[t.Etype] != 0 {
|
if gc.Isptr[t.Etype] {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
off := stkof(n.Left)
|
off := stkof(n.Left)
|
||||||
|
|
@ -1396,7 +1396,7 @@ func stkof(n *gc.Node) int64 {
|
||||||
gc.OCALLINTER,
|
gc.OCALLINTER,
|
||||||
gc.OCALLFUNC:
|
gc.OCALLFUNC:
|
||||||
t := n.Left.Type
|
t := n.Left.Type
|
||||||
if gc.Isptr[t.Etype] != 0 {
|
if gc.Isptr[t.Etype] {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -387,7 +387,7 @@ func cgen_callret(n *gc.Node, res *gc.Node) {
|
||||||
*/
|
*/
|
||||||
func cgen_aret(n *gc.Node, res *gc.Node) {
|
func cgen_aret(n *gc.Node, res *gc.Node) {
|
||||||
t := n.Left.Type
|
t := n.Left.Type
|
||||||
if gc.Isptr[t.Etype] != 0 {
|
if gc.Isptr[t.Etype] {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -456,7 +456,7 @@ func dodiv(op int, nl *gc.Node, nr *gc.Node, res *gc.Node) {
|
||||||
|
|
||||||
t0 := t
|
t0 := t
|
||||||
check := 0
|
check := 0
|
||||||
if gc.Issigned[t.Etype] != 0 {
|
if gc.Issigned[t.Etype] {
|
||||||
check = 1
|
check = 1
|
||||||
if gc.Isconst(nl, gc.CTINT) && gc.Mpgetfix(nl.Val.U.Xval) != -(1<<uint64(t.Width*8-1)) {
|
if gc.Isconst(nl, gc.CTINT) && gc.Mpgetfix(nl.Val.U.Xval) != -(1<<uint64(t.Width*8-1)) {
|
||||||
check = 0
|
check = 0
|
||||||
|
|
@ -466,7 +466,7 @@ func dodiv(op int, nl *gc.Node, nr *gc.Node, res *gc.Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.Width < 4 {
|
if t.Width < 4 {
|
||||||
if gc.Issigned[t.Etype] != 0 {
|
if gc.Issigned[t.Etype] {
|
||||||
t = gc.Types[gc.TINT32]
|
t = gc.Types[gc.TINT32]
|
||||||
} else {
|
} else {
|
||||||
t = gc.Types[gc.TUINT32]
|
t = gc.Types[gc.TUINT32]
|
||||||
|
|
@ -543,7 +543,7 @@ func dodiv(op int, nl *gc.Node, nr *gc.Node, res *gc.Node) {
|
||||||
var olddx gc.Node
|
var olddx gc.Node
|
||||||
var dx gc.Node
|
var dx gc.Node
|
||||||
savex(x86.REG_DX, &dx, &olddx, res, t)
|
savex(x86.REG_DX, &dx, &olddx, res, t)
|
||||||
if gc.Issigned[t.Etype] == 0 {
|
if !gc.Issigned[t.Etype] {
|
||||||
gc.Nodconst(&n4, t, 0)
|
gc.Nodconst(&n4, t, 0)
|
||||||
gmove(&n4, &dx)
|
gmove(&n4, &dx)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -873,7 +873,7 @@ func cgen_shift(op int, bounded bool, nl *gc.Node, nr *gc.Node, res *gc.Node) {
|
||||||
gc.Nodconst(&n3, tcount, nl.Type.Width*8)
|
gc.Nodconst(&n3, tcount, nl.Type.Width*8)
|
||||||
gins(optoas(gc.OCMP, tcount), &n1, &n3)
|
gins(optoas(gc.OCMP, tcount), &n1, &n3)
|
||||||
p1 := gc.Gbranch(optoas(gc.OLT, tcount), nil, +1)
|
p1 := gc.Gbranch(optoas(gc.OLT, tcount), nil, +1)
|
||||||
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] != 0 {
|
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] {
|
||||||
gc.Nodconst(&n3, gc.Types[gc.TUINT32], nl.Type.Width*8-1)
|
gc.Nodconst(&n3, gc.Types[gc.TUINT32], nl.Type.Width*8-1)
|
||||||
gins(a, &n3, &n2)
|
gins(a, &n3, &n2)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -924,7 +924,7 @@ func cgen_bmul(op int, nl *gc.Node, nr *gc.Node, res *gc.Node) {
|
||||||
// perform full-width multiplication.
|
// perform full-width multiplication.
|
||||||
t := gc.Types[gc.TUINT64]
|
t := gc.Types[gc.TUINT64]
|
||||||
|
|
||||||
if gc.Issigned[nl.Type.Etype] != 0 {
|
if gc.Issigned[nl.Type.Etype] {
|
||||||
t = gc.Types[gc.TINT64]
|
t = gc.Types[gc.TINT64]
|
||||||
}
|
}
|
||||||
var n1 gc.Node
|
var n1 gc.Node
|
||||||
|
|
|
||||||
|
|
@ -308,7 +308,7 @@ func gmove(f *gc.Node, t *gc.Node) {
|
||||||
tt := gc.Simsimtype(t.Type)
|
tt := gc.Simsimtype(t.Type)
|
||||||
cvt := t.Type
|
cvt := t.Type
|
||||||
|
|
||||||
if gc.Iscomplex[ft] != 0 || gc.Iscomplex[tt] != 0 {
|
if gc.Iscomplex[ft] || gc.Iscomplex[tt] {
|
||||||
gc.Complexmove(f, t)
|
gc.Complexmove(f, t)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -330,13 +330,13 @@ func gmove(f *gc.Node, t *gc.Node) {
|
||||||
// some constants can't move directly to memory.
|
// some constants can't move directly to memory.
|
||||||
if gc.Ismem(t) {
|
if gc.Ismem(t) {
|
||||||
// float constants come from memory.
|
// float constants come from memory.
|
||||||
if gc.Isfloat[tt] != 0 {
|
if gc.Isfloat[tt] {
|
||||||
goto hard
|
goto hard
|
||||||
}
|
}
|
||||||
|
|
||||||
// 64-bit immediates are really 32-bit sign-extended
|
// 64-bit immediates are really 32-bit sign-extended
|
||||||
// unless moving into a register.
|
// unless moving into a register.
|
||||||
if gc.Isint[tt] != 0 {
|
if gc.Isint[tt] {
|
||||||
if gc.Mpcmpfixfix(con.Val.U.Xval, gc.Minintval[gc.TINT32]) < 0 {
|
if gc.Mpcmpfixfix(con.Val.U.Xval, gc.Minintval[gc.TINT32]) < 0 {
|
||||||
goto hard
|
goto hard
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ func mgen(n *gc.Node, n1 *gc.Node, rg *gc.Node) {
|
||||||
|
|
||||||
gc.Tempname(n1, n.Type)
|
gc.Tempname(n1, n.Type)
|
||||||
cgen(n, n1)
|
cgen(n, n1)
|
||||||
if n.Type.Width <= int64(gc.Widthptr) || gc.Isfloat[n.Type.Etype] != 0 {
|
if n.Type.Width <= int64(gc.Widthptr) || gc.Isfloat[n.Type.Etype] {
|
||||||
n2 := *n1
|
n2 := *n1
|
||||||
regalloc(n1, n.Type, rg)
|
regalloc(n1, n.Type, rg)
|
||||||
gmove(&n2, n1)
|
gmove(&n2, n1)
|
||||||
|
|
@ -210,7 +210,7 @@ func cgen(n *gc.Node, res *gc.Node) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if nl != nil && gc.Isfloat[n.Type.Etype] != 0 && gc.Isfloat[nl.Type.Etype] != 0 {
|
if nl != nil && gc.Isfloat[n.Type.Etype] && gc.Isfloat[nl.Type.Etype] {
|
||||||
cgen_float(n, res)
|
cgen_float(n, res)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -712,7 +712,7 @@ func agen(n *gc.Node, res *gc.Node) {
|
||||||
// i is in register n1, extend to 32 bits.
|
// i is in register n1, extend to 32 bits.
|
||||||
t := gc.Types[gc.TUINT32]
|
t := gc.Types[gc.TUINT32]
|
||||||
|
|
||||||
if gc.Issigned[n1.Type.Etype] != 0 {
|
if gc.Issigned[n1.Type.Etype] {
|
||||||
t = gc.Types[gc.TINT32]
|
t = gc.Types[gc.TINT32]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -820,7 +820,7 @@ func agen(n *gc.Node, res *gc.Node) {
|
||||||
|
|
||||||
case gc.ODOTPTR:
|
case gc.ODOTPTR:
|
||||||
t := nl.Type
|
t := nl.Type
|
||||||
if gc.Isptr[t.Etype] == 0 {
|
if !gc.Isptr[t.Etype] {
|
||||||
gc.Fatal("agen: not ptr %v", gc.Nconv(n, 0))
|
gc.Fatal("agen: not ptr %v", gc.Nconv(n, 0))
|
||||||
}
|
}
|
||||||
cgen(nl, res)
|
cgen(nl, res)
|
||||||
|
|
@ -925,10 +925,10 @@ func igen(n *gc.Node, a *gc.Node, res *gc.Node) {
|
||||||
// Could do the same for slice except that we need
|
// Could do the same for slice except that we need
|
||||||
// to use the real index for the bounds checking.
|
// to use the real index for the bounds checking.
|
||||||
case gc.OINDEX:
|
case gc.OINDEX:
|
||||||
if gc.Isfixedarray(n.Left.Type) || (gc.Isptr[n.Left.Type.Etype] != 0 && gc.Isfixedarray(n.Left.Left.Type)) {
|
if gc.Isfixedarray(n.Left.Type) || (gc.Isptr[n.Left.Type.Etype] && gc.Isfixedarray(n.Left.Left.Type)) {
|
||||||
if gc.Isconst(n.Right, gc.CTINT) {
|
if gc.Isconst(n.Right, gc.CTINT) {
|
||||||
// Compute &a.
|
// Compute &a.
|
||||||
if gc.Isptr[n.Left.Type.Etype] == 0 {
|
if !gc.Isptr[n.Left.Type.Etype] {
|
||||||
igen(n.Left, a, res)
|
igen(n.Left, a, res)
|
||||||
} else {
|
} else {
|
||||||
var n1 gc.Node
|
var n1 gc.Node
|
||||||
|
|
@ -1007,7 +1007,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
|
||||||
nl := n.Left
|
nl := n.Left
|
||||||
nr := (*gc.Node)(nil)
|
nr := (*gc.Node)(nil)
|
||||||
|
|
||||||
if nl != nil && gc.Isfloat[nl.Type.Etype] != 0 {
|
if nl != nil && gc.Isfloat[nl.Type.Etype] {
|
||||||
bgen_float(n, bool2int(true_), likely, to)
|
bgen_float(n, bool2int(true_), likely, to)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -1138,7 +1138,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if gc.Iscomplex[nl.Type.Etype] != 0 {
|
if gc.Iscomplex[nl.Type.Etype] {
|
||||||
gc.Complexbool(a, nl, nr, true_, likely, to)
|
gc.Complexbool(a, nl, nr, true_, likely, to)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
@ -1249,7 +1249,7 @@ func stkof(n *gc.Node) int32 {
|
||||||
|
|
||||||
case gc.ODOT:
|
case gc.ODOT:
|
||||||
t := n.Left.Type
|
t := n.Left.Type
|
||||||
if gc.Isptr[t.Etype] != 0 {
|
if gc.Isptr[t.Etype] {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
off := stkof(n.Left)
|
off := stkof(n.Left)
|
||||||
|
|
@ -1276,7 +1276,7 @@ func stkof(n *gc.Node) int32 {
|
||||||
gc.OCALLINTER,
|
gc.OCALLINTER,
|
||||||
gc.OCALLFUNC:
|
gc.OCALLFUNC:
|
||||||
t := n.Left.Type
|
t := n.Left.Type
|
||||||
if gc.Isptr[t.Etype] != 0 {
|
if gc.Isptr[t.Etype] {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -446,7 +446,7 @@ func cgen_callret(n *gc.Node, res *gc.Node) {
|
||||||
*/
|
*/
|
||||||
func cgen_aret(n *gc.Node, res *gc.Node) {
|
func cgen_aret(n *gc.Node, res *gc.Node) {
|
||||||
t := n.Left.Type
|
t := n.Left.Type
|
||||||
if gc.Isptr[t.Etype] != 0 {
|
if gc.Isptr[t.Etype] {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -518,7 +518,7 @@ func dodiv(op int, nl *gc.Node, nr *gc.Node, res *gc.Node, ax *gc.Node, dx *gc.N
|
||||||
|
|
||||||
t0 := t
|
t0 := t
|
||||||
check := 0
|
check := 0
|
||||||
if gc.Issigned[t.Etype] != 0 {
|
if gc.Issigned[t.Etype] {
|
||||||
check = 1
|
check = 1
|
||||||
if gc.Isconst(nl, gc.CTINT) && gc.Mpgetfix(nl.Val.U.Xval) != -1<<uint64(t.Width*8-1) {
|
if gc.Isconst(nl, gc.CTINT) && gc.Mpgetfix(nl.Val.U.Xval) != -1<<uint64(t.Width*8-1) {
|
||||||
check = 0
|
check = 0
|
||||||
|
|
@ -528,7 +528,7 @@ func dodiv(op int, nl *gc.Node, nr *gc.Node, res *gc.Node, ax *gc.Node, dx *gc.N
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.Width < 4 {
|
if t.Width < 4 {
|
||||||
if gc.Issigned[t.Etype] != 0 {
|
if gc.Issigned[t.Etype] {
|
||||||
t = gc.Types[gc.TINT32]
|
t = gc.Types[gc.TINT32]
|
||||||
} else {
|
} else {
|
||||||
t = gc.Types[gc.TUINT32]
|
t = gc.Types[gc.TUINT32]
|
||||||
|
|
@ -602,7 +602,7 @@ func dodiv(op int, nl *gc.Node, nr *gc.Node, res *gc.Node, ax *gc.Node, dx *gc.N
|
||||||
gc.Patch(p1, gc.Pc)
|
gc.Patch(p1, gc.Pc)
|
||||||
}
|
}
|
||||||
|
|
||||||
if gc.Issigned[t.Etype] == 0 {
|
if !gc.Issigned[t.Etype] {
|
||||||
var nz gc.Node
|
var nz gc.Node
|
||||||
gc.Nodconst(&nz, t, 0)
|
gc.Nodconst(&nz, t, 0)
|
||||||
gmove(&nz, dx)
|
gmove(&nz, dx)
|
||||||
|
|
@ -658,7 +658,7 @@ func cgen_div(op int, nl *gc.Node, nr *gc.Node, res *gc.Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var t *gc.Type
|
var t *gc.Type
|
||||||
if gc.Issigned[nl.Type.Etype] != 0 {
|
if gc.Issigned[nl.Type.Etype] {
|
||||||
t = gc.Types[gc.TINT32]
|
t = gc.Types[gc.TINT32]
|
||||||
} else {
|
} else {
|
||||||
t = gc.Types[gc.TUINT32]
|
t = gc.Types[gc.TUINT32]
|
||||||
|
|
@ -776,7 +776,7 @@ func cgen_shift(op int, bounded bool, nl *gc.Node, nr *gc.Node, res *gc.Node) {
|
||||||
p1 = gc.Gbranch(optoas(gc.OLT, gc.Types[gc.TUINT32]), nil, +1)
|
p1 = gc.Gbranch(optoas(gc.OLT, gc.Types[gc.TUINT32]), nil, +1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] != 0 {
|
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] {
|
||||||
gins(a, ncon(uint32(w)-1), &n2)
|
gins(a, ncon(uint32(w)-1), &n2)
|
||||||
} else {
|
} else {
|
||||||
gmove(ncon(0), &n2)
|
gmove(ncon(0), &n2)
|
||||||
|
|
@ -807,7 +807,7 @@ func cgen_bmul(op int, nl *gc.Node, nr *gc.Node, res *gc.Node) {
|
||||||
// copy from byte to full registers
|
// copy from byte to full registers
|
||||||
t := gc.Types[gc.TUINT32]
|
t := gc.Types[gc.TUINT32]
|
||||||
|
|
||||||
if gc.Issigned[nl.Type.Etype] != 0 {
|
if gc.Issigned[nl.Type.Etype] {
|
||||||
t = gc.Types[gc.TINT32]
|
t = gc.Types[gc.TINT32]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -890,12 +890,12 @@ func gmove(f *gc.Node, t *gc.Node) {
|
||||||
tt := gc.Simsimtype(t.Type)
|
tt := gc.Simsimtype(t.Type)
|
||||||
cvt := t.Type
|
cvt := t.Type
|
||||||
|
|
||||||
if gc.Iscomplex[ft] != 0 || gc.Iscomplex[tt] != 0 {
|
if gc.Iscomplex[ft] || gc.Iscomplex[tt] {
|
||||||
gc.Complexmove(f, t)
|
gc.Complexmove(f, t)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if gc.Isfloat[ft] != 0 || gc.Isfloat[tt] != 0 {
|
if gc.Isfloat[ft] || gc.Isfloat[tt] {
|
||||||
floatmove(f, t)
|
floatmove(f, t)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -904,7 +904,7 @@ func gmove(f *gc.Node, t *gc.Node) {
|
||||||
// except 64-bit, which always copies via registers anyway.
|
// except 64-bit, which always copies via registers anyway.
|
||||||
var r1 gc.Node
|
var r1 gc.Node
|
||||||
var a int
|
var a int
|
||||||
if gc.Isint[ft] != 0 && gc.Isint[tt] != 0 && !gc.Is64(f.Type) && !gc.Is64(t.Type) && gc.Ismem(f) && gc.Ismem(t) {
|
if gc.Isint[ft] && gc.Isint[tt] && !gc.Is64(f.Type) && !gc.Is64(t.Type) && gc.Ismem(f) && gc.Ismem(t) {
|
||||||
goto hard
|
goto hard
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1173,7 +1173,7 @@ func floatmove(f *gc.Node, t *gc.Node) {
|
||||||
cvt := t.Type
|
cvt := t.Type
|
||||||
|
|
||||||
// cannot have two floating point memory operands.
|
// cannot have two floating point memory operands.
|
||||||
if gc.Isfloat[ft] != 0 && gc.Isfloat[tt] != 0 && gc.Ismem(f) && gc.Ismem(t) {
|
if gc.Isfloat[ft] && gc.Isfloat[tt] && gc.Ismem(f) && gc.Ismem(t) {
|
||||||
goto hard
|
goto hard
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1187,7 +1187,7 @@ func floatmove(f *gc.Node, t *gc.Node) {
|
||||||
// some constants can't move directly to memory.
|
// some constants can't move directly to memory.
|
||||||
if gc.Ismem(t) {
|
if gc.Ismem(t) {
|
||||||
// float constants come from memory.
|
// float constants come from memory.
|
||||||
if gc.Isfloat[tt] != 0 {
|
if gc.Isfloat[tt] {
|
||||||
goto hard
|
goto hard
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ func cgen(n *gc.Node, res *gc.Node) {
|
||||||
f = 0
|
f = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if gc.Iscomplex[n.Type.Etype] == 0 {
|
if !gc.Iscomplex[n.Type.Etype] {
|
||||||
a := optoas(gc.OAS, res.Type)
|
a := optoas(gc.OAS, res.Type)
|
||||||
var addr obj.Addr
|
var addr obj.Addr
|
||||||
if sudoaddable(a, res, &addr) {
|
if sudoaddable(a, res, &addr) {
|
||||||
|
|
@ -209,7 +209,7 @@ func cgen(n *gc.Node, res *gc.Node) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if gc.Iscomplex[n.Type.Etype] == 0 {
|
if !gc.Iscomplex[n.Type.Etype] {
|
||||||
a := optoas(gc.OAS, n.Type)
|
a := optoas(gc.OAS, n.Type)
|
||||||
var addr obj.Addr
|
var addr obj.Addr
|
||||||
if sudoaddable(a, n, &addr) {
|
if sudoaddable(a, n, &addr) {
|
||||||
|
|
@ -280,7 +280,7 @@ func cgen(n *gc.Node, res *gc.Node) {
|
||||||
return
|
return
|
||||||
|
|
||||||
case gc.OMINUS:
|
case gc.OMINUS:
|
||||||
if gc.Isfloat[nl.Type.Etype] != 0 {
|
if gc.Isfloat[nl.Type.Etype] {
|
||||||
nr = gc.Nodintconst(-1)
|
nr = gc.Nodintconst(-1)
|
||||||
gc.Convlit(&nr, n.Type)
|
gc.Convlit(&nr, n.Type)
|
||||||
a = optoas(gc.OMUL, nl.Type)
|
a = optoas(gc.OMUL, nl.Type)
|
||||||
|
|
@ -495,7 +495,7 @@ func cgen(n *gc.Node, res *gc.Node) {
|
||||||
|
|
||||||
case gc.OMOD,
|
case gc.OMOD,
|
||||||
gc.ODIV:
|
gc.ODIV:
|
||||||
if gc.Isfloat[n.Type.Etype] != 0 {
|
if gc.Isfloat[n.Type.Etype] {
|
||||||
a = optoas(int(n.Op), nl.Type)
|
a = optoas(int(n.Op), nl.Type)
|
||||||
goto abop
|
goto abop
|
||||||
}
|
}
|
||||||
|
|
@ -1071,10 +1071,10 @@ func igen(n *gc.Node, a *gc.Node, res *gc.Node) {
|
||||||
// Could do the same for slice except that we need
|
// Could do the same for slice except that we need
|
||||||
// to use the real index for the bounds checking.
|
// to use the real index for the bounds checking.
|
||||||
case gc.OINDEX:
|
case gc.OINDEX:
|
||||||
if gc.Isfixedarray(n.Left.Type) || (gc.Isptr[n.Left.Type.Etype] != 0 && gc.Isfixedarray(n.Left.Left.Type)) {
|
if gc.Isfixedarray(n.Left.Type) || (gc.Isptr[n.Left.Type.Etype] && gc.Isfixedarray(n.Left.Left.Type)) {
|
||||||
if gc.Isconst(n.Right, gc.CTINT) {
|
if gc.Isconst(n.Right, gc.CTINT) {
|
||||||
// Compute &a.
|
// Compute &a.
|
||||||
if gc.Isptr[n.Left.Type.Etype] == 0 {
|
if !gc.Isptr[n.Left.Type.Etype] {
|
||||||
igen(n.Left, a, res)
|
igen(n.Left, a, res)
|
||||||
} else {
|
} else {
|
||||||
var n1 gc.Node
|
var n1 gc.Node
|
||||||
|
|
@ -1216,7 +1216,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
|
||||||
gc.OGE:
|
gc.OGE:
|
||||||
a := int(n.Op)
|
a := int(n.Op)
|
||||||
if !true_ {
|
if !true_ {
|
||||||
if gc.Isfloat[nr.Type.Etype] != 0 {
|
if gc.Isfloat[nr.Type.Etype] {
|
||||||
// brcom is not valid on floats when NaN is involved.
|
// brcom is not valid on floats when NaN is involved.
|
||||||
p1 := gc.Gbranch(ppc64.ABR, nil, 0)
|
p1 := gc.Gbranch(ppc64.ABR, nil, 0)
|
||||||
|
|
||||||
|
|
@ -1290,7 +1290,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if gc.Iscomplex[nl.Type.Etype] != 0 {
|
if gc.Iscomplex[nl.Type.Etype] {
|
||||||
gc.Complexbool(a, nl, nr, true_, likely, to)
|
gc.Complexbool(a, nl, nr, true_, likely, to)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
@ -1335,7 +1335,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
|
||||||
l := &n1
|
l := &n1
|
||||||
r := &n2
|
r := &n2
|
||||||
gins(optoas(gc.OCMP, nr.Type), l, r)
|
gins(optoas(gc.OCMP, nr.Type), l, r)
|
||||||
if gc.Isfloat[nr.Type.Etype] != 0 && (a == gc.OLE || a == gc.OGE) {
|
if gc.Isfloat[nr.Type.Etype] && (a == gc.OLE || a == gc.OGE) {
|
||||||
// To get NaN right, must rewrite x <= y into separate x < y or x = y.
|
// To get NaN right, must rewrite x <= y into separate x < y or x = y.
|
||||||
switch a {
|
switch a {
|
||||||
case gc.OLE:
|
case gc.OLE:
|
||||||
|
|
@ -1370,7 +1370,7 @@ func stkof(n *gc.Node) int64 {
|
||||||
|
|
||||||
case gc.ODOT:
|
case gc.ODOT:
|
||||||
t := n.Left.Type
|
t := n.Left.Type
|
||||||
if gc.Isptr[t.Etype] != 0 {
|
if gc.Isptr[t.Etype] {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
off := stkof(n.Left)
|
off := stkof(n.Left)
|
||||||
|
|
@ -1397,7 +1397,7 @@ func stkof(n *gc.Node) int64 {
|
||||||
gc.OCALLINTER,
|
gc.OCALLINTER,
|
||||||
gc.OCALLFUNC:
|
gc.OCALLFUNC:
|
||||||
t := n.Left.Type
|
t := n.Left.Type
|
||||||
if gc.Isptr[t.Etype] != 0 {
|
if gc.Isptr[t.Etype] {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -391,7 +391,7 @@ func cgen_callret(n *gc.Node, res *gc.Node) {
|
||||||
*/
|
*/
|
||||||
func cgen_aret(n *gc.Node, res *gc.Node) {
|
func cgen_aret(n *gc.Node, res *gc.Node) {
|
||||||
t := n.Left.Type
|
t := n.Left.Type
|
||||||
if gc.Isptr[t.Etype] != 0 {
|
if gc.Isptr[t.Etype] {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -459,7 +459,7 @@ func dodiv(op int, nl *gc.Node, nr *gc.Node, res *gc.Node) {
|
||||||
|
|
||||||
t0 := t
|
t0 := t
|
||||||
check := 0
|
check := 0
|
||||||
if gc.Issigned[t.Etype] != 0 {
|
if gc.Issigned[t.Etype] {
|
||||||
check = 1
|
check = 1
|
||||||
if gc.Isconst(nl, gc.CTINT) && gc.Mpgetfix(nl.Val.U.Xval) != -(1<<uint64(t.Width*8-1)) {
|
if gc.Isconst(nl, gc.CTINT) && gc.Mpgetfix(nl.Val.U.Xval) != -(1<<uint64(t.Width*8-1)) {
|
||||||
check = 0
|
check = 0
|
||||||
|
|
@ -469,7 +469,7 @@ func dodiv(op int, nl *gc.Node, nr *gc.Node, res *gc.Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.Width < 8 {
|
if t.Width < 8 {
|
||||||
if gc.Issigned[t.Etype] != 0 {
|
if gc.Issigned[t.Etype] {
|
||||||
t = gc.Types[gc.TINT64]
|
t = gc.Types[gc.TINT64]
|
||||||
} else {
|
} else {
|
||||||
t = gc.Types[gc.TUINT64]
|
t = gc.Types[gc.TUINT64]
|
||||||
|
|
@ -615,7 +615,7 @@ func cgen_hmul(nl *gc.Node, nr *gc.Node, res *gc.Node) {
|
||||||
|
|
||||||
case gc.TINT64,
|
case gc.TINT64,
|
||||||
gc.TUINT64:
|
gc.TUINT64:
|
||||||
if gc.Issigned[t.Etype] != 0 {
|
if gc.Issigned[t.Etype] {
|
||||||
gins(ppc64.AMULHD, &n2, &n1)
|
gins(ppc64.AMULHD, &n2, &n1)
|
||||||
} else {
|
} else {
|
||||||
gins(ppc64.AMULHDU, &n2, &n1)
|
gins(ppc64.AMULHDU, &n2, &n1)
|
||||||
|
|
@ -706,7 +706,7 @@ func cgen_shift(op int, bounded bool, nl *gc.Node, nr *gc.Node, res *gc.Node) {
|
||||||
gc.Nodconst(&n3, tcount, nl.Type.Width*8)
|
gc.Nodconst(&n3, tcount, nl.Type.Width*8)
|
||||||
gins(optoas(gc.OCMP, tcount), &n1, &n3)
|
gins(optoas(gc.OCMP, tcount), &n1, &n3)
|
||||||
p1 := (*obj.Prog)(gc.Gbranch(optoas(gc.OLT, tcount), nil, +1))
|
p1 := (*obj.Prog)(gc.Gbranch(optoas(gc.OLT, tcount), nil, +1))
|
||||||
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] != 0 {
|
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] {
|
||||||
gc.Nodconst(&n3, gc.Types[gc.TUINT32], nl.Type.Width*8-1)
|
gc.Nodconst(&n3, gc.Types[gc.TUINT32], nl.Type.Width*8-1)
|
||||||
gins(a, &n3, &n2)
|
gins(a, &n3, &n2)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,7 @@ func gmove(f *gc.Node, t *gc.Node) {
|
||||||
tt := int(gc.Simsimtype(t.Type))
|
tt := int(gc.Simsimtype(t.Type))
|
||||||
cvt := (*gc.Type)(t.Type)
|
cvt := (*gc.Type)(t.Type)
|
||||||
|
|
||||||
if gc.Iscomplex[ft] != 0 || gc.Iscomplex[tt] != 0 {
|
if gc.Iscomplex[ft] || gc.Iscomplex[tt] {
|
||||||
gc.Complexmove(f, t)
|
gc.Complexmove(f, t)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -450,95 +450,95 @@ func typeinit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := TINT8; i <= TUINT64; i++ {
|
for i := TINT8; i <= TUINT64; i++ {
|
||||||
Isint[i] = 1
|
Isint[i] = true
|
||||||
}
|
}
|
||||||
Isint[TINT] = 1
|
Isint[TINT] = true
|
||||||
Isint[TUINT] = 1
|
Isint[TUINT] = true
|
||||||
Isint[TUINTPTR] = 1
|
Isint[TUINTPTR] = true
|
||||||
|
|
||||||
Isfloat[TFLOAT32] = 1
|
Isfloat[TFLOAT32] = true
|
||||||
Isfloat[TFLOAT64] = 1
|
Isfloat[TFLOAT64] = true
|
||||||
|
|
||||||
Iscomplex[TCOMPLEX64] = 1
|
Iscomplex[TCOMPLEX64] = true
|
||||||
Iscomplex[TCOMPLEX128] = 1
|
Iscomplex[TCOMPLEX128] = true
|
||||||
|
|
||||||
Isptr[TPTR32] = 1
|
Isptr[TPTR32] = true
|
||||||
Isptr[TPTR64] = 1
|
Isptr[TPTR64] = true
|
||||||
|
|
||||||
isforw[TFORW] = 1
|
isforw[TFORW] = true
|
||||||
|
|
||||||
Issigned[TINT] = 1
|
Issigned[TINT] = true
|
||||||
Issigned[TINT8] = 1
|
Issigned[TINT8] = true
|
||||||
Issigned[TINT16] = 1
|
Issigned[TINT16] = true
|
||||||
Issigned[TINT32] = 1
|
Issigned[TINT32] = true
|
||||||
Issigned[TINT64] = 1
|
Issigned[TINT64] = true
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initialize okfor
|
* initialize okfor
|
||||||
*/
|
*/
|
||||||
for i := 0; i < NTYPE; i++ {
|
for i := 0; i < NTYPE; i++ {
|
||||||
if Isint[i] != 0 || i == TIDEAL {
|
if Isint[i] || i == TIDEAL {
|
||||||
okforeq[i] = 1
|
okforeq[i] = true
|
||||||
okforcmp[i] = 1
|
okforcmp[i] = true
|
||||||
okforarith[i] = 1
|
okforarith[i] = true
|
||||||
okforadd[i] = 1
|
okforadd[i] = true
|
||||||
okforand[i] = 1
|
okforand[i] = true
|
||||||
okforconst[i] = 1
|
okforconst[i] = true
|
||||||
issimple[i] = 1
|
issimple[i] = true
|
||||||
Minintval[i] = new(Mpint)
|
Minintval[i] = new(Mpint)
|
||||||
Maxintval[i] = new(Mpint)
|
Maxintval[i] = new(Mpint)
|
||||||
}
|
}
|
||||||
|
|
||||||
if Isfloat[i] != 0 {
|
if Isfloat[i] {
|
||||||
okforeq[i] = 1
|
okforeq[i] = true
|
||||||
okforcmp[i] = 1
|
okforcmp[i] = true
|
||||||
okforadd[i] = 1
|
okforadd[i] = true
|
||||||
okforarith[i] = 1
|
okforarith[i] = true
|
||||||
okforconst[i] = 1
|
okforconst[i] = true
|
||||||
issimple[i] = 1
|
issimple[i] = true
|
||||||
minfltval[i] = new(Mpflt)
|
minfltval[i] = new(Mpflt)
|
||||||
maxfltval[i] = new(Mpflt)
|
maxfltval[i] = new(Mpflt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if Iscomplex[i] != 0 {
|
if Iscomplex[i] {
|
||||||
okforeq[i] = 1
|
okforeq[i] = true
|
||||||
okforadd[i] = 1
|
okforadd[i] = true
|
||||||
okforarith[i] = 1
|
okforarith[i] = true
|
||||||
okforconst[i] = 1
|
okforconst[i] = true
|
||||||
issimple[i] = 1
|
issimple[i] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
issimple[TBOOL] = 1
|
issimple[TBOOL] = true
|
||||||
|
|
||||||
okforadd[TSTRING] = 1
|
okforadd[TSTRING] = true
|
||||||
|
|
||||||
okforbool[TBOOL] = 1
|
okforbool[TBOOL] = true
|
||||||
|
|
||||||
okforcap[TARRAY] = 1
|
okforcap[TARRAY] = true
|
||||||
okforcap[TCHAN] = 1
|
okforcap[TCHAN] = true
|
||||||
|
|
||||||
okforconst[TBOOL] = 1
|
okforconst[TBOOL] = true
|
||||||
okforconst[TSTRING] = 1
|
okforconst[TSTRING] = true
|
||||||
|
|
||||||
okforlen[TARRAY] = 1
|
okforlen[TARRAY] = true
|
||||||
okforlen[TCHAN] = 1
|
okforlen[TCHAN] = true
|
||||||
okforlen[TMAP] = 1
|
okforlen[TMAP] = true
|
||||||
okforlen[TSTRING] = 1
|
okforlen[TSTRING] = true
|
||||||
|
|
||||||
okforeq[TPTR32] = 1
|
okforeq[TPTR32] = true
|
||||||
okforeq[TPTR64] = 1
|
okforeq[TPTR64] = true
|
||||||
okforeq[TUNSAFEPTR] = 1
|
okforeq[TUNSAFEPTR] = true
|
||||||
okforeq[TINTER] = 1
|
okforeq[TINTER] = true
|
||||||
okforeq[TCHAN] = 1
|
okforeq[TCHAN] = true
|
||||||
okforeq[TSTRING] = 1
|
okforeq[TSTRING] = true
|
||||||
okforeq[TBOOL] = 1
|
okforeq[TBOOL] = true
|
||||||
okforeq[TMAP] = 1 // nil only; refined in typecheck
|
okforeq[TMAP] = true // nil only; refined in typecheck
|
||||||
okforeq[TFUNC] = 1 // nil only; refined in typecheck
|
okforeq[TFUNC] = true // nil only; refined in typecheck
|
||||||
okforeq[TARRAY] = 1 // nil slice only; refined in typecheck
|
okforeq[TARRAY] = true // nil slice only; refined in typecheck
|
||||||
okforeq[TSTRUCT] = 1 // it's complicated; refined in typecheck
|
okforeq[TSTRUCT] = true // it's complicated; refined in typecheck
|
||||||
|
|
||||||
okforcmp[TSTRING] = 1
|
okforcmp[TSTRING] = true
|
||||||
|
|
||||||
var i int
|
var i int
|
||||||
for i = 0; i < len(okfor); i++ {
|
for i = 0; i < len(okfor); i++ {
|
||||||
|
|
@ -580,13 +580,13 @@ func typeinit() {
|
||||||
okfor[OLEN] = okforlen[:]
|
okfor[OLEN] = okforlen[:]
|
||||||
|
|
||||||
// comparison
|
// comparison
|
||||||
iscmp[OLT] = 1
|
iscmp[OLT] = true
|
||||||
|
|
||||||
iscmp[OGT] = 1
|
iscmp[OGT] = true
|
||||||
iscmp[OGE] = 1
|
iscmp[OGE] = true
|
||||||
iscmp[OLE] = 1
|
iscmp[OLE] = true
|
||||||
iscmp[OEQ] = 1
|
iscmp[OEQ] = true
|
||||||
iscmp[ONE] = 1
|
iscmp[ONE] = true
|
||||||
|
|
||||||
mpatofix(Maxintval[TINT8], "0x7f")
|
mpatofix(Maxintval[TINT8], "0x7f")
|
||||||
mpatofix(Minintval[TINT8], "-0x80")
|
mpatofix(Minintval[TINT8], "-0x80")
|
||||||
|
|
|
||||||
|
|
@ -519,7 +519,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node {
|
||||||
p = fmt.Sprintf("(%v).(%v)-fm", Tconv(rcvrtype, obj.FmtLeft|obj.FmtShort), Sconv(meth.Sym, obj.FmtLeft))
|
p = fmt.Sprintf("(%v).(%v)-fm", Tconv(rcvrtype, obj.FmtLeft|obj.FmtShort), Sconv(meth.Sym, obj.FmtLeft))
|
||||||
}
|
}
|
||||||
basetype := rcvrtype
|
basetype := rcvrtype
|
||||||
if Isptr[rcvrtype.Etype] != 0 {
|
if Isptr[rcvrtype.Etype] {
|
||||||
basetype = basetype.Type
|
basetype = basetype.Type
|
||||||
}
|
}
|
||||||
if basetype.Etype != TINTER && basetype.Sym == nil {
|
if basetype.Etype != TINTER && basetype.Sym == nil {
|
||||||
|
|
@ -613,7 +613,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node {
|
||||||
ptr.Used = 1
|
ptr.Used = 1
|
||||||
ptr.Curfn = xfunc
|
ptr.Curfn = xfunc
|
||||||
xfunc.Dcl = list(xfunc.Dcl, ptr)
|
xfunc.Dcl = list(xfunc.Dcl, ptr)
|
||||||
if Isptr[rcvrtype.Etype] != 0 || Isinter(rcvrtype) {
|
if Isptr[rcvrtype.Etype] || Isinter(rcvrtype) {
|
||||||
ptr.Ntype = typenod(rcvrtype)
|
ptr.Ntype = typenod(rcvrtype)
|
||||||
body = list(body, Nod(OAS, ptr, cv))
|
body = list(body, Nod(OAS, ptr, cv))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ func convlit1(np **Node, t *Type, explicit bool) {
|
||||||
|
|
||||||
// target is invalid type for a constant? leave alone.
|
// target is invalid type for a constant? leave alone.
|
||||||
case OLITERAL:
|
case OLITERAL:
|
||||||
if okforconst[t.Etype] == 0 && n.Type.Etype != TNIL {
|
if !okforconst[t.Etype] && n.Type.Etype != TNIL {
|
||||||
defaultlit(&n, nil)
|
defaultlit(&n, nil)
|
||||||
*np = n
|
*np = n
|
||||||
return
|
return
|
||||||
|
|
@ -100,7 +100,7 @@ func convlit1(np **Node, t *Type, explicit bool) {
|
||||||
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.Val = toint(n.Val)
|
||||||
}
|
}
|
||||||
if t != nil && Isint[t.Etype] == 0 {
|
if t != nil && !Isint[t.Etype] {
|
||||||
Yyerror("invalid operation: %v (shift of type %v)", Nconv(n, 0), Tconv(t, 0))
|
Yyerror("invalid operation: %v (shift of type %v)", Nconv(n, 0), Tconv(t, 0))
|
||||||
t = nil
|
t = nil
|
||||||
}
|
}
|
||||||
|
|
@ -207,7 +207,7 @@ func convlit1(np **Node, t *Type, explicit bool) {
|
||||||
CTFLT,
|
CTFLT,
|
||||||
CTCPLX:
|
CTCPLX:
|
||||||
ct := int(n.Val.Ctype)
|
ct := int(n.Val.Ctype)
|
||||||
if Isint[et] != 0 {
|
if Isint[et] {
|
||||||
switch ct {
|
switch ct {
|
||||||
default:
|
default:
|
||||||
goto bad
|
goto bad
|
||||||
|
|
@ -222,7 +222,7 @@ func convlit1(np **Node, t *Type, explicit bool) {
|
||||||
case CTINT:
|
case CTINT:
|
||||||
overflow(n.Val, t)
|
overflow(n.Val, t)
|
||||||
}
|
}
|
||||||
} else if Isfloat[et] != 0 {
|
} else if Isfloat[et] {
|
||||||
switch ct {
|
switch ct {
|
||||||
default:
|
default:
|
||||||
goto bad
|
goto bad
|
||||||
|
|
@ -237,7 +237,7 @@ func convlit1(np **Node, t *Type, explicit bool) {
|
||||||
case CTFLT:
|
case CTFLT:
|
||||||
n.Val.U.Fval = truncfltlit(n.Val.U.Fval, t)
|
n.Val.U.Fval = truncfltlit(n.Val.U.Fval, t)
|
||||||
}
|
}
|
||||||
} else if Iscomplex[et] != 0 {
|
} else if Iscomplex[et] {
|
||||||
switch ct {
|
switch ct {
|
||||||
default:
|
default:
|
||||||
goto bad
|
goto bad
|
||||||
|
|
@ -374,7 +374,7 @@ func doesoverflow(v Val, t *Type) bool {
|
||||||
switch v.Ctype {
|
switch v.Ctype {
|
||||||
case CTINT,
|
case CTINT,
|
||||||
CTRUNE:
|
CTRUNE:
|
||||||
if Isint[t.Etype] == 0 {
|
if !Isint[t.Etype] {
|
||||||
Fatal("overflow: %v integer constant", Tconv(t, 0))
|
Fatal("overflow: %v integer constant", Tconv(t, 0))
|
||||||
}
|
}
|
||||||
if Mpcmpfixfix(v.U.Xval, Minintval[t.Etype]) < 0 || Mpcmpfixfix(v.U.Xval, Maxintval[t.Etype]) > 0 {
|
if Mpcmpfixfix(v.U.Xval, Minintval[t.Etype]) < 0 || Mpcmpfixfix(v.U.Xval, Maxintval[t.Etype]) > 0 {
|
||||||
|
|
@ -382,7 +382,7 @@ func doesoverflow(v Val, t *Type) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
case CTFLT:
|
case CTFLT:
|
||||||
if Isfloat[t.Etype] == 0 {
|
if !Isfloat[t.Etype] {
|
||||||
Fatal("overflow: %v floating-point constant", Tconv(t, 0))
|
Fatal("overflow: %v floating-point constant", Tconv(t, 0))
|
||||||
}
|
}
|
||||||
if mpcmpfltflt(v.U.Fval, minfltval[t.Etype]) <= 0 || mpcmpfltflt(v.U.Fval, maxfltval[t.Etype]) >= 0 {
|
if mpcmpfltflt(v.U.Fval, minfltval[t.Etype]) <= 0 || mpcmpfltflt(v.U.Fval, maxfltval[t.Etype]) >= 0 {
|
||||||
|
|
@ -390,7 +390,7 @@ func doesoverflow(v Val, t *Type) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
case CTCPLX:
|
case CTCPLX:
|
||||||
if Iscomplex[t.Etype] == 0 {
|
if !Iscomplex[t.Etype] {
|
||||||
Fatal("overflow: %v complex constant", Tconv(t, 0))
|
Fatal("overflow: %v complex constant", Tconv(t, 0))
|
||||||
}
|
}
|
||||||
if mpcmpfltflt(&v.U.Cval.Real, minfltval[t.Etype]) <= 0 || mpcmpfltflt(&v.U.Cval.Real, maxfltval[t.Etype]) >= 0 || mpcmpfltflt(&v.U.Cval.Imag, minfltval[t.Etype]) <= 0 || mpcmpfltflt(&v.U.Cval.Imag, maxfltval[t.Etype]) >= 0 {
|
if mpcmpfltflt(&v.U.Cval.Real, minfltval[t.Etype]) <= 0 || mpcmpfltflt(&v.U.Cval.Real, maxfltval[t.Etype]) >= 0 || mpcmpfltflt(&v.U.Cval.Imag, minfltval[t.Etype]) <= 0 || mpcmpfltflt(&v.U.Cval.Imag, maxfltval[t.Etype]) >= 0 {
|
||||||
|
|
@ -518,7 +518,7 @@ func evconst(n *Node) {
|
||||||
if n.Type == nil {
|
if n.Type == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if okforconst[n.Type.Etype] == 0 && n.Type.Etype != TNIL {
|
if !okforconst[n.Type.Etype] && n.Type.Etype != TNIL {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -571,7 +571,7 @@ func evconst(n *Node) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
wl := int(nl.Type.Etype)
|
wl := int(nl.Type.Etype)
|
||||||
if Isint[wl] != 0 || Isfloat[wl] != 0 || Iscomplex[wl] != 0 {
|
if Isint[wl] || Isfloat[wl] || Iscomplex[wl] {
|
||||||
wl = TIDEAL
|
wl = TIDEAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -680,7 +680,7 @@ func evconst(n *Node) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
wr = int(nr.Type.Etype)
|
wr = int(nr.Type.Etype)
|
||||||
if Isint[wr] != 0 || Isfloat[wr] != 0 || Iscomplex[wr] != 0 {
|
if Isint[wr] || Isfloat[wr] || Iscomplex[wr] {
|
||||||
wr = TIDEAL
|
wr = TIDEAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -714,7 +714,7 @@ func evconst(n *Node) {
|
||||||
defaultlit(&nr, Types[TUINT])
|
defaultlit(&nr, Types[TUINT])
|
||||||
|
|
||||||
n.Right = nr
|
n.Right = nr
|
||||||
if nr.Type != nil && (Issigned[nr.Type.Etype] != 0 || Isint[nr.Type.Etype] == 0) {
|
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 {
|
||||||
|
|
@ -1261,13 +1261,13 @@ func defaultlit(np **Node, t *Type) {
|
||||||
|
|
||||||
num:
|
num:
|
||||||
if t != nil {
|
if t != nil {
|
||||||
if Isint[t.Etype] != 0 {
|
if Isint[t.Etype] {
|
||||||
t1 = t
|
t1 = t
|
||||||
n.Val = toint(n.Val)
|
n.Val = toint(n.Val)
|
||||||
} else if Isfloat[t.Etype] != 0 {
|
} else if Isfloat[t.Etype] {
|
||||||
t1 = t
|
t1 = t
|
||||||
n.Val = toflt(n.Val)
|
n.Val = toflt(n.Val)
|
||||||
} else if Iscomplex[t.Etype] != 0 {
|
} else if Iscomplex[t.Etype] {
|
||||||
t1 = t
|
t1 = t
|
||||||
n.Val = tocplx(n.Val)
|
n.Val = tocplx(n.Val)
|
||||||
}
|
}
|
||||||
|
|
@ -1432,7 +1432,7 @@ func Convconst(con *Node, t *Type, val *Val) {
|
||||||
con.Type = t
|
con.Type = t
|
||||||
con.Val = *val
|
con.Val = *val
|
||||||
|
|
||||||
if Isint[tt] != 0 {
|
if Isint[tt] {
|
||||||
con.Val.Ctype = CTINT
|
con.Val.Ctype = CTINT
|
||||||
con.Val.U.Xval = new(Mpint)
|
con.Val.U.Xval = new(Mpint)
|
||||||
var i int64
|
var i int64
|
||||||
|
|
@ -1456,7 +1456,7 @@ func Convconst(con *Node, t *Type, val *Val) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if Isfloat[tt] != 0 {
|
if Isfloat[tt] {
|
||||||
con.Val = toflt(con.Val)
|
con.Val = toflt(con.Val)
|
||||||
if con.Val.Ctype != CTFLT {
|
if con.Val.Ctype != CTFLT {
|
||||||
Fatal("convconst ctype=%d %v", con.Val.Ctype, Tconv(t, 0))
|
Fatal("convconst ctype=%d %v", con.Val.Ctype, Tconv(t, 0))
|
||||||
|
|
@ -1467,7 +1467,7 @@ func Convconst(con *Node, t *Type, val *Val) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if Iscomplex[tt] != 0 {
|
if Iscomplex[tt] {
|
||||||
con.Val = tocplx(con.Val)
|
con.Val = tocplx(con.Val)
|
||||||
if tt == TCOMPLEX64 {
|
if tt == TCOMPLEX64 {
|
||||||
con.Val.U.Cval.Real = *truncfltlit(&con.Val.U.Cval.Real, Types[TFLOAT32])
|
con.Val.U.Cval.Real = *truncfltlit(&con.Val.U.Cval.Real, Types[TFLOAT32])
|
||||||
|
|
@ -1601,7 +1601,7 @@ func isgoconst(n *Node) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
case OCONV:
|
case OCONV:
|
||||||
if okforconst[n.Type.Etype] != 0 && isgoconst(n.Left) {
|
if okforconst[n.Type.Etype] && isgoconst(n.Left) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1617,7 +1617,7 @@ func isgoconst(n *Node) bool {
|
||||||
// function calls or channel receive operations.
|
// function calls or channel receive operations.
|
||||||
t := l.Type
|
t := l.Type
|
||||||
|
|
||||||
if t != nil && Isptr[t.Etype] != 0 {
|
if t != nil && Isptr[t.Etype] {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
}
|
}
|
||||||
if Isfixedarray(t) && !hascallchan(l) {
|
if Isfixedarray(t) && !hascallchan(l) {
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ func nodfconst(n *Node, t *Type, fval *Mpflt) {
|
||||||
n.Val.Ctype = CTFLT
|
n.Val.Ctype = CTFLT
|
||||||
n.Type = t
|
n.Type = t
|
||||||
|
|
||||||
if Isfloat[t.Etype] == 0 {
|
if !Isfloat[t.Etype] {
|
||||||
Fatal("nodfconst: bad type %v", Tconv(t, 0))
|
Fatal("nodfconst: bad type %v", Tconv(t, 0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -243,13 +243,13 @@ func nodfconst(n *Node, t *Type, fval *Mpflt) {
|
||||||
*/
|
*/
|
||||||
func Complexop(n *Node, res *Node) bool {
|
func Complexop(n *Node, res *Node) bool {
|
||||||
if n != nil && n.Type != nil {
|
if n != nil && n.Type != nil {
|
||||||
if Iscomplex[n.Type.Etype] != 0 {
|
if Iscomplex[n.Type.Etype] {
|
||||||
goto maybe
|
goto maybe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res != nil && res.Type != nil {
|
if res != nil && res.Type != nil {
|
||||||
if Iscomplex[res.Type.Etype] != 0 {
|
if Iscomplex[res.Type.Etype] {
|
||||||
goto maybe
|
goto maybe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -778,14 +778,14 @@ func checkembeddedtype(t *Type) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.Sym == nil && Isptr[t.Etype] != 0 {
|
if t.Sym == nil && Isptr[t.Etype] {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
if t.Etype == TINTER {
|
if t.Etype == TINTER {
|
||||||
Yyerror("embedded type cannot be a pointer to interface")
|
Yyerror("embedded type cannot be a pointer to interface")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if Isptr[t.Etype] != 0 {
|
if Isptr[t.Etype] {
|
||||||
Yyerror("embedded type cannot be a pointer")
|
Yyerror("embedded type cannot be a pointer")
|
||||||
} else if t.Etype == TFORW && t.Embedlineno == 0 {
|
} else if t.Etype == TFORW && t.Embedlineno == 0 {
|
||||||
t.Embedlineno = lineno
|
t.Embedlineno = lineno
|
||||||
|
|
@ -1178,7 +1178,7 @@ func isifacemethod(f *Type) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
t := rcvr.Type
|
t := rcvr.Type
|
||||||
if Isptr[t.Etype] == 0 {
|
if !Isptr[t.Etype] {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
t = t.Type
|
t = t.Type
|
||||||
|
|
@ -1241,7 +1241,7 @@ func methodsym(nsym *Sym, t0 *Type, iface int) *Sym {
|
||||||
goto bad
|
goto bad
|
||||||
}
|
}
|
||||||
s = t.Sym
|
s = t.Sym
|
||||||
if s == nil && Isptr[t.Etype] != 0 {
|
if s == nil && Isptr[t.Etype] {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
if t == nil {
|
if t == nil {
|
||||||
goto bad
|
goto bad
|
||||||
|
|
@ -1269,13 +1269,13 @@ func methodsym(nsym *Sym, t0 *Type, iface int) *Sym {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spkg == nil || nsym.Pkg != spkg) && !exportname(nsym.Name) {
|
if (spkg == nil || nsym.Pkg != spkg) && !exportname(nsym.Name) {
|
||||||
if t0.Sym == nil && Isptr[t0.Etype] != 0 {
|
if t0.Sym == nil && Isptr[t0.Etype] {
|
||||||
p = fmt.Sprintf("(%v).%s.%s%s", Tconv(t0, obj.FmtLeft|obj.FmtShort), nsym.Pkg.Prefix, nsym.Name, suffix)
|
p = fmt.Sprintf("(%v).%s.%s%s", Tconv(t0, obj.FmtLeft|obj.FmtShort), nsym.Pkg.Prefix, nsym.Name, suffix)
|
||||||
} else {
|
} else {
|
||||||
p = fmt.Sprintf("%v.%s.%s%s", Tconv(t0, obj.FmtLeft|obj.FmtShort), nsym.Pkg.Prefix, nsym.Name, suffix)
|
p = fmt.Sprintf("%v.%s.%s%s", Tconv(t0, obj.FmtLeft|obj.FmtShort), nsym.Pkg.Prefix, nsym.Name, suffix)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if t0.Sym == nil && Isptr[t0.Etype] != 0 {
|
if t0.Sym == nil && Isptr[t0.Etype] {
|
||||||
p = fmt.Sprintf("(%v).%s%s", Tconv(t0, obj.FmtLeft|obj.FmtShort), nsym.Name, suffix)
|
p = fmt.Sprintf("(%v).%s%s", Tconv(t0, obj.FmtLeft|obj.FmtShort), nsym.Name, suffix)
|
||||||
} else {
|
} else {
|
||||||
p = fmt.Sprintf("%v.%s%s", Tconv(t0, obj.FmtLeft|obj.FmtShort), nsym.Name, suffix)
|
p = fmt.Sprintf("%v.%s%s", Tconv(t0, obj.FmtLeft|obj.FmtShort), nsym.Name, suffix)
|
||||||
|
|
@ -1358,7 +1358,7 @@ func addmethod(sf *Sym, t *Type, local bool, nointerface bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if t != nil {
|
if t != nil {
|
||||||
if Isptr[t.Etype] != 0 {
|
if Isptr[t.Etype] {
|
||||||
if t.Sym != nil {
|
if t.Sym != nil {
|
||||||
Yyerror("invalid receiver type %v (%v is a pointer type)", Tconv(pa, 0), Tconv(t, 0))
|
Yyerror("invalid receiver type %v (%v is a pointer type)", Tconv(pa, 0), Tconv(t, 0))
|
||||||
return
|
return
|
||||||
|
|
@ -1375,7 +1375,7 @@ func addmethod(sf *Sym, t *Type, local bool, nointerface bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if Isptr[t.Etype] != 0 {
|
if Isptr[t.Etype] {
|
||||||
Yyerror("invalid receiver type %v (%v is a pointer type)", Tconv(pa, 0), Tconv(t, 0))
|
Yyerror("invalid receiver type %v (%v is a pointer type)", Tconv(pa, 0), Tconv(t, 0))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ func reexportdep(n *Node) {
|
||||||
t := n.Left.Type
|
t := n.Left.Type
|
||||||
|
|
||||||
if t != Types[t.Etype] && t != idealbool && t != idealstring {
|
if t != Types[t.Etype] && t != idealbool && t != idealstring {
|
||||||
if Isptr[t.Etype] != 0 {
|
if Isptr[t.Etype] {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
}
|
}
|
||||||
if t != nil && t.Sym != nil && t.Sym.Def != nil && !exportedsym(t.Sym) {
|
if t != nil && t.Sym != nil && t.Sym.Def != nil && !exportedsym(t.Sym) {
|
||||||
|
|
@ -148,7 +148,7 @@ func reexportdep(n *Node) {
|
||||||
case OLITERAL:
|
case OLITERAL:
|
||||||
t := n.Type
|
t := n.Type
|
||||||
if t != Types[n.Type.Etype] && t != idealbool && t != idealstring {
|
if t != Types[n.Type.Etype] && t != idealbool && t != idealstring {
|
||||||
if Isptr[t.Etype] != 0 {
|
if Isptr[t.Etype] {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
}
|
}
|
||||||
if t != nil && t.Sym != nil && t.Sym.Def != nil && !exportedsym(t.Sym) {
|
if t != nil && t.Sym != nil && t.Sym.Def != nil && !exportedsym(t.Sym) {
|
||||||
|
|
|
||||||
|
|
@ -1202,7 +1202,7 @@ func exprfmt(n *Node, prec int) string {
|
||||||
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] != 0 || (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)", Tconv(n.Type, 0), Vconv(&n.Val, 0))
|
return fmt.Sprintf("(%v)(%v)", Tconv(n.Type, 0), Vconv(&n.Val, 0))
|
||||||
} else {
|
} else {
|
||||||
return fmt.Sprintf("%v(%v)", Tconv(n.Type, 0), Vconv(&n.Val, 0))
|
return fmt.Sprintf("%v(%v)", Tconv(n.Type, 0), Vconv(&n.Val, 0))
|
||||||
|
|
@ -1227,7 +1227,7 @@ func exprfmt(n *Node, prec int) string {
|
||||||
// but for export, this should be rendered as (*pkg.T).meth.
|
// but for export, this should be rendered as (*pkg.T).meth.
|
||||||
// These nodes have the special property that they are names with a left OTYPE and a right ONAME.
|
// These nodes have the special property that they are names with a left OTYPE and a right ONAME.
|
||||||
if fmtmode == FExp && n.Left != nil && n.Left.Op == OTYPE && n.Right != nil && n.Right.Op == ONAME {
|
if fmtmode == FExp && n.Left != nil && n.Left.Op == OTYPE && n.Right != nil && n.Right.Op == ONAME {
|
||||||
if Isptr[n.Left.Type.Etype] != 0 {
|
if Isptr[n.Left.Type.Etype] {
|
||||||
return fmt.Sprintf("(%v).%v", Tconv(n.Left.Type, 0), Sconv(n.Right.Sym, obj.FmtShort|obj.FmtByte))
|
return fmt.Sprintf("(%v).%v", Tconv(n.Left.Type, 0), Sconv(n.Right.Sym, obj.FmtShort|obj.FmtByte))
|
||||||
} else {
|
} else {
|
||||||
return fmt.Sprintf("%v.%v", Tconv(n.Left.Type, 0), Sconv(n.Right.Sym, obj.FmtShort|obj.FmtByte))
|
return fmt.Sprintf("%v.%v", Tconv(n.Left.Type, 0), Sconv(n.Right.Sym, obj.FmtShort|obj.FmtByte))
|
||||||
|
|
@ -1311,7 +1311,7 @@ func exprfmt(n *Node, prec int) string {
|
||||||
return f
|
return f
|
||||||
|
|
||||||
case OCOMPLIT:
|
case OCOMPLIT:
|
||||||
ptrlit := n.Right != nil && n.Right.Implicit != 0 && n.Right.Type != nil && Isptr[n.Right.Type.Etype] != 0
|
ptrlit := n.Right != nil && n.Right.Implicit != 0 && n.Right.Type != nil && Isptr[n.Right.Type.Etype]
|
||||||
if fmtmode == FErr {
|
if fmtmode == FErr {
|
||||||
if n.Right != nil && n.Right.Type != nil && n.Implicit == 0 {
|
if n.Right != nil && n.Right.Type != nil && n.Implicit == 0 {
|
||||||
if ptrlit {
|
if ptrlit {
|
||||||
|
|
|
||||||
|
|
@ -452,7 +452,7 @@ func Cgen_slice(n *Node, res *Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if n.Op == OSLICEARR || n.Op == OSLICE3ARR {
|
if n.Op == OSLICEARR || n.Op == OSLICE3ARR {
|
||||||
if Isptr[n.Left.Type.Etype] == 0 {
|
if !Isptr[n.Left.Type.Etype] {
|
||||||
Fatal("slicearr is supposed to work on pointer: %v\n", Nconv(n, obj.FmtSign))
|
Fatal("slicearr is supposed to work on pointer: %v\n", Nconv(n, obj.FmtSign))
|
||||||
}
|
}
|
||||||
Thearch.Cgen(&src, base)
|
Thearch.Cgen(&src, base)
|
||||||
|
|
|
||||||
|
|
@ -822,43 +822,33 @@ var errortype *Type
|
||||||
|
|
||||||
var Simtype [NTYPE]uint8
|
var Simtype [NTYPE]uint8
|
||||||
|
|
||||||
var Isptr [NTYPE]uint8
|
var (
|
||||||
|
Isptr [NTYPE]bool
|
||||||
|
isforw [NTYPE]bool
|
||||||
|
Isint [NTYPE]bool
|
||||||
|
Isfloat [NTYPE]bool
|
||||||
|
Iscomplex [NTYPE]bool
|
||||||
|
Issigned [NTYPE]bool
|
||||||
|
issimple [NTYPE]bool
|
||||||
|
)
|
||||||
|
|
||||||
var isforw [NTYPE]uint8
|
var (
|
||||||
|
okforeq [NTYPE]bool
|
||||||
|
okforadd [NTYPE]bool
|
||||||
|
okforand [NTYPE]bool
|
||||||
|
okfornone [NTYPE]bool
|
||||||
|
okforcmp [NTYPE]bool
|
||||||
|
okforbool [NTYPE]bool
|
||||||
|
okforcap [NTYPE]bool
|
||||||
|
okforlen [NTYPE]bool
|
||||||
|
okforarith [NTYPE]bool
|
||||||
|
okforconst [NTYPE]bool
|
||||||
|
)
|
||||||
|
|
||||||
var Isint [NTYPE]uint8
|
var (
|
||||||
|
okfor [OEND][]bool
|
||||||
var Isfloat [NTYPE]uint8
|
iscmp [OEND]bool
|
||||||
|
)
|
||||||
var Iscomplex [NTYPE]uint8
|
|
||||||
|
|
||||||
var Issigned [NTYPE]uint8
|
|
||||||
|
|
||||||
var issimple [NTYPE]uint8
|
|
||||||
|
|
||||||
var okforeq [NTYPE]uint8
|
|
||||||
|
|
||||||
var okforadd [NTYPE]uint8
|
|
||||||
|
|
||||||
var okforand [NTYPE]uint8
|
|
||||||
|
|
||||||
var okfornone [NTYPE]uint8
|
|
||||||
|
|
||||||
var okforcmp [NTYPE]uint8
|
|
||||||
|
|
||||||
var okforbool [NTYPE]uint8
|
|
||||||
|
|
||||||
var okforcap [NTYPE]uint8
|
|
||||||
|
|
||||||
var okforlen [NTYPE]uint8
|
|
||||||
|
|
||||||
var okforarith [NTYPE]uint8
|
|
||||||
|
|
||||||
var okforconst [NTYPE]uint8
|
|
||||||
|
|
||||||
var okfor [OEND][]byte
|
|
||||||
|
|
||||||
var iscmp [OEND]uint8
|
|
||||||
|
|
||||||
var Minintval [NTYPE]*Mpint
|
var Minintval [NTYPE]*Mpint
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2118,7 +2118,7 @@ hidden_structdcl:
|
||||||
$$.Val = $3;
|
$$.Val = $3;
|
||||||
} else {
|
} else {
|
||||||
s = $2.Sym;
|
s = $2.Sym;
|
||||||
if s == nil && Isptr[$2.Etype] != 0 {
|
if s == nil && Isptr[$2.Etype] {
|
||||||
s = $2.Type.Sym;
|
s = $2.Type.Sym;
|
||||||
}
|
}
|
||||||
p = importpkg;
|
p = importpkg;
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ func fnpkg(fn *Node) *Pkg {
|
||||||
// method
|
// method
|
||||||
rcvr := getthisx(fn.Type).Type.Type
|
rcvr := getthisx(fn.Type).Type.Type
|
||||||
|
|
||||||
if Isptr[rcvr.Etype] != 0 {
|
if Isptr[rcvr.Etype] {
|
||||||
rcvr = rcvr.Type
|
rcvr = rcvr.Type
|
||||||
}
|
}
|
||||||
if rcvr.Sym == nil {
|
if rcvr.Sym == nil {
|
||||||
|
|
|
||||||
|
|
@ -337,7 +337,7 @@ func Cgen_checknil(n *Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ideally we wouldn't see any integer types here, but we do.
|
// Ideally we wouldn't see any integer types here, but we do.
|
||||||
if n.Type == nil || (Isptr[n.Type.Etype] == 0 && Isint[n.Type.Etype] == 0 && n.Type.Etype != TUNSAFEPTR) {
|
if n.Type == nil || (!Isptr[n.Type.Etype] && !Isint[n.Type.Etype] && n.Type.Etype != TUNSAFEPTR) {
|
||||||
Dump("checknil", n)
|
Dump("checknil", n)
|
||||||
Fatal("bad checknil")
|
Fatal("bad checknil")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ func typecheckrange(n *Node) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if Isptr[t.Etype] != 0 && Isfixedarray(t.Type) {
|
if Isptr[t.Etype] && Isfixedarray(t.Type) {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
}
|
}
|
||||||
n.Type = t
|
n.Type = t
|
||||||
|
|
|
||||||
|
|
@ -358,10 +358,10 @@ func methods(t *Type) *Sig {
|
||||||
// method does not apply.
|
// method does not apply.
|
||||||
this = getthisx(f.Type).Type.Type
|
this = getthisx(f.Type).Type.Type
|
||||||
|
|
||||||
if Isptr[this.Etype] != 0 && this.Type == t {
|
if Isptr[this.Etype] && this.Type == t {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if Isptr[this.Etype] != 0 && Isptr[t.Etype] == 0 && f.Embedded != 2 && !isifacemethod(f.Type) {
|
if Isptr[this.Etype] && !Isptr[t.Etype] && f.Embedded != 2 && !isifacemethod(f.Type) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -693,7 +693,7 @@ func dcommontype(s *Sym, ot int, t *Type) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
var sptr *Sym
|
var sptr *Sym
|
||||||
if t.Sym != nil && Isptr[t.Etype] == 0 {
|
if t.Sym != nil && !Isptr[t.Etype] {
|
||||||
sptr = dtypesym(Ptrto(t))
|
sptr = dtypesym(Ptrto(t))
|
||||||
} else {
|
} else {
|
||||||
sptr = weaktypesym(Ptrto(t))
|
sptr = weaktypesym(Ptrto(t))
|
||||||
|
|
@ -868,7 +868,7 @@ func typesymprefix(prefix string, t *Type) *Sym {
|
||||||
}
|
}
|
||||||
|
|
||||||
func typenamesym(t *Type) *Sym {
|
func typenamesym(t *Type) *Sym {
|
||||||
if t == nil || (Isptr[t.Etype] != 0 && t.Type == nil) || isideal(t) {
|
if t == nil || (Isptr[t.Etype] && t.Type == nil) || isideal(t) {
|
||||||
Fatal("typename %v", Tconv(t, 0))
|
Fatal("typename %v", Tconv(t, 0))
|
||||||
}
|
}
|
||||||
s := typesym(t)
|
s := typesym(t)
|
||||||
|
|
@ -987,7 +987,7 @@ func dtypesym(t *Type) *Sym {
|
||||||
// emit the type structures for int, float, etc.
|
// emit the type structures for int, float, etc.
|
||||||
tbase := t
|
tbase := t
|
||||||
|
|
||||||
if Isptr[t.Etype] != 0 && t.Sym == nil && t.Type.Sym != nil {
|
if Isptr[t.Etype] && t.Sym == nil && t.Type.Sym != nil {
|
||||||
tbase = t.Type
|
tbase = t.Type
|
||||||
}
|
}
|
||||||
dupok := 0
|
dupok := 0
|
||||||
|
|
@ -1003,7 +1003,7 @@ func dtypesym(t *Type) *Sym {
|
||||||
if tbase.Sym != nil && tbase.Local == 0 {
|
if tbase.Sym != nil && tbase.Local == 0 {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
if isforw[tbase.Etype] != 0 {
|
if isforw[tbase.Etype] {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1070,7 +1070,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init **NodeList) {
|
||||||
Fatal("anylit: not lit")
|
Fatal("anylit: not lit")
|
||||||
|
|
||||||
case OPTRLIT:
|
case OPTRLIT:
|
||||||
if Isptr[t.Etype] == 0 {
|
if !Isptr[t.Etype] {
|
||||||
Fatal("anylit: not ptr")
|
Fatal("anylit: not ptr")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -714,7 +714,7 @@ func Nodconst(n *Node, t *Type, v int64) {
|
||||||
n.Val.Ctype = CTINT
|
n.Val.Ctype = CTINT
|
||||||
n.Type = t
|
n.Type = t
|
||||||
|
|
||||||
if Isfloat[t.Etype] != 0 {
|
if Isfloat[t.Etype] {
|
||||||
Fatal("nodconst: bad type %v", Tconv(t, 0))
|
Fatal("nodconst: bad type %v", Tconv(t, 0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -818,7 +818,7 @@ func isptrto(t *Type, et int) bool {
|
||||||
if t == nil {
|
if t == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if Isptr[t.Etype] == 0 {
|
if !Isptr[t.Etype] {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
t = t.Type
|
t = t.Type
|
||||||
|
|
@ -894,7 +894,7 @@ func methtype(t *Type, mustname int) *Type {
|
||||||
}
|
}
|
||||||
|
|
||||||
// strip away pointer if it's there
|
// strip away pointer if it's there
|
||||||
if Isptr[t.Etype] != 0 {
|
if Isptr[t.Etype] {
|
||||||
if t.Sym != nil {
|
if t.Sym != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -910,7 +910,7 @@ func methtype(t *Type, mustname int) *Type {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check types
|
// check types
|
||||||
if issimple[t.Etype] == 0 {
|
if !issimple[t.Etype] {
|
||||||
switch t.Etype {
|
switch t.Etype {
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -1259,14 +1259,14 @@ func convertop(src *Type, dst *Type, why *string) int {
|
||||||
|
|
||||||
// 3. src and dst are unnamed pointer types
|
// 3. src and dst are unnamed pointer types
|
||||||
// and their base types have identical underlying types.
|
// and their base types have identical underlying types.
|
||||||
if Isptr[src.Etype] != 0 && Isptr[dst.Etype] != 0 && src.Sym == nil && dst.Sym == nil {
|
if Isptr[src.Etype] && Isptr[dst.Etype] && src.Sym == nil && dst.Sym == nil {
|
||||||
if Eqtype(src.Type.Orig, dst.Type.Orig) {
|
if Eqtype(src.Type.Orig, dst.Type.Orig) {
|
||||||
return OCONVNOP
|
return OCONVNOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. src and dst are both integer or floating point types.
|
// 4. src and dst are both integer or floating point types.
|
||||||
if (Isint[src.Etype] != 0 || Isfloat[src.Etype] != 0) && (Isint[dst.Etype] != 0 || Isfloat[dst.Etype] != 0) {
|
if (Isint[src.Etype] || Isfloat[src.Etype]) && (Isint[dst.Etype] || Isfloat[dst.Etype]) {
|
||||||
if Simtype[src.Etype] == Simtype[dst.Etype] {
|
if Simtype[src.Etype] == Simtype[dst.Etype] {
|
||||||
return OCONVNOP
|
return OCONVNOP
|
||||||
}
|
}
|
||||||
|
|
@ -1274,7 +1274,7 @@ func convertop(src *Type, dst *Type, why *string) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. src and dst are both complex types.
|
// 5. src and dst are both complex types.
|
||||||
if Iscomplex[src.Etype] != 0 && Iscomplex[dst.Etype] != 0 {
|
if Iscomplex[src.Etype] && Iscomplex[dst.Etype] {
|
||||||
if Simtype[src.Etype] == Simtype[dst.Etype] {
|
if Simtype[src.Etype] == Simtype[dst.Etype] {
|
||||||
return OCONVNOP
|
return OCONVNOP
|
||||||
}
|
}
|
||||||
|
|
@ -1283,7 +1283,7 @@ func convertop(src *Type, dst *Type, why *string) int {
|
||||||
|
|
||||||
// 6. src is an integer or has type []byte or []rune
|
// 6. src is an integer or has type []byte or []rune
|
||||||
// and dst is a string type.
|
// and dst is a string type.
|
||||||
if Isint[src.Etype] != 0 && dst.Etype == TSTRING {
|
if Isint[src.Etype] && dst.Etype == TSTRING {
|
||||||
return ORUNESTR
|
return ORUNESTR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1308,12 +1308,12 @@ func convertop(src *Type, dst *Type, why *string) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8. src is a pointer or uintptr and dst is unsafe.Pointer.
|
// 8. src is a pointer or uintptr and dst is unsafe.Pointer.
|
||||||
if (Isptr[src.Etype] != 0 || src.Etype == TUINTPTR) && dst.Etype == TUNSAFEPTR {
|
if (Isptr[src.Etype] || src.Etype == TUINTPTR) && dst.Etype == TUNSAFEPTR {
|
||||||
return OCONVNOP
|
return OCONVNOP
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9. src is unsafe.Pointer and dst is a pointer or uintptr.
|
// 9. src is unsafe.Pointer and dst is a pointer or uintptr.
|
||||||
if src.Etype == TUNSAFEPTR && (Isptr[dst.Etype] != 0 || dst.Etype == TUINTPTR) {
|
if src.Etype == TUNSAFEPTR && (Isptr[dst.Etype] || dst.Etype == TUINTPTR) {
|
||||||
return OCONVNOP
|
return OCONVNOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1719,7 +1719,7 @@ func badtype(o int, tl *Type, tr *Type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// common mistake: *struct and *interface.
|
// common mistake: *struct and *interface.
|
||||||
if tl != nil && tr != nil && Isptr[tl.Etype] != 0 && Isptr[tr.Etype] != 0 {
|
if tl != nil && tr != nil && Isptr[tl.Etype] && Isptr[tr.Etype] {
|
||||||
if tl.Type.Etype == TSTRUCT && tr.Type.Etype == TINTER {
|
if tl.Type.Etype == TSTRUCT && tr.Type.Etype == TINTER {
|
||||||
fmt_ += "\n\t(*struct vs *interface)"
|
fmt_ += "\n\t(*struct vs *interface)"
|
||||||
} else if tl.Type.Etype == TINTER && tr.Type.Etype == TSTRUCT {
|
} else if tl.Type.Etype == TINTER && tr.Type.Etype == TSTRUCT {
|
||||||
|
|
@ -2038,7 +2038,7 @@ func Setmaxarg(t *Type, extra int32) {
|
||||||
// found with a given name
|
// found with a given name
|
||||||
func lookdot0(s *Sym, t *Type, save **Type, ignorecase int) int {
|
func lookdot0(s *Sym, t *Type, save **Type, ignorecase int) int {
|
||||||
u := t
|
u := t
|
||||||
if Isptr[u.Etype] != 0 {
|
if Isptr[u.Etype] {
|
||||||
u = u.Type
|
u = u.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2090,7 +2090,7 @@ func adddot1(s *Sym, t *Type, d int, save **Type, ignorecase int) int {
|
||||||
|
|
||||||
c = 0
|
c = 0
|
||||||
u = t
|
u = t
|
||||||
if Isptr[u.Etype] != 0 {
|
if Isptr[u.Etype] {
|
||||||
u = u.Type
|
u = u.Type
|
||||||
}
|
}
|
||||||
if u.Etype != TSTRUCT && u.Etype != TINTER {
|
if u.Etype != TSTRUCT && u.Etype != TINTER {
|
||||||
|
|
@ -2153,7 +2153,7 @@ func adddot(n *Node) *Node {
|
||||||
|
|
||||||
// rebuild elided dots
|
// rebuild elided dots
|
||||||
for c := d - 1; c >= 0; c-- {
|
for c := d - 1; c >= 0; c-- {
|
||||||
if n.Left.Type != nil && Isptr[n.Left.Type.Etype] != 0 {
|
if n.Left.Type != nil && Isptr[n.Left.Type.Etype] {
|
||||||
n.Left.Implicit = 1
|
n.Left.Implicit = 1
|
||||||
}
|
}
|
||||||
n.Left = Nod(ODOT, n.Left, newname(dotlist[c].field.Sym))
|
n.Left = Nod(ODOT, n.Left, newname(dotlist[c].field.Sym))
|
||||||
|
|
@ -2187,7 +2187,7 @@ var slist *Symlink
|
||||||
|
|
||||||
func expand0(t *Type, followptr int) {
|
func expand0(t *Type, followptr int) {
|
||||||
u := t
|
u := t
|
||||||
if Isptr[u.Etype] != 0 {
|
if Isptr[u.Etype] {
|
||||||
followptr = 1
|
followptr = 1
|
||||||
u = u.Type
|
u = u.Type
|
||||||
}
|
}
|
||||||
|
|
@ -2240,7 +2240,7 @@ func expand1(t *Type, d int, followptr int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
u := t
|
u := t
|
||||||
if Isptr[u.Etype] != 0 {
|
if Isptr[u.Etype] {
|
||||||
followptr = 1
|
followptr = 1
|
||||||
u = u.Type
|
u = u.Type
|
||||||
}
|
}
|
||||||
|
|
@ -2442,7 +2442,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
|
||||||
methodrcvr := getthisx(method.Type).Type.Type
|
methodrcvr := getthisx(method.Type).Type.Type
|
||||||
|
|
||||||
// generate nil pointer check for better error
|
// generate nil pointer check for better error
|
||||||
if Isptr[rcvr.Etype] != 0 && rcvr.Type == methodrcvr {
|
if Isptr[rcvr.Etype] && rcvr.Type == methodrcvr {
|
||||||
// generating wrapper from *T to T.
|
// generating wrapper from *T to T.
|
||||||
n := Nod(OIF, nil, nil)
|
n := Nod(OIF, nil, nil)
|
||||||
|
|
||||||
|
|
@ -2469,10 +2469,10 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
|
||||||
dot := adddot(Nod(OXDOT, this.Left, newname(method.Sym)))
|
dot := adddot(Nod(OXDOT, this.Left, newname(method.Sym)))
|
||||||
|
|
||||||
// generate call
|
// generate call
|
||||||
if flag_race == 0 && Isptr[rcvr.Etype] != 0 && Isptr[methodrcvr.Etype] != 0 && method.Embedded != 0 && !isifacemethod(method.Type) {
|
if flag_race == 0 && Isptr[rcvr.Etype] && Isptr[methodrcvr.Etype] && method.Embedded != 0 && !isifacemethod(method.Type) {
|
||||||
// generate tail call: adjust pointer receiver and jump to embedded method.
|
// generate tail call: adjust pointer receiver and jump to embedded method.
|
||||||
dot = dot.Left // skip final .M
|
dot = dot.Left // skip final .M
|
||||||
if Isptr[dotlist[0].field.Type.Etype] == 0 {
|
if !Isptr[dotlist[0].field.Type.Etype] {
|
||||||
dot = Nod(OADDR, dot, nil)
|
dot = Nod(OADDR, dot, nil)
|
||||||
}
|
}
|
||||||
as := Nod(OAS, this.Left, Nod(OCONVNOP, dot, nil))
|
as := Nod(OAS, this.Left, Nod(OCONVNOP, dot, nil))
|
||||||
|
|
@ -2503,7 +2503,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
|
||||||
Curfn = fn
|
Curfn = fn
|
||||||
|
|
||||||
// wrappers where T is anonymous (struct or interface) can be duplicated.
|
// wrappers where T is anonymous (struct or interface) can be duplicated.
|
||||||
if rcvr.Etype == TSTRUCT || rcvr.Etype == TINTER || Isptr[rcvr.Etype] != 0 && rcvr.Type.Etype == TSTRUCT {
|
if rcvr.Etype == TSTRUCT || rcvr.Etype == TINTER || Isptr[rcvr.Etype] && rcvr.Type.Etype == TSTRUCT {
|
||||||
fn.Dupok = 1
|
fn.Dupok = 1
|
||||||
}
|
}
|
||||||
typecheck(&fn, Etop)
|
typecheck(&fn, Etop)
|
||||||
|
|
@ -3015,7 +3015,7 @@ func ifacelookdot(s *Sym, t *Type, followptr *int, ignorecase int) *Type {
|
||||||
|
|
||||||
if c == 1 {
|
if c == 1 {
|
||||||
for i = 0; i < d; i++ {
|
for i = 0; i < d; i++ {
|
||||||
if Isptr[dotlist[i].field.Type.Etype] != 0 {
|
if Isptr[dotlist[i].field.Type.Etype] {
|
||||||
*followptr = 1
|
*followptr = 1
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
@ -3093,7 +3093,7 @@ func implements(t *Type, iface *Type, m **Type, samename **Type, ptr *int) bool
|
||||||
// the method does not exist for value types.
|
// the method does not exist for value types.
|
||||||
rcvr = getthisx(tm.Type).Type.Type
|
rcvr = getthisx(tm.Type).Type.Type
|
||||||
|
|
||||||
if Isptr[rcvr.Etype] != 0 && Isptr[t0.Etype] == 0 && followptr == 0 && !isifacemethod(tm.Type) {
|
if Isptr[rcvr.Etype] && !Isptr[t0.Etype] && followptr == 0 && !isifacemethod(tm.Type) {
|
||||||
if false && Debug['r'] != 0 {
|
if false && Debug['r'] != 0 {
|
||||||
Yyerror("interface pointer mismatch")
|
Yyerror("interface pointer mismatch")
|
||||||
}
|
}
|
||||||
|
|
@ -3284,7 +3284,7 @@ func powtwo(n *Node) int {
|
||||||
if n == nil || n.Op != OLITERAL || n.Type == nil {
|
if n == nil || n.Op != OLITERAL || n.Type == nil {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
if Isint[n.Type.Etype] == 0 {
|
if !Isint[n.Type.Etype] {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3297,7 +3297,7 @@ func powtwo(n *Node) int {
|
||||||
b = b << 1
|
b = b << 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if Issigned[n.Type.Etype] == 0 {
|
if !Issigned[n.Type.Etype] {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ func typecheckswitch(n *Node) {
|
||||||
if t != nil {
|
if t != nil {
|
||||||
var badtype *Type
|
var badtype *Type
|
||||||
switch {
|
switch {
|
||||||
case okforeq[t.Etype] == 0:
|
case !okforeq[t.Etype]:
|
||||||
Yyerror("cannot switch on %v", Nconv(n.Ntest, obj.FmtLong))
|
Yyerror("cannot switch on %v", Nconv(n.Ntest, obj.FmtLong))
|
||||||
case t.Etype == TARRAY && !Isfixedarray(t):
|
case t.Etype == TARRAY && !Isfixedarray(t):
|
||||||
nilonly = "slice"
|
nilonly = "slice"
|
||||||
|
|
@ -255,7 +255,7 @@ func (s *exprSwitch) walk(sw *Node) {
|
||||||
// handle the cases in order
|
// handle the cases in order
|
||||||
for len(cc) > 0 {
|
for len(cc) > 0 {
|
||||||
// deal with expressions one at a time
|
// deal with expressions one at a time
|
||||||
if okforcmp[t.Etype] == 0 || cc[0].typ != caseKindExprConst {
|
if !okforcmp[t.Etype] || cc[0].typ != caseKindExprConst {
|
||||||
a := s.walkCases(cc[:1])
|
a := s.walkCases(cc[:1])
|
||||||
cas = list(cas, a)
|
cas = list(cas, a)
|
||||||
cc = cc[1:]
|
cc = cc[1:]
|
||||||
|
|
|
||||||
|
|
@ -405,7 +405,7 @@ reswitch:
|
||||||
v = toint(l.Val)
|
v = toint(l.Val)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if l.Type != nil && Isint[l.Type.Etype] != 0 && l.Op != OLITERAL {
|
if l.Type != nil && Isint[l.Type.Etype] && l.Op != OLITERAL {
|
||||||
Yyerror("non-constant array bound %v", Nconv(l, 0))
|
Yyerror("non-constant array bound %v", Nconv(l, 0))
|
||||||
} else {
|
} else {
|
||||||
Yyerror("invalid array bound %v", Nconv(l, 0))
|
Yyerror("invalid array bound %v", Nconv(l, 0))
|
||||||
|
|
@ -510,7 +510,7 @@ reswitch:
|
||||||
goto ret
|
goto ret
|
||||||
}
|
}
|
||||||
|
|
||||||
if Isptr[t.Etype] == 0 {
|
if !Isptr[t.Etype] {
|
||||||
if top&(Erv|Etop) != 0 {
|
if top&(Erv|Etop) != 0 {
|
||||||
Yyerror("invalid indirect of %v", Nconv(n.Left, obj.FmtLong))
|
Yyerror("invalid indirect of %v", Nconv(n.Left, obj.FmtLong))
|
||||||
goto error
|
goto error
|
||||||
|
|
@ -576,7 +576,7 @@ reswitch:
|
||||||
if t == nil {
|
if t == nil {
|
||||||
goto error
|
goto error
|
||||||
}
|
}
|
||||||
if okfor[n.Op][t.Etype] == 0 {
|
if !okfor[n.Op][t.Etype] {
|
||||||
Yyerror("invalid operation: %v %v", Oconv(int(n.Op), 0), Tconv(t, 0))
|
Yyerror("invalid operation: %v %v", Oconv(int(n.Op), 0), Tconv(t, 0))
|
||||||
goto error
|
goto error
|
||||||
}
|
}
|
||||||
|
|
@ -678,7 +678,7 @@ reswitch:
|
||||||
goto ret
|
goto ret
|
||||||
}
|
}
|
||||||
|
|
||||||
if Isptr[t.Etype] != 0 && t.Type.Etype != TINTER {
|
if Isptr[t.Etype] && t.Type.Etype != TINTER {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
if t == nil {
|
if t == nil {
|
||||||
goto error
|
goto error
|
||||||
|
|
@ -791,7 +791,7 @@ reswitch:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if n.Right.Type != nil && Isint[n.Right.Type.Etype] == 0 {
|
if n.Right.Type != nil && !Isint[n.Right.Type.Etype] {
|
||||||
Yyerror("non-integer %s index %v", why, Nconv(n.Right, 0))
|
Yyerror("non-integer %s index %v", why, Nconv(n.Right, 0))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
@ -905,7 +905,7 @@ reswitch:
|
||||||
if Istype(t, TSTRING) {
|
if Istype(t, TSTRING) {
|
||||||
n.Type = t
|
n.Type = t
|
||||||
n.Op = OSLICESTR
|
n.Op = OSLICESTR
|
||||||
} else if Isptr[t.Etype] != 0 && Isfixedarray(t.Type) {
|
} else if Isptr[t.Etype] && Isfixedarray(t.Type) {
|
||||||
tp = t.Type
|
tp = t.Type
|
||||||
n.Type = typ(TARRAY)
|
n.Type = typ(TARRAY)
|
||||||
n.Type.Type = tp.Type
|
n.Type.Type = tp.Type
|
||||||
|
|
@ -965,7 +965,7 @@ reswitch:
|
||||||
goto error
|
goto error
|
||||||
}
|
}
|
||||||
|
|
||||||
if Isptr[t.Etype] != 0 && Isfixedarray(t.Type) {
|
if Isptr[t.Etype] && Isfixedarray(t.Type) {
|
||||||
tp = t.Type
|
tp = t.Type
|
||||||
n.Type = typ(TARRAY)
|
n.Type = typ(TARRAY)
|
||||||
n.Type.Type = tp.Type
|
n.Type.Type = tp.Type
|
||||||
|
|
@ -1136,18 +1136,18 @@ reswitch:
|
||||||
}
|
}
|
||||||
switch n.Op {
|
switch n.Op {
|
||||||
case OCAP:
|
case OCAP:
|
||||||
if okforcap[t.Etype] == 0 {
|
if !okforcap[t.Etype] {
|
||||||
goto badcall1
|
goto badcall1
|
||||||
}
|
}
|
||||||
|
|
||||||
case OLEN:
|
case OLEN:
|
||||||
if okforlen[t.Etype] == 0 {
|
if !okforlen[t.Etype] {
|
||||||
goto badcall1
|
goto badcall1
|
||||||
}
|
}
|
||||||
|
|
||||||
case OREAL,
|
case OREAL,
|
||||||
OIMAG:
|
OIMAG:
|
||||||
if Iscomplex[t.Etype] == 0 {
|
if !Iscomplex[t.Etype] {
|
||||||
goto badcall1
|
goto badcall1
|
||||||
}
|
}
|
||||||
if Isconst(l, CTCPLX) {
|
if Isconst(l, CTCPLX) {
|
||||||
|
|
@ -1808,13 +1808,13 @@ arith:
|
||||||
defaultlit(&r, Types[TUINT])
|
defaultlit(&r, Types[TUINT])
|
||||||
n.Right = r
|
n.Right = r
|
||||||
t := r.Type
|
t := r.Type
|
||||||
if Isint[t.Etype] == 0 || Issigned[t.Etype] != 0 {
|
if !Isint[t.Etype] || Issigned[t.Etype] {
|
||||||
Yyerror("invalid operation: %v (shift count type %v, must be unsigned integer)", Nconv(n, 0), Tconv(r.Type, 0))
|
Yyerror("invalid operation: %v (shift count type %v, must be unsigned integer)", Nconv(n, 0), Tconv(r.Type, 0))
|
||||||
goto error
|
goto error
|
||||||
}
|
}
|
||||||
|
|
||||||
t = l.Type
|
t = l.Type
|
||||||
if t != nil && t.Etype != TIDEAL && Isint[t.Etype] == 0 {
|
if t != nil && t.Etype != TIDEAL && !Isint[t.Etype] {
|
||||||
Yyerror("invalid operation: %v (shift of type %v)", Nconv(n, 0), Tconv(t, 0))
|
Yyerror("invalid operation: %v (shift of type %v)", Nconv(n, 0), Tconv(t, 0))
|
||||||
goto error
|
goto error
|
||||||
}
|
}
|
||||||
|
|
@ -1843,7 +1843,7 @@ arith:
|
||||||
et = TINT
|
et = TINT
|
||||||
}
|
}
|
||||||
aop = 0
|
aop = 0
|
||||||
if iscmp[n.Op] != 0 && t.Etype != TIDEAL && !Eqtype(l.Type, r.Type) {
|
if iscmp[n.Op] && t.Etype != TIDEAL && !Eqtype(l.Type, r.Type) {
|
||||||
// comparison is okay as long as one side is
|
// comparison is okay as long as one side is
|
||||||
// assignable to the other. convert so they have
|
// assignable to the other. convert so they have
|
||||||
// the same type.
|
// the same type.
|
||||||
|
|
@ -1909,7 +1909,7 @@ arith:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if okfor[op][et] == 0 {
|
if !okfor[op][et] {
|
||||||
Yyerror("invalid operation: %v (operator %v not defined on %s)", Nconv(n, 0), Oconv(int(op), 0), typekind(t))
|
Yyerror("invalid operation: %v (operator %v not defined on %s)", Nconv(n, 0), Oconv(int(op), 0), typekind(t))
|
||||||
goto error
|
goto error
|
||||||
}
|
}
|
||||||
|
|
@ -1942,7 +1942,7 @@ arith:
|
||||||
}
|
}
|
||||||
|
|
||||||
t = l.Type
|
t = l.Type
|
||||||
if iscmp[n.Op] != 0 {
|
if iscmp[n.Op] {
|
||||||
evconst(n)
|
evconst(n)
|
||||||
t = idealbool
|
t = idealbool
|
||||||
if n.Op != OLITERAL {
|
if n.Op != OLITERAL {
|
||||||
|
|
@ -1965,7 +1965,7 @@ arith:
|
||||||
}
|
}
|
||||||
|
|
||||||
if et == TSTRING {
|
if et == TSTRING {
|
||||||
if iscmp[n.Op] != 0 {
|
if iscmp[n.Op] {
|
||||||
n.Etype = n.Op
|
n.Etype = n.Op
|
||||||
n.Op = OCMPSTR
|
n.Op = OCMPSTR
|
||||||
} else if n.Op == OADD {
|
} else if n.Op == OADD {
|
||||||
|
|
@ -2123,7 +2123,7 @@ func checksliceindex(l *Node, r *Node, tp *Type) int {
|
||||||
if t == nil {
|
if t == nil {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
if Isint[t.Etype] == 0 {
|
if !Isint[t.Etype] {
|
||||||
Yyerror("invalid slice index %v (type %v)", Nconv(r, 0), Tconv(t, 0))
|
Yyerror("invalid slice index %v (type %v)", Nconv(r, 0), Tconv(t, 0))
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
@ -2215,7 +2215,7 @@ func implicitstar(nn **Node) {
|
||||||
n := *nn
|
n := *nn
|
||||||
|
|
||||||
t := n.Type
|
t := n.Type
|
||||||
if t == nil || Isptr[t.Etype] == 0 {
|
if t == nil || !Isptr[t.Etype] {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
t = t.Type
|
t = t.Type
|
||||||
|
|
@ -2293,7 +2293,7 @@ func lookdot1(errnode *Node, s *Sym, t *Type, f *Type, dostrcmp int) *Type {
|
||||||
if r != nil {
|
if r != nil {
|
||||||
if errnode != nil {
|
if errnode != nil {
|
||||||
Yyerror("ambiguous selector %v", Nconv(errnode, 0))
|
Yyerror("ambiguous selector %v", Nconv(errnode, 0))
|
||||||
} else if Isptr[t.Etype] != 0 {
|
} else if Isptr[t.Etype] {
|
||||||
Yyerror("ambiguous selector (%v).%v", Tconv(t, 0), Sconv(s, 0))
|
Yyerror("ambiguous selector (%v).%v", Tconv(t, 0), Sconv(s, 0))
|
||||||
} else {
|
} else {
|
||||||
Yyerror("ambiguous selector %v.%v", Tconv(t, 0), Sconv(s, 0))
|
Yyerror("ambiguous selector %v.%v", Tconv(t, 0), Sconv(s, 0))
|
||||||
|
|
@ -2338,7 +2338,7 @@ func looktypedot(n *Node, t *Type, dostrcmp int) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// disallow T.m if m requires *T receiver
|
// disallow T.m if m requires *T receiver
|
||||||
if Isptr[getthisx(f2.Type).Type.Type.Etype] != 0 && Isptr[t.Etype] == 0 && f2.Embedded != 2 && !isifacemethod(f2.Type) {
|
if Isptr[getthisx(f2.Type).Type.Type.Etype] && !Isptr[t.Etype] && f2.Embedded != 2 && !isifacemethod(f2.Type) {
|
||||||
Yyerror("invalid method expression %v (needs pointer receiver: (*%v).%v)", Nconv(n, 0), Tconv(t, 0), Sconv(f2.Sym, obj.FmtShort))
|
Yyerror("invalid method expression %v (needs pointer receiver: (*%v).%v)", Nconv(n, 0), Tconv(t, 0), Sconv(f2.Sym, obj.FmtShort))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
@ -2387,7 +2387,7 @@ func lookdot(n *Node, t *Type, dostrcmp int) bool {
|
||||||
n.Type = f1.Type
|
n.Type = f1.Type
|
||||||
n.Paramfld = f1
|
n.Paramfld = f1
|
||||||
if t.Etype == TINTER {
|
if t.Etype == TINTER {
|
||||||
if Isptr[n.Left.Type.Etype] != 0 {
|
if Isptr[n.Left.Type.Etype] {
|
||||||
n.Left = Nod(OIND, n.Left, nil) // implicitstar
|
n.Left = Nod(OIND, n.Left, nil) // implicitstar
|
||||||
n.Left.Implicit = 1
|
n.Left.Implicit = 1
|
||||||
typecheck(&n.Left, Erv)
|
typecheck(&n.Left, Erv)
|
||||||
|
|
@ -2435,7 +2435,7 @@ func lookdot(n *Node, t *Type, dostrcmp int) bool {
|
||||||
ll = ll.Left
|
ll = ll.Left
|
||||||
}
|
}
|
||||||
if ll.Implicit != 0 {
|
if ll.Implicit != 0 {
|
||||||
if Isptr[ll.Type.Etype] != 0 && ll.Type.Sym != nil && ll.Type.Sym.Def != nil && ll.Type.Sym.Def.Op == OTYPE {
|
if Isptr[ll.Type.Etype] && ll.Type.Sym != nil && ll.Type.Sym.Def != nil && ll.Type.Sym.Def.Op == OTYPE {
|
||||||
// It is invalid to automatically dereference a named pointer type when selecting a method.
|
// It is invalid to automatically dereference a named pointer type when selecting a method.
|
||||||
// Make n->left == ll to clarify error message.
|
// Make n->left == ll to clarify error message.
|
||||||
n.Left = ll
|
n.Left = ll
|
||||||
|
|
@ -2876,7 +2876,7 @@ func typecheckcomplit(np **Node) {
|
||||||
nerr = nerrors
|
nerr = nerrors
|
||||||
n.Type = t
|
n.Type = t
|
||||||
|
|
||||||
if Isptr[t.Etype] != 0 {
|
if Isptr[t.Etype] {
|
||||||
// For better or worse, we don't allow pointers as the composite literal type,
|
// For better or worse, we don't allow pointers as the composite literal type,
|
||||||
// except when using the &T syntax, which sets implicit on the OIND.
|
// except when using the &T syntax, which sets implicit on the OIND.
|
||||||
if n.Right.Implicit == 0 {
|
if n.Right.Implicit == 0 {
|
||||||
|
|
@ -3085,7 +3085,7 @@ func typecheckcomplit(np **Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
n.Orig = norig
|
n.Orig = norig
|
||||||
if Isptr[n.Type.Etype] != 0 {
|
if Isptr[n.Type.Etype] {
|
||||||
n = Nod(OPTRLIT, n, nil)
|
n = Nod(OPTRLIT, n, nil)
|
||||||
n.Typecheck = 1
|
n.Typecheck = 1
|
||||||
n.Type = n.Left.Type
|
n.Type = n.Left.Type
|
||||||
|
|
@ -3538,7 +3538,7 @@ func copytype(n *Node, t *Type) {
|
||||||
|
|
||||||
if embedlineno != 0 {
|
if embedlineno != 0 {
|
||||||
lineno = int32(embedlineno)
|
lineno = int32(embedlineno)
|
||||||
if Isptr[t.Etype] != 0 {
|
if Isptr[t.Etype] {
|
||||||
Yyerror("embedded type cannot be a pointer")
|
Yyerror("embedded type cannot be a pointer")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3705,7 +3705,7 @@ func typecheckdef(n *Node) *Node {
|
||||||
|
|
||||||
t := n.Type
|
t := n.Type
|
||||||
if t != nil {
|
if t != nil {
|
||||||
if okforconst[t.Etype] == 0 {
|
if !okforconst[t.Etype] {
|
||||||
Yyerror("invalid constant type %v", Tconv(t, 0))
|
Yyerror("invalid constant type %v", Tconv(t, 0))
|
||||||
goto ret
|
goto ret
|
||||||
}
|
}
|
||||||
|
|
@ -3826,7 +3826,7 @@ func checkmake(t *Type, arg string, n *Node) int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if Isint[n.Type.Etype] == 0 && n.Type.Etype != TIDEAL {
|
if !Isint[n.Type.Etype] && n.Type.Etype != TIDEAL {
|
||||||
Yyerror("non-integer %s argument in make(%v) - %v", arg, Tconv(t, 0), Tconv(n.Type, 0))
|
Yyerror("non-integer %s argument in make(%v) - %v", arg, Tconv(t, 0), Tconv(n.Type, 0))
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -479,7 +479,7 @@ func walkexpr(np **Node, init **NodeList) {
|
||||||
// delayed until now to preserve side effects.
|
// delayed until now to preserve side effects.
|
||||||
t := n.Left.Type
|
t := n.Left.Type
|
||||||
|
|
||||||
if Isptr[t.Etype] != 0 {
|
if Isptr[t.Etype] {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
}
|
}
|
||||||
if Isfixedarray(t) {
|
if Isfixedarray(t) {
|
||||||
|
|
@ -1032,7 +1032,7 @@ func walkexpr(np **Node, init **NodeList) {
|
||||||
case OCONV,
|
case OCONV,
|
||||||
OCONVNOP:
|
OCONVNOP:
|
||||||
if Thearch.Thechar == '5' {
|
if Thearch.Thechar == '5' {
|
||||||
if Isfloat[n.Left.Type.Etype] != 0 {
|
if Isfloat[n.Left.Type.Etype] {
|
||||||
if n.Type.Etype == TINT64 {
|
if n.Type.Etype == TINT64 {
|
||||||
n = mkcall("float64toint64", n.Type, init, conv(n.Left, Types[TFLOAT64]))
|
n = mkcall("float64toint64", n.Type, init, conv(n.Left, Types[TFLOAT64]))
|
||||||
goto ret
|
goto ret
|
||||||
|
|
@ -1044,7 +1044,7 @@ func walkexpr(np **Node, init **NodeList) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if Isfloat[n.Type.Etype] != 0 {
|
if Isfloat[n.Type.Etype] {
|
||||||
if n.Left.Type.Etype == TINT64 {
|
if n.Left.Type.Etype == TINT64 {
|
||||||
n = mkcall("int64tofloat64", n.Type, init, conv(n.Left, Types[TINT64]))
|
n = mkcall("int64tofloat64", n.Type, init, conv(n.Left, Types[TINT64]))
|
||||||
goto ret
|
goto ret
|
||||||
|
|
@ -1084,7 +1084,7 @@ func walkexpr(np **Node, init **NodeList) {
|
||||||
*/
|
*/
|
||||||
et := int(n.Left.Type.Etype)
|
et := int(n.Left.Type.Etype)
|
||||||
|
|
||||||
if Iscomplex[et] != 0 && n.Op == ODIV {
|
if Iscomplex[et] && n.Op == ODIV {
|
||||||
t := n.Type
|
t := n.Type
|
||||||
n = mkcall("complex128div", Types[TCOMPLEX128], init, conv(n.Left, Types[TCOMPLEX128]), conv(n.Right, Types[TCOMPLEX128]))
|
n = mkcall("complex128div", Types[TCOMPLEX128], init, conv(n.Left, Types[TCOMPLEX128]), conv(n.Right, Types[TCOMPLEX128]))
|
||||||
n = conv(n, t)
|
n = conv(n, t)
|
||||||
|
|
@ -1092,7 +1092,7 @@ func walkexpr(np **Node, init **NodeList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing to do for float divisions.
|
// Nothing to do for float divisions.
|
||||||
if Isfloat[et] != 0 {
|
if Isfloat[et] {
|
||||||
goto ret
|
goto ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1142,7 +1142,7 @@ func walkexpr(np **Node, init **NodeList) {
|
||||||
goto ret
|
goto ret
|
||||||
}
|
}
|
||||||
t := n.Left.Type
|
t := n.Left.Type
|
||||||
if t != nil && Isptr[t.Etype] != 0 {
|
if t != nil && Isptr[t.Etype] {
|
||||||
t = t.Type
|
t = t.Type
|
||||||
}
|
}
|
||||||
if Isfixedarray(t) {
|
if Isfixedarray(t) {
|
||||||
|
|
@ -2005,13 +2005,13 @@ func walkprint(nn *Node, init **NodeList) *Node {
|
||||||
on = syslook("printiface", 1)
|
on = syslook("printiface", 1)
|
||||||
}
|
}
|
||||||
argtype(on, n.Type) // any-1
|
argtype(on, n.Type) // any-1
|
||||||
} else if Isptr[et] != 0 || et == TCHAN || et == TMAP || et == TFUNC || et == TUNSAFEPTR {
|
} else if Isptr[et] || et == TCHAN || et == TMAP || et == TFUNC || et == TUNSAFEPTR {
|
||||||
on = syslook("printpointer", 1)
|
on = syslook("printpointer", 1)
|
||||||
argtype(on, n.Type) // any-1
|
argtype(on, n.Type) // any-1
|
||||||
} else if Isslice(n.Type) {
|
} else if Isslice(n.Type) {
|
||||||
on = syslook("printslice", 1)
|
on = syslook("printslice", 1)
|
||||||
argtype(on, n.Type) // any-1
|
argtype(on, n.Type) // any-1
|
||||||
} else if Isint[et] != 0 {
|
} else if Isint[et] {
|
||||||
if et == TUINT64 {
|
if et == TUINT64 {
|
||||||
if (t.Sym.Pkg == Runtimepkg || compiling_runtime != 0) && t.Sym.Name == "hex" {
|
if (t.Sym.Pkg == Runtimepkg || compiling_runtime != 0) && t.Sym.Name == "hex" {
|
||||||
on = syslook("printhex", 0)
|
on = syslook("printhex", 0)
|
||||||
|
|
@ -2021,9 +2021,9 @@ func walkprint(nn *Node, init **NodeList) *Node {
|
||||||
} else {
|
} else {
|
||||||
on = syslook("printint", 0)
|
on = syslook("printint", 0)
|
||||||
}
|
}
|
||||||
} else if Isfloat[et] != 0 {
|
} else if Isfloat[et] {
|
||||||
on = syslook("printfloat", 0)
|
on = syslook("printfloat", 0)
|
||||||
} else if Iscomplex[et] != 0 {
|
} else if Iscomplex[et] {
|
||||||
on = syslook("printcomplex", 0)
|
on = syslook("printcomplex", 0)
|
||||||
} else if et == TBOOL {
|
} else if et == TBOOL {
|
||||||
on = syslook("printbool", 0)
|
on = syslook("printbool", 0)
|
||||||
|
|
@ -3515,7 +3515,7 @@ func walkcompare(np **Node, init **NodeList) {
|
||||||
andor = OOROR
|
andor = OOROR
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.Etype == TARRAY && t.Bound <= 4 && issimple[t.Type.Etype] != 0 {
|
if t.Etype == TARRAY && t.Bound <= 4 && issimple[t.Type.Etype] {
|
||||||
// Four or fewer elements of a basic type.
|
// Four or fewer elements of a basic type.
|
||||||
// Unroll comparisons.
|
// Unroll comparisons.
|
||||||
var li *Node
|
var li *Node
|
||||||
|
|
@ -3636,7 +3636,7 @@ func walkrotate(np **Node) {
|
||||||
l := n.Left
|
l := n.Left
|
||||||
|
|
||||||
r := n.Right
|
r := n.Right
|
||||||
if (n.Op != OOR && n.Op != OXOR) || (l.Op != OLSH && l.Op != ORSH) || (r.Op != OLSH && r.Op != ORSH) || n.Type == nil || Issigned[n.Type.Etype] != 0 || l.Op == r.Op {
|
if (n.Op != OOR && n.Op != OXOR) || (l.Op != OLSH && l.Op != ORSH) || (r.Op != OLSH && r.Op != ORSH) || n.Type == nil || Issigned[n.Type.Etype] || l.Op == r.Op {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3684,7 +3684,7 @@ func walkrotate(np **Node) {
|
||||||
*/
|
*/
|
||||||
func walkmul(np **Node, init **NodeList) {
|
func walkmul(np **Node, init **NodeList) {
|
||||||
n := *np
|
n := *np
|
||||||
if Isint[n.Type.Etype] == 0 {
|
if !Isint[n.Type.Etype] {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3797,7 +3797,7 @@ func walkdiv(np **Node, init **NodeList) {
|
||||||
var m Magic
|
var m Magic
|
||||||
m.W = w
|
m.W = w
|
||||||
|
|
||||||
if Issigned[nl.Type.Etype] != 0 {
|
if Issigned[nl.Type.Etype] {
|
||||||
m.Sd = Mpgetfix(nr.Val.U.Xval)
|
m.Sd = Mpgetfix(nr.Val.U.Xval)
|
||||||
Smagic(&m)
|
Smagic(&m)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -3926,7 +3926,7 @@ func walkdiv(np **Node, init **NodeList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if Issigned[n.Type.Etype] != 0 {
|
if Issigned[n.Type.Etype] {
|
||||||
if n.Op == OMOD {
|
if n.Op == OMOD {
|
||||||
// signed modulo 2^pow is like ANDing
|
// signed modulo 2^pow is like ANDing
|
||||||
// with the last pow bits, but if nl < 0,
|
// with the last pow bits, but if nl < 0,
|
||||||
|
|
@ -4023,11 +4023,11 @@ ret:
|
||||||
|
|
||||||
// return 1 if integer n must be in range [0, max), 0 otherwise
|
// return 1 if integer n must be in range [0, max), 0 otherwise
|
||||||
func bounded(n *Node, max int64) bool {
|
func bounded(n *Node, max int64) bool {
|
||||||
if n.Type == nil || Isint[n.Type.Etype] == 0 {
|
if n.Type == nil || !Isint[n.Type.Etype] {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
sign := int(Issigned[n.Type.Etype])
|
sign := Issigned[n.Type.Etype]
|
||||||
bits := int32(8 * n.Type.Width)
|
bits := int32(8 * n.Type.Width)
|
||||||
|
|
||||||
if Smallintconst(n) {
|
if Smallintconst(n) {
|
||||||
|
|
@ -4049,7 +4049,7 @@ func bounded(n *Node, max int64) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
case OMOD:
|
case OMOD:
|
||||||
if sign == 0 && Smallintconst(n.Right) {
|
if !sign && Smallintconst(n.Right) {
|
||||||
v := Mpgetfix(n.Right.Val.U.Xval)
|
v := Mpgetfix(n.Right.Val.U.Xval)
|
||||||
if 0 <= v && v <= max {
|
if 0 <= v && v <= max {
|
||||||
return true
|
return true
|
||||||
|
|
@ -4057,7 +4057,7 @@ func bounded(n *Node, max int64) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
case ODIV:
|
case ODIV:
|
||||||
if sign == 0 && Smallintconst(n.Right) {
|
if !sign && Smallintconst(n.Right) {
|
||||||
v := Mpgetfix(n.Right.Val.U.Xval)
|
v := Mpgetfix(n.Right.Val.U.Xval)
|
||||||
for bits > 0 && v >= 2 {
|
for bits > 0 && v >= 2 {
|
||||||
bits--
|
bits--
|
||||||
|
|
@ -4066,7 +4066,7 @@ func bounded(n *Node, max int64) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
case ORSH:
|
case ORSH:
|
||||||
if sign == 0 && Smallintconst(n.Right) {
|
if !sign && Smallintconst(n.Right) {
|
||||||
v := Mpgetfix(n.Right.Val.U.Xval)
|
v := Mpgetfix(n.Right.Val.U.Xval)
|
||||||
if v > int64(bits) {
|
if v > int64(bits) {
|
||||||
return true
|
return true
|
||||||
|
|
@ -4075,7 +4075,7 @@ func bounded(n *Node, max int64) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if sign == 0 && bits <= 62 && 1<<uint(bits) <= max {
|
if !sign && bits <= 62 && 1<<uint(bits) <= max {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4110,7 +4110,7 @@ func usefield(n *Node) {
|
||||||
}
|
}
|
||||||
field.Lastfn = Curfn
|
field.Lastfn = Curfn
|
||||||
field.Outer = n.Left.Type
|
field.Outer = n.Left.Type
|
||||||
if Isptr[field.Outer.Etype] != 0 {
|
if Isptr[field.Outer.Etype] {
|
||||||
field.Outer = field.Outer.Type
|
field.Outer = field.Outer.Type
|
||||||
}
|
}
|
||||||
if field.Outer.Sym == nil {
|
if field.Outer.Sym == nil {
|
||||||
|
|
|
||||||
|
|
@ -3394,7 +3394,7 @@ yydefault:
|
||||||
yyVAL.node.Val = yyDollar[3].val
|
yyVAL.node.Val = yyDollar[3].val
|
||||||
} else {
|
} else {
|
||||||
s = yyDollar[2].typ.Sym
|
s = yyDollar[2].typ.Sym
|
||||||
if s == nil && Isptr[yyDollar[2].typ.Etype] != 0 {
|
if s == nil && Isptr[yyDollar[2].typ.Etype] {
|
||||||
s = yyDollar[2].typ.Type.Sym
|
s = yyDollar[2].typ.Type.Sym
|
||||||
}
|
}
|
||||||
p = importpkg
|
p = importpkg
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue