Source File
value.go
Belonging Package
internal/reflectlite
}
type flag uintptr
const (
flagKindWidth = 5 // there are 27 kinds
flagKindMask flag = 1<<flagKindWidth - 1
flagStickyRO flag = 1 << 5
flagEmbedRO flag = 1 << 6
flagIndir flag = 1 << 7
flagAddr flag = 1 << 8
flagMethod flag = 1 << 9
flagMethodShift = 10
flagRO flag = flagStickyRO | flagEmbedRO
)
func ( flag) () Kind {
return Kind( & flagKindMask)
}
func ( flag) () flag {
if &flagRO != 0 {
return flagStickyRO
}
return 0
}
switch {
case ifaceIndir():
if .flag&flagIndir == 0 {
panic("bad indir")
:= .ptr
:= unsafe_New()
typedmemmove(, , )
=
}
.word =
.typ =
return
}
func ( interface{}) Value {
func ( flag) () {
if == 0 {
panic(&ValueError{methodName(), 0})
}
if &flagRO != 0 {
panic("reflect: " + methodName() + " using value obtained using unexported field")
}
}
func ( flag) () {
if == 0 {
panic(&ValueError{methodName(), Invalid})
if &flagRO != 0 {
panic("reflect: " + methodName() + " using value obtained using unexported field")
}
if &flagAddr == 0 {
panic("reflect: " + methodName() + " using unaddressable value")
}
}
func ( Value) () Value {
:= .kind()
switch {
case Interface:
var interface{}
if .typ.NumMethod() == 0 {
= *(*interface{})(.ptr)
} else {
= (interface{})(*(*interface {
()
})(.ptr))
}
:= unpackEface()
if .flag != 0 {
.flag |= .flag.ro()
}
return
case Ptr:
:= .ptr
if .flag&flagIndir != 0 {
= *(*unsafe.Pointer)()
if == nil {
return Value{}
}
:= (*ptrType)(unsafe.Pointer(.typ))
:= .elem
:= .flag&flagRO | flagIndir | flagAddr
|= flag(.Kind())
return Value{, , }
}
panic(&ValueError{"reflectlite.Value.Elem", .kind()})
}
func ( Value) interface{} {
if .flag == 0 {
panic(&ValueError{"reflectlite.Value.Interface", 0})
}
return packEface()
}
return (*unsafeheader.Slice)(.ptr).Len
return (*unsafeheader.String)(.ptr).Len
}
panic(&ValueError{"reflect.Value.Len", .kind()})
}
return .typ
}
escapes()
return unpackEface()
}
switch {
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |