internal/lib/reflect: Value.InterfaceData
This commit is contained in:
@@ -791,18 +791,15 @@ func valueInterface(v Value, safe bool) any {
|
|||||||
// Deprecated: The memory representation of interface values is not
|
// Deprecated: The memory representation of interface values is not
|
||||||
// compatible with InterfaceData.
|
// compatible with InterfaceData.
|
||||||
func (v Value) InterfaceData() [2]uintptr {
|
func (v Value) InterfaceData() [2]uintptr {
|
||||||
/*
|
v.mustBe(Interface)
|
||||||
v.mustBe(Interface)
|
// The compiler loses track as it converts to uintptr. Force escape.
|
||||||
// The compiler loses track as it converts to uintptr. Force escape.
|
escapes(v.ptr)
|
||||||
escapes(v.ptr)
|
// We treat this as a read operation, so we allow
|
||||||
// We treat this as a read operation, so we allow
|
// it even for unexported data, because the caller
|
||||||
// it even for unexported data, because the caller
|
// has to import "unsafe" to turn it into something
|
||||||
// has to import "unsafe" to turn it into something
|
// that can be abused.
|
||||||
// that can be abused.
|
// Interface value is always bigger than a word; assume flagIndir.
|
||||||
// Interface value is always bigger than a word; assume flagIndir.
|
return *(*[2]uintptr)(v.ptr)
|
||||||
return *(*[2]uintptr)(v.ptr)
|
|
||||||
*/
|
|
||||||
panic("todo: reflect.Value.InterfaceData")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNil reports whether its argument v is nil. The argument must be
|
// IsNil reports whether its argument v is nil. The argument must be
|
||||||
@@ -1035,6 +1032,8 @@ func (v Value) Pointer() uintptr {
|
|||||||
// so their Pointers are equal. The function used here must
|
// so their Pointers are equal. The function used here must
|
||||||
// match the one used in makeMethodValue.
|
// match the one used in makeMethodValue.
|
||||||
// return methodValueCallCodePtr()
|
// return methodValueCallCodePtr()
|
||||||
|
_, _, fn := methodReceiver("unsafePointer", v, int(v.flag)>>flagMethodShift)
|
||||||
|
return uintptr(fn)
|
||||||
}
|
}
|
||||||
p := v.pointer()
|
p := v.pointer()
|
||||||
// Non-nil func value points at data block.
|
// Non-nil func value points at data block.
|
||||||
|
|||||||
Reference in New Issue
Block a user