typeutil

package
v0.0.0-...-2c056e7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(typ types.Type, fn func(*types.Term) bool) bool

All is a wrapper for NewTypeSet(typ).All(fn).

func Any

func Any(typ types.Type, fn func(*types.Term) bool) bool

Any is a wrapper for NewTypeSet(typ).Any(fn).

func Callee

func Callee(info *types.Info, call *ast.CallExpr) types.Object

func CoreType

func CoreType(typ types.Type) types.Type

CoreType is a wrapper for NewTypeSet(typ).CoreType()

func Dereference

func Dereference(T types.Type) types.Type

Dereference returns a pointer's element type; otherwise it returns T.

func DereferenceR

func DereferenceR(T types.Type) types.Type

DereferenceR returns a pointer's element type; otherwise it returns T. If the element type is itself a pointer, DereferenceR will be applied recursively.

func FuncName

func FuncName(f *types.Func) string

func IntuitiveMethodSet

func IntuitiveMethodSet(T types.Type, msets *MethodSetCache) []*types.Selection

func IsObject

func IsObject(obj types.Object, name string) bool

func IsPointerLike

func IsPointerLike(T types.Type) bool

func IsSlice

func IsSlice(term *types.Term) bool

func IsType

func IsType(T types.Type, name string) bool

OPT(dh): IsType is kind of expensive; should we really use it?

Types

type Field

type Field struct {
	Var  *types.Var
	Tag  string
	Path []int
}

func FlattenFields

func FlattenFields(T *types.Struct) []Field

FlattenFields recursively flattens T and embedded structs, returning a list of fields. If multiple fields with the same name exist, all will be returned.

type Hasher

type Hasher = typeutil.Hasher

func MakeHasher

func MakeHasher() Hasher

type Iterator

type Iterator struct {
	// contains filtered or unexported fields
}

func NewIterator

func NewIterator(elem types.Type) *Iterator

func (*Iterator) Elem

func (t *Iterator) Elem() types.Type

func (*Iterator) String

func (t *Iterator) String() string

func (*Iterator) Underlying

func (t *Iterator) Underlying() types.Type

type Map

type Map[V any] struct {
	// contains filtered or unexported fields
}

func (*Map[V]) At

func (m *Map[V]) At(key types.Type) (V, bool)

func (*Map[V]) Delete

func (m *Map[V]) Delete(key types.Type) bool

func (*Map[V]) Iterate

func (m *Map[V]) Iterate(f func(key types.Type, value V))

func (*Map[V]) Keys

func (m *Map[V]) Keys() []types.Type

func (*Map[V]) KeysString

func (m *Map[V]) KeysString() string

func (*Map[V]) Len

func (m *Map[V]) Len() int

func (*Map[V]) Set

func (m *Map[V]) Set(key types.Type, value V)

func (*Map[V]) SetHasher

func (m *Map[V]) SetHasher(h typeutil.Hasher)

func (*Map[V]) String

func (m *Map[V]) String() string

type MethodSetCache

type MethodSetCache = typeutil.MethodSetCache

type TypeSet

type TypeSet struct {
	Terms []*types.Term
	// contains filtered or unexported fields
}

func NewTypeSet

func NewTypeSet(typ types.Type) TypeSet

func (TypeSet) All

func (ts TypeSet) All(fn func(*types.Term) bool) bool

All calls fn for each term in the type set and reports whether all invocations returned true. If the type set is empty or unconstrained, All immediately returns false.

func (TypeSet) Any

func (ts TypeSet) Any(fn func(*types.Term) bool) bool

Any calls fn for each term in the type set and reports whether any invocation returned true. It stops after the first call that returned true.

func (TypeSet) CoreType

func (ts TypeSet) CoreType() types.Type

CoreType returns the type set's core type, or nil if it has none. The function only looks at type terms and may thus return core types for some empty type sets, such as 'interface { map[int]string; foo() }'

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL