cmd/compile: use NumElem instead of Type.Bound
This eliminates all direct reads of Type.Bound
outside type.go.
Change-Id: I0a9a72539f8f4c0de7f5e05e1821936bf7db5eb7
Reviewed-on: https://go-review.googlesource.com/21421
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go
index 9310171..3758aa0 100644
--- a/src/cmd/compile/internal/gc/walk.go
+++ b/src/cmd/compile/internal/gc/walk.go
@@ -546,7 +546,7 @@
}
if t.IsArray() {
safeexpr(n.Left, init)
- Nodconst(n, n.Type, t.Bound)
+ Nodconst(n, n.Type, t.NumElem())
n.Typecheck = 1
}
@@ -1158,7 +1158,7 @@
t = t.Elem()
}
if t.IsArray() {
- n.Bounded = bounded(r, t.Bound)
+ n.Bounded = bounded(r, t.NumElem())
if Debug['m'] != 0 && n.Bounded && !Isconst(n.Right, CTINT) {
Warn("index bounds check elided")
}
@@ -3145,12 +3145,12 @@
}
var expr *Node
- if t.Etype == TARRAY && t.Bound <= 4 && issimple[t.Elem().Etype] {
+ if t.Etype == TARRAY && t.NumElem() <= 4 && issimple[t.Elem().Etype] {
// Four or fewer elements of a basic type.
// Unroll comparisons.
var li *Node
var ri *Node
- for i := 0; int64(i) < t.Bound; i++ {
+ for i := 0; int64(i) < t.NumElem(); i++ {
li = Nod(OINDEX, l, Nodintconst(int64(i)))
ri = Nod(OINDEX, r, Nodintconst(int64(i)))
a = Nod(n.Op, li, ri)
@@ -3170,7 +3170,7 @@
if t.Etype == TARRAY {
// Zero- or single-element array, of any type.
- switch t.Bound {
+ switch t.NumElem() {
case 0:
n = finishcompare(n, Nodbool(n.Op == OEQ), init)
return n