GoString() string
}
+// getter is implemented by any value that has a Get() method,
+// which means the object contains a pointer. Used by %p.
+type getter interface {
+ Get() uintptr
+}
+
const allocSize = 32
type pp struct {
// pointer, including addresses of reference types.
case 'p':
switch v := field.(type) {
- case *reflect.PtrValue:
+ case getter:
p.fmt.fmt_s("0x")
p.fmt.fmt_uX64(uint64(v.Get()))
- case *reflect.ChanValue, *reflect.MapValue, *reflect.SliceValue:
- p.fmt.fmt_s("0x")
- p.fmt.fmt_uX64(uint64(field.Addr()))
default:
goto badtype
}
// Set sets v to the value x.
func (v *SliceValue) SetValue(x Value) { v.Set(x.(*SliceValue)) }
+// Get returns the uintptr address of the v.Cap()'th element. This gives
+// the same result for all slices of the same array.
+// It is mainly useful for printing.
+func (v *SliceValue) Get() uintptr {
+ typ := v.typ.(*SliceType)
+ return uintptr(v.addr()) + uintptr(v.Cap())*typ.Elem().Size()
+}
+
// Slice returns a sub-slice of the slice v.
func (v *SliceValue) Slice(beg, end int) *SliceValue {
cap := v.Cap()
// Set sets v to the value x.
func (v *MapValue) SetValue(x Value) { v.Set(x.(*MapValue)) }
+// Get returns the uintptr value of v.
+// It is mainly useful for printing.
+func (v *MapValue) Get() uintptr { return *(*uintptr)(v.addr) }
+
// implemented in ../pkg/runtime/reflect.cgo
func mapaccess(m, key, val *byte) bool
func mapassign(m, key, val *byte)