}
// pointer returns the underlying pointer represented by v.
-// v.Kind() must be Ptr, Map, Chan, Func, or UnsafePointer
+// v.Kind() must be Pointer, Map, Chan, Func, or UnsafePointer
func (v Value) pointer() unsafe.Pointer {
if v.typ.size != goarch.PtrSize || !v.typ.pointers() {
panic("can't call pointer on a non-pointer Value")
// Elem returns the value that the interface v contains
// or that the pointer v points to.
-// It panics if v's Kind is not Interface or Ptr.
+// It panics if v's Kind is not Interface or Pointer.
// It returns the zero Value if v is nil.
func (v Value) Elem() Value {
k := v.kind()
x.flag |= v.flag.ro()
}
return x
- case Ptr:
+ case Pointer:
ptr := v.ptr
if v.flag&flagIndir != 0 {
ptr = *(*unsafe.Pointer)(ptr)
func (v Value) IsNil() bool {
k := v.kind()
switch k {
- case Chan, Func, Map, Ptr, UnsafePointer:
+ case Chan, Func, Map, Pointer, UnsafePointer:
// if v.flag&flagMethod != 0 {
// return false
// }
// Chan: ChanDir, Elem
// Func: In, NumIn, Out, NumOut, IsVariadic.
// Map: Key, Elem
- // Ptr: Elem
+ // Pointer: Elem
// Slice: Elem
// Struct: Field, FieldByIndex, FieldByName, FieldByNameFunc, NumField
IsVariadic() bool
// Elem returns a type's element type.
- // It panics if the type's Kind is not Array, Chan, Map, Ptr, or Slice.
+ // It panics if the type's Kind is not Array, Chan, Map, Pointer, or Slice.
Elem() Type
// Field returns a struct type's i'th field.
Func
Interface
Map
- Ptr
+ Pointer
Slice
String
Struct
UnsafePointer
)
+// Ptr is the old name for the Pointer kind.
+//
+// Deprecated: use the new spelling, Pointer.
+const Ptr = Pointer
+
// tflag is used by an rtype to signal what extra type information is
// available in the memory directly following the rtype value.
//
Func: "func",
Interface: "interface",
Map: "map",
- Ptr: "ptr",
+ Pointer: "ptr",
Slice: "slice",
String: "string",
Struct: "struct",
switch t.Kind() {
case Struct:
return &(*structTypeUncommon)(unsafe.Pointer(t)).u
- case Ptr:
+ case Pointer:
type u struct {
ptrType
u uncommonType
case Map:
tt := (*mapType)(unsafe.Pointer(t))
return toType(tt.elem)
- case Ptr:
+ case Pointer:
tt := (*ptrType)(unsafe.Pointer(t))
return toType(tt.elem)
case Slice:
for i, x := range index {
if i > 0 {
ft := f.Type
- if ft.Kind() == Ptr && ft.Elem().Kind() == Struct {
+ if ft.Kind() == Pointer && ft.Elem().Kind() == Struct {
ft = ft.Elem()
}
f.Type = ft
if f.embedded() {
// Embedded field of type T or *T.
ntyp = f.typ
- if ntyp.Kind() == Ptr {
+ if ntyp.Kind() == Pointer {
ntyp = ntyp.Elem().common()
}
}
return toType(eface.typ)
}
-// ptrMap is the cache for PtrTo.
+// ptrMap is the cache for PointerTo.
var ptrMap sync.Map // map[*rtype]*ptrType
// PtrTo returns the pointer type with element t.
// For example, if t represents type Foo, PtrTo(t) represents *Foo.
-func PtrTo(t Type) Type {
+//
+// Deprecated: use PointerTo. PtrTo is the old spelling.
+// The two functions behaves identically.
+func PtrTo(t Type) Type { return PointerTo(t) }
+
+// PointerTo returns the pointer type with element t.
+// For example, if t represents type Foo, PointerTo(t) represents *Foo.
+func PointerTo(t Type) Type {
return t.(*rtype).ptrTo()
}
case Map:
return haveIdenticalType(T.Key(), V.Key(), cmpTags) && haveIdenticalType(T.Elem(), V.Elem(), cmpTags)
- case Ptr, Slice:
+ case Pointer, Slice:
return haveIdenticalType(T.Elem(), V.Elem(), cmpTags)
case Struct:
// That is, x == x for all values x of type t.
func isReflexive(t *rtype) bool {
switch t.Kind() {
- case Bool, Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, Uintptr, Chan, Ptr, String, UnsafePointer:
+ case Bool, Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, Uintptr, Chan, Pointer, String, UnsafePointer:
return true
case Float32, Float64, Complex64, Complex128, Interface:
return false
// needKeyUpdate reports whether map overwrites require the key to be copied.
func needKeyUpdate(t *rtype) bool {
switch t.Kind() {
- case Bool, Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, Uintptr, Chan, Ptr, UnsafePointer:
+ case Bool, Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, Uintptr, Chan, Pointer, UnsafePointer:
return false
case Float32, Float64, Complex64, Complex128, Interface, String:
// Float keys can be updated from +0 to -0.
func bucketOf(ktyp, etyp *rtype) *rtype {
if ktyp.size > maxKeySize {
- ktyp = PtrTo(ktyp).(*rtype)
+ ktyp = PointerTo(ktyp).(*rtype)
}
if etyp.size > maxValSize {
- etyp = PtrTo(etyp).(*rtype)
+ etyp = PointerTo(etyp).(*rtype)
}
// Prepare GC data if any.
repr = append(repr, (" " + name)...)
if f.embedded() {
// Embedded field
- if f.typ.Kind() == Ptr {
+ if f.typ.Kind() == Pointer {
// Embedded ** and *interface{} are illegal
elem := ft.Elem()
- if k := elem.Kind(); k == Ptr || k == Interface {
+ if k := elem.Kind(); k == Pointer || k == Interface {
panic("reflect.StructOf: illegal embedded field type " + ft.String())
}
}
tfn: resolveReflectText(unsafe.Pointer(&tfn)),
})
}
- case Ptr:
+ case Pointer:
ptr := (*ptrType)(unsafe.Pointer(ft))
if unt := ptr.uncommon(); unt != nil {
if i > 0 && unt.mcount > 0 {
}
switch Kind(t.kind & kindMask) {
- case Chan, Func, Map, Ptr, Slice, String, UnsafePointer:
+ case Chan, Func, Map, Pointer, Slice, String, UnsafePointer:
// 1 pointer at start of representation
for bv.n < uint32(offset/uintptr(goarch.PtrSize)) {
bv.append(0)