Skip to content

Commit

Permalink
add _type.uncommon
Browse files Browse the repository at this point in the history
  • Loading branch information
pkujhd committed Jul 27, 2024
1 parent e522b5b commit f5b4fbd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions type.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ type uncommonType struct {
_ uint32 // unused
}

func (t *uncommonType) methods() []method {
if t.mcount == 0 {
return nil
}
return (*[1 << 16]method)(add(unsafe.Pointer(t), uintptr(t.moff)))[:t.mcount:t.mcount]
}

//go:linkname _uncommon reflect.(*rtype).uncommon
func _uncommon(t *_type) *uncommonType

//go:linkname _Kind reflect.(*rtype).Kind
func _Kind(t *_type) reflect.Kind

Expand Down Expand Up @@ -128,6 +138,7 @@ func _PkgPath(t *_type) string
//go:linkname typelinksinit runtime.typelinksinit
func typelinksinit()

func (t *_type) uncommon() *uncommonType { return _uncommon(t) }
func (t *_type) Kind() reflect.Kind { return _Kind(t) }
func (t *_type) NumField() int { return _NumField(t) }
func (t *_type) Field(i int) reflect.StructField { return _Field(t, i) }
Expand Down

0 comments on commit f5b4fbd

Please sign in to comment.