Documentation ¶
Index ¶
- Constants
- func AssignableTo(src *Complete, dst *Complete) bool
- func ConvertibleTo(src *Complete, dst *Complete) bool
- func IdenticalType(c1 *Complete, c2 *Complete, ignoreTags bool) bool
- func Implements(src *Complete, dst *Complete) bool
- func TypeString(t Type, showFullPkgPath bool) string
- type Array
- type Basic
- type Chan
- type ChanDir
- type Class
- type Complete
- func (t *Complete) Align() uint64
- func (t *Complete) ChanDir() ChanDir
- func (t *Complete) Comparable() bool
- func (t *Complete) Elem() *Complete
- func (t *Complete) Field(i int) CompleteField
- func (t *Complete) In(i int) *Complete
- func (t *Complete) IsVariadic() bool
- func (t *Complete) Key() *Complete
- func (t *Complete) Kind() Kind
- func (t *Complete) Len() uint64
- func (t *Complete) Method(i int) CompleteMethod
- func (t *Complete) Name() string
- func (t *Complete) NumField() int
- func (t *Complete) NumIn() int
- func (t *Complete) NumMethod() int
- func (t *Complete) NumOut() int
- func (t *Complete) Out(i int) *Complete
- func (t *Complete) PkgPath() string
- func (t *Complete) Size() uint64
- func (t *Complete) String() string
- func (t *Complete) Type() Type
- func (t *Complete) Underlying() *Complete
- type CompleteField
- type CompleteMethod
- type Constraint
- type Field
- type Func
- type Generic
- func (g *Generic) Instantiate(concreteTypes []Type) Type
- func (g *Generic) Name() string
- func (g *Generic) NumTypes() int
- func (g *Generic) PkgPath() string
- func (g *Generic) String() string
- func (g *Generic) TypeConstraint(i int) Constraint
- func (g *Generic) TypeParam(i int) string
- func (g *Generic) WriteTo(dst io.StringWriter, flag verbose)
- type Instantiate
- type Interface
- type Kind
- type Map
- type Method
- type Named
- func (t *Named) AddMethod(mtd *Method)
- func (t *Named) Method(i int) Method
- func (t *Named) Name() string
- func (t *Named) NumMethod() int
- func (t *Named) PkgPath() string
- func (t *Named) SetUnderlying(u Type)
- func (t *Named) String() string
- func (t *Named) Underlying() Type
- func (t *Named) WriteTo(dst io.StringWriter, flag verbose)
- type Object
- func (obj *Object) Class() Class
- func (obj *Object) Decl() interface{}
- func (obj *Object) Name() string
- func (obj *Object) SetDecl(decl interface{}) *Object
- func (obj *Object) SetType(t *Complete)
- func (obj *Object) SetValue(value interface{}) *Object
- func (obj *Object) String() string
- func (obj *Object) Type() *Complete
- func (obj *Object) Value() interface{}
- type Package
- type Packages
- type Pointer
- type Scope
- type Slice
- type Struct
- type Type
Constants ¶
const ( Invalid = token.Invalid Bool = token.Bool Int = token.Int Int8 = token.Int8 Int16 = token.Int16 Int32 = token.Int32 Int64 = token.Int64 Uint = token.Uint Uint8 = token.Uint8 Uint16 = token.Uint16 Uint32 = token.Uint32 Uint64 = token.Uint64 Uintptr = token.Uintptr Float32 = token.Float32 Float64 = token.Float64 Complex64 = token.Complex64 Complex128 = token.Complex128 ArrayKind = token.ArrayKind ChanKind = token.ChanKind FuncKind = token.FuncKind InterfaceKind = token.InterfaceKind MapKind = token.MapKind PtrKind = token.PtrKind SliceKind = token.SliceKind String = token.String StructKind = token.StructKind UnsafePointer = token.UnsafePointer // types for untyped values UntypedBool = token.UntypedBool UntypedInt = token.UntypedInt UntypedRune = token.UntypedRune UntypedFloat = token.UntypedFloat UntypedComplex = token.UntypedComplex UntypedString = token.UntypedString UntypedNil = token.UntypedNil // aliases Byte = token.Byte Rune = token.Rune )
Variables ¶
This section is empty.
Functions ¶
func AssignableTo ¶
*
- return true if values of type 'src' can be assigned to variables of type 'dst' *
- as per Go specifications https://golang.ir/ref/spec#Assignability
- a type 'src' is assignable to type 'dst' if at least one of the following applies:
- - src and dst are identical
- - src and dst have identical underlying types, and at least one of src, dst is unnamed
- - dst is an interface type, and src implements it
- - src is a bidirectional channel value, dst is a channel type, they have identical element types
- and and at least one of src, dst is unnamed
- - src is UntypedNil and dst is a channel, function, interface, map, pointer or slice type
- - src is an untyped and is representable by dst
func ConvertibleTo ¶
*
- return true if values of type 'src' can be converted to type 'dst' *
- as per Go specifications https://golang.ir/ref/spec#Conversions
- a type 'src' is convertible to type 'dst' if at least one of the following applies:
- - src is assignable to dst
- - ignoring struct tags, src and dst have identical underlying types
- - ignoring struct tags, src and dst are unnamed pointers,
- and their element types have identical underlying types
- - src and dst are both integer or floating point types
- - src and dst are both complex types
- - src is an integer (obsolescent) or a slice of byte/rune and dst is a string
- - src is a string and dst is a slice of byte/rune *
- notes:
- - "X is a string" means: "X underlying type is string"
- - analogously, "X is a complex type" means "X underlying type is complex64 or complex128"
- - analogously, "X is a floating point" means "X underlying type is float32 or float64"
- - analogously, "X is an integer" means "X underlying type is one of the basic integer types"
- - "X is a slice of byte/rune" means: "X underlying type is slice,
- and the the underlying type of slice element is byte (i.e. uint8) or rune (i.e. int32)"
func Implements ¶
return true if values of type 'src' implement interface type 'dst'
func TypeString ¶
Types ¶
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
func (*Array) Underlying ¶
func (*Array) WriteTo ¶
func (t *Array) WriteTo(dst io.StringWriter, flag verbose)
type Basic ¶
type Basic struct {
// contains filtered or unexported fields
}
Basic represents one of Go's predefined basic types
func (*Basic) Underlying ¶
func (*Basic) WriteTo ¶
func (t *Basic) WriteTo(dst io.StringWriter, flag verbose)
type Chan ¶
type Chan struct {
// contains filtered or unexported fields
}
func (*Chan) Underlying ¶
func (*Chan) WriteTo ¶
func (t *Chan) WriteTo(dst io.StringWriter, flag verbose)
type Complete ¶
type Complete struct {
// contains filtered or unexported fields
}
Complete represent a Go type. It is similar in spirit to reflect.Type
func BasicType ¶
return *Complete basic type for specified Kind and current GetArchSizeBits() and GetTargetOs()
func BasicTypes ¶
func BasicTypes() []*Complete
create and return a slice containing *Complete basic types for current GetArchSizeBits() and GetTargetOs() use Kind as index in returned slice.
func BinaryOp ¶
return the type of 'e1 op e2' where e1's type = t1 and e2's type = t2 return nil if t1 and t2 are not compatible with op.
func CompleteTypes ¶
resolve circular dependencies and incomplete Types, and return equivalent *Complete objects
func NewBuiltin ¶
create a new type representing a builtin function. the returned *Complete has .Kind() = Invalid and .Type() = nil, as it cannot be used as component in new types.
func (*Complete) Comparable ¶
func (*Complete) Field ¶
func (t *Complete) Field(i int) CompleteField
func (*Complete) IsVariadic ¶
func (*Complete) Method ¶
func (t *Complete) Method(i int) CompleteMethod
func (*Complete) Underlying ¶
type CompleteField ¶
type CompleteMethod ¶
returned by Complete.Method(int)
type Constraint ¶
type Constraint struct {
// contains filtered or unexported fields
}
Constraint represents a constraint on a generic type. it is either a named or unnamed interface type (i.e. .Kind() = InterfaceKind) or a generic type that, when instantiated, declares a named or unnamed interface type
func MakeConstraintGeneric ¶
func MakeConstraintGeneric(generic *Generic) Constraint
func MakeConstraintType ¶
func MakeConstraintType(typ Type) Constraint
func (Constraint) Generic ¶
func (c Constraint) Generic() *Generic
func (Constraint) Type ¶
func (c Constraint) Type() Type
type Field ¶
type Field struct { Type Type Name string PkgPath string Tag string Offset uint64 Index int Embedded bool }
func (*Field) WriteTo ¶
func (f *Field) WriteTo(dst io.StringWriter, flag verbose)
type Func ¶
type Func struct {
// contains filtered or unexported fields
}
Func represents the type of a function
func (*Func) IsVariadic ¶
func (*Func) Underlying ¶
func (*Func) WriteTo ¶
func (t *Func) WriteTo(dst io.StringWriter, flag verbose)
type Generic ¶
type Generic struct {
// contains filtered or unexported fields
}
Generic represents a generic type or generic function
func NewGeneric ¶
func NewGeneric( name string, pkgPath string, paramNames []string, constraints []Constraint, instantiate Instantiate, ) *Generic
Declare a new Generic type. A generic type *cannot* be an alias
func (*Generic) Instantiate ¶
func (*Generic) TypeConstraint ¶
func (g *Generic) TypeConstraint(i int) Constraint
func (*Generic) WriteTo ¶
func (g *Generic) WriteTo(dst io.StringWriter, flag verbose)
type Instantiate ¶
user-provided function to instantiate a generic type or generic function
type Interface ¶
type Interface struct {
// contains filtered or unexported fields
}
func NewInterface ¶
create a new Interface type
func (*Interface) NumEmbedded ¶
return number of embedded interfaces.
func (*Interface) Underlying ¶
func (*Interface) WriteTo ¶
func (t *Interface) WriteTo(dst io.StringWriter, flag verbose)
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
func (*Map) Underlying ¶
func (*Map) WriteTo ¶
func (t *Map) WriteTo(dst io.StringWriter, flag verbose)
type Method ¶
returned by Named.Method(int)
func (*Method) WriteTo ¶
func (m *Method) WriteTo(dst io.StringWriter, flag verbose)
type Named ¶
type Named struct {
// contains filtered or unexported fields
}
represents a named type
func (*Named) AddMethod ¶
add a method. always appends to the list of methods, even if another method with the same name already exists.
func (*Named) SetUnderlying ¶
Set underlying type of t to be the same as underlying type of u. u can also be a *Named (and possibly incomplete) type: its underlying type will be retrieved by CompleteTypes(t)
func (*Named) Underlying ¶
returns nil if SetUnderlying() was not invoked yet
func (*Named) WriteTo ¶
func (t *Named) WriteTo(dst io.StringWriter, flag verbose)
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
func NewBuiltinObj ¶
create a new Object representing a builtin function.
func (*Object) Value ¶
func (obj *Object) Value() interface{}
*
- Value returns the value associated to given *Object, or nil if no value was set.
- If non nil, it is expected to be:
- constant.Value for constants
- *Package for imports,
- Label for global variables and functions/methods
- Generic for generic types and generic functions/methods
type Pointer ¶
type Pointer struct {
// contains filtered or unexported fields
}
func (*Pointer) Underlying ¶
func (*Pointer) WriteTo ¶
func (t *Pointer) WriteTo(dst io.StringWriter, flag verbose)
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
func Universe ¶
func Universe() *Scope
return the top-level scope, containing all predeclared objects of Go. result depends on config.Target()
func (*Scope) LookupParent ¶
search object by name in specified Scope and all its parent scopes.
type Slice ¶
type Slice struct {
// contains filtered or unexported fields
}
func (*Slice) Underlying ¶
func (*Slice) WriteTo ¶
func (t *Slice) WriteTo(dst io.StringWriter, flag verbose)
type Struct ¶
type Struct struct {
// contains filtered or unexported fields
}
func (*Struct) Underlying ¶
func (*Struct) WriteTo ¶
func (t *Struct) WriteTo(dst io.StringWriter, flag verbose)