Documentation
¶
Index ¶
- func StructFields(c *Cache, t reflect.Type) map[string]Nature
- type Cache
- type Nature
- func (n *Nature) All(c *Cache) map[string]Nature
- func (n *Nature) AssignableTo(nt Nature) bool
- func (n *Nature) ComparableTo(c *Cache, rhs Nature) bool
- func (n *Nature) Deref(c *Cache) Nature
- func (n *Nature) Elem(c *Cache) Nature
- func (n *Nature) FieldByName(c *Cache, name string) (Nature, bool)
- func (n *Nature) FieldIndex(c *Cache, name string) ([]int, bool)
- func (n *Nature) Get(c *Cache, name string) (Nature, bool)
- func (n *Nature) In(c *Cache, i int) Nature
- func (n *Nature) InElem(c *Cache, i int) Nature
- func (n *Nature) IsAny(c *Cache) bool
- func (n *Nature) IsAnyOf(cs ...NatureCheck) bool
- func (n *Nature) IsArray() bool
- func (n *Nature) IsBool() bool
- func (n *Nature) IsByteSlice() bool
- func (n *Nature) IsDuration() bool
- func (n *Nature) IsFastMap() bool
- func (n *Nature) IsFirstArgUnknown(c *Cache) bool
- func (n *Nature) IsFunc() bool
- func (n *Nature) IsMap() bool
- func (n *Nature) IsNumber() bool
- func (n *Nature) IsPointer() bool
- func (n *Nature) IsString() bool
- func (n *Nature) IsStruct() bool
- func (n *Nature) IsTime() bool
- func (n *Nature) IsUnknown(c *Cache) bool
- func (n *Nature) IsVariadic() bool
- func (n *Nature) Key(c *Cache) Nature
- func (n *Nature) MakeArrayOf(c *Cache) Nature
- func (n *Nature) MaybeCompatible(c *Cache, rhs Nature, cs ...NatureCheck) bool
- func (n *Nature) MethodByName(c *Cache, name string) (Nature, bool)
- func (n *Nature) NumIn() int
- func (n *Nature) NumMethods(c *Cache) int
- func (n *Nature) NumOut() int
- func (n *Nature) Out(c *Cache, i int) Nature
- func (n *Nature) PromoteNumericNature(c *Cache, rhs Nature) Nature
- func (n *Nature) String() string
- type NatureCheck
- type TypeData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶ added in v1.17.7
type Cache struct {
// contains filtered or unexported fields
}
Cache is a shared cache of type information. It is only used in the stages where type information becomes relevant, so packages like ast, parser, types, and lexer do not need to use the cache because they don't need any service from the Nature type, they only describe. However, when receiving a Nature from one of those packages, the cache must be set immediately.
type Nature ¶
type Nature struct {
Type reflect.Type // Type of the value. If nil, then value is unknown.
Kind reflect.Kind // Kind of the value.
*TypeData
// Ref is a reference used for multiple, disjoint purposes. When the Nature
// is for a:
// - Predicate: then Ref is the nature of the Out of the predicate.
// - Array-like types: then Ref is the Elem nature of array type (usually Type is []any, but ArrayOf can be any nature).
Ref *Nature
Nil bool // If value is nil.
Strict bool // If map is types.StrictMap.
Method bool // If value retrieved from method. Usually used to determine amount of in arguments.
IsInteger bool // If it's a builtin integer or unsigned integer type.
IsFloat bool // If it's a builtin float type.
}
func (*Nature) AssignableTo ¶
func (*Nature) ComparableTo ¶ added in v1.17.7
func (*Nature) IsAnyOf ¶ added in v1.17.7
func (n *Nature) IsAnyOf(cs ...NatureCheck) bool
func (*Nature) IsByteSlice ¶ added in v1.17.7
func (*Nature) IsDuration ¶ added in v1.17.7
func (*Nature) IsFirstArgUnknown ¶ added in v1.17.7
func (*Nature) IsVariadic ¶
func (*Nature) MakeArrayOf ¶ added in v1.17.7
func (*Nature) MaybeCompatible ¶ added in v1.17.7
func (n *Nature) MaybeCompatible(c *Cache, rhs Nature, cs ...NatureCheck) bool
func (*Nature) NumMethods ¶
func (*Nature) PromoteNumericNature ¶ added in v1.17.7
type NatureCheck ¶ added in v1.17.7
type NatureCheck int
const ( BoolCheck NatureCheck StringCheck IntegerCheck NumberCheck MapCheck ArrayCheck TimeCheck DurationCheck )
type TypeData ¶ added in v1.17.7
type TypeData struct {
// map-only data
Fields map[string]Nature // Fields of map type.
DefaultMapValue *Nature // Default value of map type.
// callable-only data
Func *builtin.Function // Used to pass function type from callee to CallNode.
MethodIndex int // Index of method in type.
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.