internal/lib/reflect: Value.Type
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -553,6 +553,22 @@ func (t *Type) InterfaceType() *InterfaceType {
|
|||||||
return (*InterfaceType)(unsafe.Pointer(t))
|
return (*InterfaceType)(unsafe.Pointer(t))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Type) ExportedMethods() []Method {
|
||||||
|
ut := t.Uncommon()
|
||||||
|
if ut == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return ut.ExportedMethods()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Type) NumMethod() int {
|
||||||
|
if t.Kind() == Interface {
|
||||||
|
tt := (*InterfaceType)(unsafe.Pointer(t))
|
||||||
|
return tt.NumMethod()
|
||||||
|
}
|
||||||
|
return len(t.ExportedMethods())
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
// addChecked returns p+x.
|
// addChecked returns p+x.
|
||||||
|
|||||||
@@ -1525,7 +1525,6 @@ func (v Value) Type() Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v Value) typeSlow() Type {
|
func (v Value) typeSlow() Type {
|
||||||
/* TODO(xsw):
|
|
||||||
if v.flag == 0 {
|
if v.flag == 0 {
|
||||||
panic(&ValueError{"reflect.Value.Type", Invalid})
|
panic(&ValueError{"reflect.Value.Type", Invalid})
|
||||||
}
|
}
|
||||||
@@ -1545,7 +1544,7 @@ func (v Value) typeSlow() Type {
|
|||||||
panic("reflect: internal error: invalid method index")
|
panic("reflect: internal error: invalid method index")
|
||||||
}
|
}
|
||||||
m := &tt.Methods[i]
|
m := &tt.Methods[i]
|
||||||
return toRType(typeOffFor(typ, m.Typ))
|
return toRType(&m.Typ_.Type)
|
||||||
}
|
}
|
||||||
// Method on concrete type.
|
// Method on concrete type.
|
||||||
ms := typ.ExportedMethods()
|
ms := typ.ExportedMethods()
|
||||||
@@ -1553,9 +1552,7 @@ func (v Value) typeSlow() Type {
|
|||||||
panic("reflect: internal error: invalid method index")
|
panic("reflect: internal error: invalid method index")
|
||||||
}
|
}
|
||||||
m := ms[i]
|
m := ms[i]
|
||||||
return toRType(typeOffFor(typ, m.Mtyp))
|
return toRType(&m.Mtyp_.Type)
|
||||||
*/
|
|
||||||
panic("todo: reflect.Value.Type")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CanUint reports whether Uint can be used without panicking.
|
// CanUint reports whether Uint can be used without panicking.
|
||||||
|
|||||||
Reference in New Issue
Block a user