reflect.valueInterface

This commit is contained in:
xushiwei
2024-07-16 22:20:20 +08:00
parent ade0d38a7c
commit 410617f73b

View File

@@ -747,7 +747,6 @@ func (v Value) Interface() (i any) {
} }
func valueInterface(v Value, safe bool) any { func valueInterface(v Value, safe bool) any {
/*
if v.flag == 0 { if v.flag == 0 {
panic(&ValueError{"reflect.Value.Interface", Invalid}) panic(&ValueError{"reflect.Value.Interface", Invalid})
} }
@@ -762,6 +761,7 @@ func valueInterface(v Value, safe bool) any {
} }
if v.kind() == Interface { if v.kind() == Interface {
/* TODO(xsw):
// Special case: return the element inside the interface. // Special case: return the element inside the interface.
// Empty interface has one layout, all interfaces with // Empty interface has one layout, all interfaces with
// methods have a second layout. // methods have a second layout.
@@ -771,12 +771,12 @@ func valueInterface(v Value, safe bool) any {
return *(*interface { return *(*interface {
M() M()
})(v.ptr) })(v.ptr)
*/
panic("todo: reflect.valueInterface")
} }
// TODO: pass safe to packEface so we don't need to copy if safe==true? // TODO: pass safe to packEface so we don't need to copy if safe==true?
return packEface(v) return packEface(v)
*/
panic("todo: reflect.valueInterface")
} }
// InterfaceData returns a pair of unspecified uintptr values. // InterfaceData returns a pair of unspecified uintptr values.