aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types/type.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2020-08-22 14:07:30 -0700
committerKeith Randall <khr@golang.org>2020-08-23 18:33:55 +0000
commit623652e73fa694eacac9e4b93049817615f1be1d (patch)
tree9e2eb2b85c7966dee61fe9f8a786dabdfce1752e /src/cmd/compile/internal/types/type.go
parent0c3bf27b9789e6e6e7d10c47f08163111ce6d9de (diff)
downloadgo-623652e73fa694eacac9e4b93049817615f1be1d.tar.gz
go-623652e73fa694eacac9e4b93049817615f1be1d.zip
cmd/compile: make Haspointers a method instead of a function
More ergonomic that way. Also change Haspointers to HasPointers while we are here. Change-Id: I45bedc294c1a8c2bd01dc14bd04615ae77555375 Reviewed-on: https://go-review.googlesource.com/c/go/+/249959 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types/type.go')
-rw-r--r--src/cmd/compile/internal/types/type.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/cmd/compile/internal/types/type.go b/src/cmd/compile/internal/types/type.go
index 91b54b43d4..20ae856bba 100644
--- a/src/cmd/compile/internal/types/type.go
+++ b/src/cmd/compile/internal/types/type.go
@@ -1401,11 +1401,11 @@ func (t *Type) IsUntyped() bool {
// TODO(austin): We probably only need HasHeapPointer. See
// golang.org/cl/73412 for discussion.
-func Haspointers(t *Type) bool {
- return Haspointers1(t, false)
+func (t *Type) HasPointers() bool {
+ return t.hasPointers1(false)
}
-func Haspointers1(t *Type, ignoreNotInHeap bool) bool {
+func (t *Type) hasPointers1(ignoreNotInHeap bool) bool {
switch t.Etype {
case TINT, TUINT, TINT8, TUINT8, TINT16, TUINT16, TINT32, TUINT32, TINT64,
TUINT64, TUINTPTR, TFLOAT32, TFLOAT64, TCOMPLEX64, TCOMPLEX128, TBOOL, TSSA:
@@ -1415,11 +1415,11 @@ func Haspointers1(t *Type, ignoreNotInHeap bool) bool {
if t.NumElem() == 0 { // empty array has no pointers
return false
}
- return Haspointers1(t.Elem(), ignoreNotInHeap)
+ return t.Elem().hasPointers1(ignoreNotInHeap)
case TSTRUCT:
for _, t1 := range t.Fields().Slice() {
- if Haspointers1(t1.Type, ignoreNotInHeap) {
+ if t1.Type.hasPointers1(ignoreNotInHeap) {
return true
}
}
@@ -1430,7 +1430,7 @@ func Haspointers1(t *Type, ignoreNotInHeap bool) bool {
case TTUPLE:
ttup := t.Extra.(*Tuple)
- return Haspointers1(ttup.first, ignoreNotInHeap) || Haspointers1(ttup.second, ignoreNotInHeap)
+ return ttup.first.hasPointers1(ignoreNotInHeap) || ttup.second.hasPointers1(ignoreNotInHeap)
}
return true
@@ -1440,7 +1440,7 @@ func Haspointers1(t *Type, ignoreNotInHeap bool) bool {
// This is used for write barrier insertion, so it ignores
// pointers to go:notinheap types.
func (t *Type) HasHeapPointer() bool {
- return Haspointers1(t, true)
+ return t.hasPointers1(true)
}
func (t *Type) Symbol() *obj.LSym {
@@ -1471,7 +1471,7 @@ func FakeRecvType() *Type {
}
var (
- // TSSA types. Haspointers assumes these are pointer-free.
+ // TSSA types. HasPointers assumes these are pointer-free.
TypeInvalid = newSSA("invalid")
TypeMem = newSSA("mem")
TypeFlags = newSSA("flags")