go/src/cmd/compile/internal/types/type.go

type Object

type Kind

const Txxx

const TINT8

const TUINT8

const TINT16

const TUINT16

const TINT32

const TUINT32

const TINT64

const TUINT64

const TINT

const TUINT

const TUINTPTR

const TCOMPLEX64

const TCOMPLEX128

const TFLOAT32

const TFLOAT64

const TBOOL

const TPTR

const TFUNC

const TSLICE

const TARRAY

const TSTRUCT

const TCHAN

const TMAP

const TINTER

const TFORW

const TANY

const TSTRING

const TUNSAFEPTR

const TIDEAL

const TNIL

const TBLANK

const TFUNCARGS

const TCHANARGS

const TSSA

const TTUPLE

const TRESULTS

const NTYPE

type ChanDir

func (c ChanDir) CanRecv() bool {}

func (c ChanDir) CanSend() bool {}

const Crecv

const Csend

const Cboth

var Types

var AnyType

var ByteType

var RuneType

var ErrorType

var ComparableType

var UntypedString

var UntypedBool

var UntypedInt

var UntypedRune

var UntypedFloat

var UntypedComplex

var UntypedTypes

var DefaultKinds

type Type

// Registers returns the number of integer and floating-point
// registers required to represent a parameter of this type under the
// ABIInternal calling conventions.
//
// If t must be passed by memory, Registers returns (math.MaxUint8,
// math.MaxUint8).
func (t *Type) Registers() (uint8, uint8) {}

func (*Type) CanBeAnSSAAux() {}

const typeNotInHeap

const typeNoalg

const typeDeferwidth

const typeRecur

const typeIsShape

const typeHasShape

const typeIsFullyInstantiated

func (t *Type) NotInHeap() bool           {}

func (t *Type) Noalg() bool               {}

func (t *Type) Deferwidth() bool          {}

func (t *Type) Recur() bool               {}

func (t *Type) IsShape() bool             {}

func (t *Type) HasShape() bool            {}

func (t *Type) IsFullyInstantiated() bool {}

func (t *Type) SetNotInHeap(b bool)           {}

func (t *Type) SetNoalg(b bool)               {}

func (t *Type) SetDeferwidth(b bool)          {}

func (t *Type) SetRecur(b bool)               {}

func (t *Type) SetIsFullyInstantiated(b bool) {}

// Should always do SetHasShape(true) when doing SetIsShape(true).
func (t *Type) SetIsShape(b bool)  {}

func (t *Type) SetHasShape(b bool) {}

// Kind returns the kind of type t.
func (t *Type) Kind() Kind {}

// Sym returns the name of type t.
func (t *Type) Sym() *Sym {}

// Underlying returns the underlying type of type t.
func (t *Type) Underlying() *Type {}

// Pos returns a position associated with t, if any.
// This should only be used for diagnostics.
func (t *Type) Pos() src.XPos {}

type Map

// MapType returns t's extra map-specific fields.
func (t *Type) MapType() *Map {}

type Forward

// forwardType returns t's extra forward-type-specific fields.
func (t *Type) forwardType() *Forward {}

type Func

func (ft *Func) recvs() []*Field         {}

func (ft *Func) params() []*Field        {}

func (ft *Func) results() []*Field       {}

func (ft *Func) recvParams() []*Field    {}

func (ft *Func) paramsResults() []*Field {}

// funcType returns t's extra func-specific fields.
func (t *Type) funcType() *Func {}

type Struct

// StructType returns t's extra struct-specific fields.
func (t *Type) StructType() *Struct {}

type Interface

type Ptr

type ChanArgs

type FuncArgs

type Chan

// chanType returns t's extra channel-specific fields.
func (t *Type) chanType() *Chan {}

type Tuple

type Results

type Array

type Slice

type Field

const fieldIsDDD

const fieldNointerface

func (f *Field) IsDDD() bool       {}

func (f *Field) Nointerface() bool {}

func (f *Field) SetIsDDD(b bool)       {}

func (f *Field) SetNointerface(b bool) {}

// End returns the offset of the first byte immediately after this field.
func (f *Field) End() int64 {}

// IsMethod reports whether f represents a method rather than a struct field.
func (f *Field) IsMethod() bool {}

type fields

// Slice returns the entries in f as a slice.
// Changes to the slice entries will be reflected in f.
func (f *fields) Slice() []*Field {}

// Set sets f to a slice.
// This takes ownership of the slice.
func (f *fields) Set(s []*Field) {}

// newType returns a new Type of the specified kind.
func newType(et Kind) *Type {}

// NewArray returns a new fixed-length array Type.
func NewArray(elem *Type, bound int64) *Type {}

// NewSlice returns the slice Type with element type elem.
func NewSlice(elem *Type) *Type {}

// NewChan returns a new chan Type with direction dir.
func NewChan(elem *Type, dir ChanDir) *Type {}

func NewTuple(t1, t2 *Type) *Type {}

func newResults(types []*Type) *Type {}

func NewResults(types []*Type) *Type {}

func newSSA(name string) *Type {}

// NewMap returns a new map Type with key type k and element (aka value) type v.
func NewMap(k, v *Type) *Type {}

var NewPtrCacheEnabled

// NewPtr returns the pointer type pointing to t.
func NewPtr(elem *Type) *Type {}

// NewChanArgs returns a new TCHANARGS type for channel type c.
func NewChanArgs(c *Type) *Type {}

// NewFuncArgs returns a new TFUNCARGS type for func type f.
func NewFuncArgs(f *Type) *Type {}

func NewField(pos src.XPos, sym *Sym, typ *Type) *Field {}

// SubstAny walks t, replacing instances of "any" with successive
// elements removed from types.  It returns the substituted type.
func SubstAny(t *Type, types *[]*Type) *Type {}

func substFields(fields []*Field, types *[]*Type) []*Field {}

// copy returns a shallow copy of the Type.
func (t *Type) copy() *Type {}

func (f *Field) Copy() *Field {}

func (t *Type) wantEtype(et Kind) {}

// ResultsTuple returns the result type of signature type t as a tuple.
// This can be used as the type of multi-valued call expressions.
func (t *Type) ResultsTuple() *Type {}

// Recvs returns a slice of receiver parameters of signature type t.
// The returned slice always has length 0 or 1.
func (t *Type) Recvs() []*Field {}

// Params returns a slice of regular parameters of signature type t.
func (t *Type) Params() []*Field {}

// Results returns a slice of result parameters of signature type t.
func (t *Type) Results() []*Field {}

// RecvParamsResults returns a slice containing all of the
// signature's parameters in receiver (if any), (normal) parameters,
// and then results.
func (t *Type) RecvParamsResults() []*Field {}

// RecvParams returns a slice containing the signature's receiver (if
// any) followed by its (normal) parameters.
func (t *Type) RecvParams() []*Field {}

// ParamsResults returns a slice containing the signature's (normal)
// parameters followed by its results.
func (t *Type) ParamsResults() []*Field {}

func (t *Type) NumRecvs() int   {}

func (t *Type) NumParams() int  {}

func (t *Type) NumResults() int {}

// IsVariadic reports whether function type t is variadic.
func (t *Type) IsVariadic() bool {}

// Recv returns the receiver of function type t, if any.
func (t *Type) Recv() *Field {}

// Param returns the i'th parameter of signature type t.
func (t *Type) Param(i int) *Field {}

// Result returns the i'th result of signature type t.
func (t *Type) Result(i int) *Field {}

// Key returns the key type of map type t.
func (t *Type) Key() *Type {}

// Elem returns the type of elements of t.
// Usable with pointers, channels, arrays, slices, and maps.
func (t *Type) Elem() *Type {}

// ChanArgs returns the channel type for TCHANARGS type t.
func (t *Type) ChanArgs() *Type {}

// FuncArgs returns the func type for TFUNCARGS type t.
func (t *Type) FuncArgs() *Type {}

// IsFuncArgStruct reports whether t is a struct representing function parameters or results.
func (t *Type) IsFuncArgStruct() bool {}

// Methods returns a pointer to the base methods (excluding embedding) for type t.
// These can either be concrete methods (for non-interface types) or interface
// methods (for interface types).
func (t *Type) Methods() []*Field {}

// AllMethods returns a pointer to all the methods (including embedding) for type t.
// For an interface type, this is the set of methods that are typically iterated
// over. For non-interface types, AllMethods() only returns a valid result after
// CalcMethods() has been called at least once.
func (t *Type) AllMethods() []*Field {}

// SetMethods sets the direct method set for type t (i.e., *not*
// including promoted methods from embedded types).
func (t *Type) SetMethods(fs []*Field) {}

// SetAllMethods sets the set of all methods for type t (i.e.,
// including promoted methods from embedded types).
func (t *Type) SetAllMethods(fs []*Field) {}

// fields returns the fields of struct type t.
func (t *Type) fields() *fields {}

// Field returns the i'th field of struct type t.
func (t *Type) Field(i int) *Field {}

// Fields returns a slice of containing all fields of
// a struct type t.
func (t *Type) Fields() []*Field {}

// setFields sets struct type t's fields to fields.
func (t *Type) setFields(fields []*Field) {}

// SetInterface sets the base methods of an interface type t.
func (t *Type) SetInterface(methods []*Field) {}

// ArgWidth returns the total aligned argument size for a function.
// It includes the receiver, parameters, and results.
func (t *Type) ArgWidth() int64 {}

func (t *Type) Size() int64 {}

func (t *Type) Alignment() int64 {}

func (t *Type) SimpleString() string {}

type Cmp

const CMPlt

const CMPeq

const CMPgt

// Compare compares types for purposes of the SSA back
// end, returning a Cmp (one of CMPlt, CMPeq, CMPgt).
// The answers are correct for an optimizer
// or code generator, but not necessarily typechecking.
// The order chosen is arbitrary, only consistency and division
// into equivalence classes (Types that compare CMPeq) matters.
func (t *Type) Compare(x *Type) Cmp {}

func cmpForNe(x bool) Cmp {}

func (r *Sym) cmpsym(s *Sym) Cmp {}

// cmp compares two *Types t and x, returning CMPlt,
// CMPeq, CMPgt as t<x, t==x, t>x, for an arbitrary
// and optimizer-centric notion of comparison.
// TODO(josharian): make this safe for recursive interface types
// and use in signatlist sorting. See issue 19869.
func (t *Type) cmp(x *Type) Cmp {}

// IsKind reports whether t is a Type of the specified kind.
func (t *Type) IsKind(et Kind) bool {}

func (t *Type) IsBoolean() bool {}

var unsignedEType

// ToUnsigned returns the unsigned equivalent of integer type t.
func (t *Type) ToUnsigned() *Type {}

func (t *Type) IsInteger() bool {}

func (t *Type) IsSigned() bool {}

func (t *Type) IsUnsigned() bool {}

func (t *Type) IsFloat() bool {}

func (t *Type) IsComplex() bool {}

// IsPtr reports whether t is a regular Go pointer type.
// This does not include unsafe.Pointer.
func (t *Type) IsPtr() bool {}

// IsPtrElem reports whether t is the element of a pointer (to t).
func (t *Type) IsPtrElem() bool {}

// IsUnsafePtr reports whether t is an unsafe pointer.
func (t *Type) IsUnsafePtr() bool {}

// IsUintptr reports whether t is a uintptr.
func (t *Type) IsUintptr() bool {}

// IsPtrShaped reports whether t is represented by a single machine pointer.
// In addition to regular Go pointer types, this includes map, channel, and
// function types and unsafe.Pointer. It does not include array or struct types
// that consist of a single pointer shaped type.
// TODO(mdempsky): Should it? See golang.org/issue/15028.
func (t *Type) IsPtrShaped() bool {}

// HasNil reports whether the set of values determined by t includes nil.
func (t *Type) HasNil() bool {}

func (t *Type) IsString() bool {}

func (t *Type) IsMap() bool {}

func (t *Type) IsChan() bool {}

func (t *Type) IsSlice() bool {}

func (t *Type) IsArray() bool {}

func (t *Type) IsStruct() bool {}

func (t *Type) IsInterface() bool {}

// IsEmptyInterface reports whether t is an empty interface type.
func (t *Type) IsEmptyInterface() bool {}

// IsScalar reports whether 't' is a scalar Go type, e.g.
// bool/int/float/complex. Note that struct and array types consisting
// of a single scalar element are not considered scalar, likewise
// pointer types are also not considered scalar.
func (t *Type) IsScalar() bool {}

func (t *Type) PtrTo() *Type {}

func (t *Type) NumFields() int {}

func (t *Type) FieldType(i int) *Type {}

func (t *Type) FieldOff(i int) int64 {}

func (t *Type) FieldName(i int) string {}

// OffsetOf reports the offset of the field of a struct.
// The field is looked up by name.
func (t *Type) OffsetOf(name string) int64 {}

func (t *Type) NumElem() int64 {}

type componentsIncludeBlankFields

const IgnoreBlankFields

const CountBlankFields

// NumComponents returns the number of primitive elements that compose t.
// Struct and array types are flattened for the purpose of counting.
// All other types (including string, slice, and interface types) count as one element.
// If countBlank is IgnoreBlankFields, then blank struct fields
// (and their comprised elements) are excluded from the count.
// struct { x, y [3]int } has six components; [10]struct{ x, y string } has twenty.
func (t *Type) NumComponents(countBlank componentsIncludeBlankFields) int64 {}

// SoleComponent returns the only primitive component in t,
// if there is exactly one. Otherwise, it returns nil.
// Components are counted as in NumComponents, including blank fields.
// Keep in sync with cmd/compile/internal/walk/convert.go:soleComponent.
func (t *Type) SoleComponent() *Type {}

// ChanDir returns the direction of a channel type t.
// The direction will be one of Crecv, Csend, or Cboth.
func (t *Type) ChanDir() ChanDir {}

func (t *Type) IsMemory() bool {}

func (t *Type) IsFlags() bool   {}

func (t *Type) IsVoid() bool    {}

func (t *Type) IsTuple() bool   {}

func (t *Type) IsResults() bool {}

// IsUntyped reports whether t is an untyped type.
func (t *Type) IsUntyped() bool {}

// HasPointers reports whether t contains a heap pointer.
// Note that this function ignores pointers to not-in-heap types.
func (t *Type) HasPointers() bool {}

var recvType

// FakeRecvType returns the singleton type used for interface method receivers.
func FakeRecvType() *Type {}

func FakeRecv() *Field {}

var TypeInvalid

var TypeMem

var TypeFlags

var TypeVoid

var TypeInt128

var TypeResultMem

func init() {}

// NewNamed returns a new named type for the given type name. obj should be an
// ir.Name. The new type is incomplete (marked as TFORW kind), and the underlying
// type should be set later via SetUnderlying(). References to the type are
// maintained until the type is filled in, so those references can be updated when
// the type is complete.
func NewNamed(obj Object) *Type {}

// Obj returns the canonical type name node for a named type t, nil for an unnamed type.
func (t *Type) Obj() Object {}

// SetUnderlying sets the underlying type of an incomplete type (i.e. type whose kind
// is currently TFORW). SetUnderlying automatically updates any types that were waiting
// for this type to be completed.
func (t *Type) SetUnderlying(underlying *Type) {}

func fieldsHasShape(fields []*Field) bool {}

// newBasic returns a new basic type of the given kind.
func newBasic(kind Kind, obj Object) *Type {}

// NewInterface returns a new interface for the given methods and
// embedded types. Embedded types are specified as fields with no Sym.
func NewInterface(methods []*Field) *Type {}

// NewSignature returns a new function type for the given receiver,
// parameters, and results, any of which may be nil.
func NewSignature(recv *Field, params, results []*Field) *Type {}

// NewStruct returns a new struct with the given fields.
func NewStruct(fields []*Field) *Type {}

var IsInt

var IsFloat

var IsComplex

var IsSimple

var IsOrdered

// IsReflexive reports whether t has a reflexive equality operator.
// That is, if x==x for all x of type t.
func IsReflexive(t *Type) bool {}

// Can this type be stored directly in an interface word?
// Yes, if the representation is a single pointer.
func IsDirectIface(t *Type) bool {}

// IsInterfaceMethod reports whether (field) m is
// an interface method. Such methods have the
// special receiver type types.FakeRecvType().
func IsInterfaceMethod(f *Type) bool {}

// IsMethodApplicable reports whether method m can be called on a
// value of type t. This is necessary because we compute a single
// method set for both T and *T, but some *T methods are not
// applicable to T receivers.
func IsMethodApplicable(t *Type, m *Field) bool {}

// RuntimeSymName returns the name of s if it's in package "runtime"; otherwise
// it returns "".
func RuntimeSymName(s *Sym) string {}

// ReflectSymName returns the name of s if it's in package "reflect"; otherwise
// it returns "".
func ReflectSymName(s *Sym) string {}

// IsNoInstrumentPkg reports whether p is a package that
// should not be instrumented.
func IsNoInstrumentPkg(p *Pkg) bool {}

// IsNoRacePkg reports whether p is a package that
// should not be race instrumented.
func IsNoRacePkg(p *Pkg) bool {}

// IsRuntimePkg reports whether p is a runtime package.
func IsRuntimePkg(p *Pkg) bool {}

// ReceiverBaseType returns the underlying type, if any,
// that owns methods with receiver parameter t.
// The result is either a named type or an anonymous struct.
func ReceiverBaseType(t *Type) *Type {}

func FloatForComplex(t *Type) *Type {}

func ComplexForFloat(t *Type) *Type {}

func TypeSym(t *Type) *Sym {}

func TypeSymLookup(name string) *Sym {}

func TypeSymName(t *Type) string {}

var typepkgmu

var typepkg

var SimType

var ShapePkg