...

Package types

import "cmd/compile/internal/types"
Overview
Index

Overview ▾

Index ▾

Constants
Variables
func CleanroomDo(f func())
func Haspointers(t *Type) bool
func Haspointers1(t *Type, ignoreNotInHeap bool) bool
func Identical(t1, t2 *Type) bool
func IdenticalIgnoreTags(t1, t2 *Type) bool
func InternString(b []byte) string
func IsDclstackValid() bool
func IsExported(name string) bool
func Markdcl()
func Popdcl()
func Pushdcl(s *Sym)
type Array
type Chan
type ChanArgs
type ChanDir
    func (c ChanDir) CanRecv() bool
    func (c ChanDir) CanSend() bool
type Cmp
type DDDField
type EType
    func (i EType) String() string
type Field
    func NewField() *Field
    func (f *Field) Broke() bool
    func (f *Field) Copy() *Field
    func (f *Field) End() int64
    func (f *Field) IsDDD() bool
    func (f *Field) Nointerface() bool
    func (f *Field) SetBroke(b bool)
    func (f *Field) SetIsDDD(b bool)
    func (f *Field) SetNointerface(b bool)
type Fields
    func (f *Fields) Append(s ...*Field)
    func (f *Fields) Index(i int) *Field
    func (f *Fields) Len() int
    func (f *Fields) Set(s []*Field)
    func (f *Fields) Slice() []*Field
type Forward
type Funarg
type Func
type FuncArgs
type Interface
type Map
type Node
type Pkg
    func ImportedPkgList() []*Pkg
    func NewPkg(path, name string) *Pkg
    func (pkg *Pkg) Lookup(name string) *Sym
    func (pkg *Pkg) LookupBytes(name []byte) *Sym
    func (pkg *Pkg) LookupOK(name string) (s *Sym, existed bool)
type Ptr
type Slice
type Struct
type Sym
    func (sym *Sym) AlgGen() bool
    func (sym *Sym) Asm() bool
    func (sym *Sym) Format(s fmt.State, verb rune)
    func (sym *Sym) Func() bool
    func (sym *Sym) IsBlank() bool
    func (a *Sym) Less(b *Sym) bool
    func (sym *Sym) Linksym() *obj.LSym
    func (sym *Sym) LinksymName() string
    func (sym *Sym) OnExportList() bool
    func (s *Sym) PkgDef() *Node
    func (sym *Sym) SetAlgGen(b bool)
    func (sym *Sym) SetAsm(b bool)
    func (sym *Sym) SetFunc(b bool)
    func (sym *Sym) SetOnExportList(b bool)
    func (s *Sym) SetPkgDef(n *Node)
    func (sym *Sym) SetSiggen(b bool)
    func (sym *Sym) SetUniq(b bool)
    func (sym *Sym) Siggen() bool
    func (s *Sym) String() string
    func (sym *Sym) Uniq() bool
type Tuple
type Type
    func FakeRecvType() *Type
    func New(et EType) *Type
    func NewArray(elem *Type, bound int64) *Type
    func NewChan(elem *Type, dir ChanDir) *Type
    func NewChanArgs(c *Type) *Type
    func NewDDDArray(elem *Type) *Type
    func NewDDDField(s *Type) *Type
    func NewFuncArgs(f *Type) *Type
    func NewMap(k, v *Type) *Type
    func NewPtr(elem *Type) *Type
    func NewSlice(elem *Type) *Type
    func NewTuple(t1, t2 *Type) *Type
    func SubstAny(t *Type, types *[]*Type) *Type
    func (t *Type) Alignment() int64
    func (t *Type) AllMethods() *Fields
    func (t *Type) ArgWidth() int64
    func (t *Type) Broke() bool
    func (t *Type) ChanArgs() *Type
    func (t *Type) ChanDir() ChanDir
    func (t *Type) ChanType() *Chan
    func (t *Type) Compare(x *Type) Cmp
    func (t *Type) DDDField() *Type
    func (t *Type) Deferwidth() bool
    func (t *Type) Elem() *Type
    func (t *Type) Field(i int) *Field
    func (t *Type) FieldName(i int) string
    func (t *Type) FieldOff(i int) int64
    func (t *Type) FieldSlice() []*Field
    func (t *Type) FieldType(i int) *Type
    func (t *Type) Fields() *Fields
    func (t *Type) Format(s fmt.State, verb rune)
    func (t *Type) ForwardType() *Forward
    func (t *Type) FuncArgs() *Type
    func (t *Type) FuncType() *Func
    func (t *Type) HasHeapPointer() bool
    func (t *Type) IsArray() bool
    func (t *Type) IsBoolean() bool
    func (t *Type) IsChan() bool
    func (t *Type) IsComplex() bool
    func (t *Type) IsDDDArray() bool
    func (t *Type) IsEmptyInterface() bool
    func (t *Type) IsFlags() bool
    func (t *Type) IsFloat() bool
    func (t *Type) IsFuncArgStruct() bool
    func (t *Type) IsInteger() bool
    func (t *Type) IsInterface() bool
    func (t *Type) IsKind(et EType) bool
    func (t *Type) IsMap() bool
    func (t *Type) IsMemory() bool
    func (t *Type) IsPtr() bool
    func (t *Type) IsPtrElem() bool
    func (t *Type) IsPtrShaped() bool
    func (t *Type) IsSigned() bool
    func (t *Type) IsSlice() bool
    func (t *Type) IsString() bool
    func (t *Type) IsStruct() bool
    func (t *Type) IsTuple() bool
    func (t *Type) IsUnsafePtr() bool
    func (t *Type) IsUntyped() bool
    func (t *Type) IsVariadic() bool
    func (t *Type) IsVoid() bool
    func (t *Type) Key() *Type
    func (t *Type) LongString() string
    func (t *Type) MapType() *Map
    func (t *Type) Methods() *Fields
    func (t *Type) Nname() *Node
    func (t *Type) Noalg() bool
    func (t *Type) NotInHeap() bool
    func (t *Type) NumComponents(countBlank componentsIncludeBlankFields) int64
    func (t *Type) NumElem() int64
    func (t *Type) NumFields() int
    func (t *Type) NumParams() int
    func (t *Type) NumRecvs() int
    func (t *Type) NumResults() int
    func (t *Type) Params() *Type
    func (t *Type) Pkg() *Pkg
    func (t *Type) PtrTo() *Type
    func (t *Type) Recur() bool
    func (t *Type) Recv() *Field
    func (t *Type) Recvs() *Type
    func (t *Type) Results() *Type
    func (t *Type) SetBroke(b bool)
    func (t *Type) SetDeferwidth(b bool)
    func (t *Type) SetFields(fields []*Field)
    func (t *Type) SetInterface(methods []*Field)
    func (t *Type) SetNname(n *Node)
    func (t *Type) SetNoalg(b bool)
    func (t *Type) SetNotInHeap(b bool)
    func (t *Type) SetNumElem(n int64)
    func (t *Type) SetPkg(pkg *Pkg)
    func (t *Type) SetRecur(b bool)
    func (t *Type) ShortString() string
    func (t *Type) SimpleString() string
    func (t *Type) Size() int64
    func (t *Type) String() string
    func (t *Type) StructType() *Struct
    func (t *Type) Symbol() *obj.LSym
    func (t *Type) Tie() byte
    func (t *Type) ToUnsigned() *Type
    func (t *Type) WidthCalculated() bool

Package files

etype_string.go identity.go pkg.go scope.go sym.go type.go utils.go

Constants

const (
        CMPlt = Cmp(-1)
        CMPeq = Cmp(0)
        CMPgt = Cmp(1)
)
const (
        IgnoreBlankFields componentsIncludeBlankFields = false
        CountBlankFields  componentsIncludeBlankFields = true
)
const BADWIDTH = -1000000000

MaxPkgHeight is a height greater than any likely package height.

const MaxPkgHeight = 1e9

Variables

var (
        // Predeclared alias types. Kept separate for better error messages.
        Bytetype *Type
        Runetype *Type

        // Predeclared error interface type.
        Errortype *Type

        // Types to represent untyped string and boolean constants.
        Idealstring *Type
        Idealbool   *Type

        // Types to represent untyped numeric constants.
        // Note: Currently these are only used within the binary export
        // data format. The rest of the compiler only uses Types[TIDEAL].
        Idealint     = New(TIDEAL)
        Idealrune    = New(TIDEAL)
        Idealfloat   = New(TIDEAL)
        Idealcomplex = New(TIDEAL)
)
var (
        // TSSA types. Haspointers assumes these are pointer-free.
        TypeInvalid = newSSA("invalid")
        TypeMem     = newSSA("mem")
        TypeFlags   = newSSA("flags")
        TypeVoid    = newSSA("void")
        TypeInt128  = newSSA("int128")
)

The following variables must be initialized early by the frontend. They are here to break import cycles. TODO(gri) eliminate these dependencies.

var (
        Widthptr    int
        Dowidth     func(*Type)
        Fatalf      func(string, ...interface{})
        Sconv       func(*Sym, int, int) string       // orig: func sconv(s *Sym, flag FmtFlag, mode fmtMode) string
        Tconv       func(*Type, int, int, int) string // orig: func tconv(t *Type, flag FmtFlag, mode fmtMode, depth int) string
        FormatSym   func(*Sym, fmt.State, rune, int)  // orig: func symFormat(sym *Sym, s fmt.State, verb rune, mode fmtMode)
        FormatType  func(*Type, fmt.State, rune, int) // orig: func typeFormat(t *Type, s fmt.State, verb rune, mode fmtMode)
        TypeLinkSym func(*Type) *obj.LSym
        Ctxt        *obj.Link

        FmtLeft     int
        FmtUnsigned int
        FErr        int
)
var Block int32 // current block number
var InitSyms []*Sym

NewPtrCacheEnabled controls whether *T Types are cached in T. Caching is disabled just before starting the backend. This allows the backend to run concurrently.

var NewPtrCacheEnabled = true

ParamsResults is like RecvsParamsResults, but omits receiver parameters.

var ParamsResults = [2]func(*Type) *Type{
        (*Type).Params, (*Type).Results,
}

RecvsParams is like RecvsParamsResults, but omits result parameters.

var RecvsParams = [2]func(*Type) *Type{
        (*Type).Recvs, (*Type).Params,
}

RecvsParamsResults stores the accessor functions for a function Type's receiver, parameters, and result parameters, in that order. It can be used to iterate over all of a function's parameter lists.

var RecvsParamsResults = [3]func(*Type) *Type{
        (*Type).Recvs, (*Type).Params, (*Type).Results,
}

Types stores pointers to predeclared named types.

It also stores pointers to several special types:

- Types[TANY] is the placeholder "any" type recognized by substArgTypes.
- Types[TBLANK] represents the blank variable's type.
- Types[TIDEAL] represents untyped numeric constants.
- Types[TNIL] represents the predeclared "nil" value's type.
- Types[TUNSAFEPTR] is package unsafe's Pointer type.
var Types [NTYPE]*Type

func CleanroomDo

func CleanroomDo(f func())

CleanroomDo invokes f in an environment with no preexisting packages. For testing of import/export only.

func Haspointers

func Haspointers(t *Type) bool

func Haspointers1

func Haspointers1(t *Type, ignoreNotInHeap bool) bool

func Identical

func Identical(t1, t2 *Type) bool

Identical reports whether t1 and t2 are identical types, following the spec rules. Receiver parameter types are ignored.

func IdenticalIgnoreTags

func IdenticalIgnoreTags(t1, t2 *Type) bool

IdenticalIgnoreTags is like Identical, but it ignores struct tags for struct identity.

func InternString

func InternString(b []byte) string

func IsDclstackValid

func IsDclstackValid() bool

func IsExported

func IsExported(name string) bool

IsExported reports whether name is an exported Go symbol (that is, whether it begins with an upper-case letter).

func Markdcl

func Markdcl()

Markdcl records the start of a new block scope for declarations.

func Popdcl

func Popdcl()

Popdcl pops the innermost block scope and restores all symbol declarations to their previous state.

func Pushdcl

func Pushdcl(s *Sym)

Pushdcl pushes the current declaration for symbol s (if any) so that it can be shadowed by a new declaration within a nested block scope.

type Array

Array contains Type fields specific to array types.

type Array struct {
        Elem  *Type // element type
        Bound int64 // number of elements; <0 if unknown yet
}

type Chan

Chan contains Type fields specific to channel types.

type Chan struct {
        Elem *Type   // element type
        Dir  ChanDir // channel direction
}

type ChanArgs

ChanArgs contains Type fields specific to TCHANARGS types.

type ChanArgs struct {
        T *Type // reference to a chan type whose elements need a width check
}

type ChanDir

ChanDir is whether a channel can send, receive, or both.

type ChanDir uint8
const (
        // types of channel
        // must match ../../../../reflect/type.go:/ChanDir
        Crecv ChanDir = 1 << 0
        Csend ChanDir = 1 << 1
        Cboth ChanDir = Crecv | Csend
)

func (ChanDir) CanRecv

func (c ChanDir) CanRecv() bool

func (ChanDir) CanSend

func (c ChanDir) CanSend() bool

type Cmp

Cmp is a comparison between values a and b. -1 if a < b

0 if a == b
1 if a > b
type Cmp int8

type DDDField

DDDField contains Type fields specific to TDDDFIELD types.

type DDDField struct {
        T *Type // reference to a slice type for ... args
}

type EType

EType describes a kind of type.

type EType uint8
const (
        Txxx EType = iota

        TINT8
        TUINT8
        TINT16
        TUINT16
        TINT32
        TUINT32
        TINT64
        TUINT64
        TINT
        TUINT
        TUINTPTR

        TCOMPLEX64
        TCOMPLEX128

        TFLOAT32
        TFLOAT64

        TBOOL

        TPTR
        TFUNC
        TSLICE
        TARRAY
        TSTRUCT
        TCHAN
        TMAP
        TINTER
        TFORW
        TANY
        TSTRING
        TUNSAFEPTR

        // pseudo-types for literals
        TIDEAL
        TNIL
        TBLANK

        // pseudo-types for frame layout
        TFUNCARGS
        TCHANARGS

        // pseudo-types for import/export
        TDDDFIELD // wrapper: contained type is a ... field

        // SSA backend types
        TSSA   // internal types used by SSA backend (flags, memory, etc.)
        TTUPLE // a pair of types, used by SSA backend

        NTYPE
)

func (EType) String

func (i EType) String() string

type Field

A Field represents a field in a struct or a method in an interface or associated with a named type.

type Field struct {
        Embedded uint8 // embedded field

        Pos  src.XPos
        Sym  *Sym
        Type *Type  // field type
        Note string // literal string annotation

        // For fields that represent function parameters, Nname points
        // to the associated ONAME Node.
        Nname *Node

        // Offset in bytes of this field or method within its enclosing struct
        // or interface Type.
        Offset int64
        // contains filtered or unexported fields
}

func NewField

func NewField() *Field

func (*Field) Broke

func (f *Field) Broke() bool

func (*Field) Copy

func (f *Field) Copy() *Field

func (*Field) End

func (f *Field) End() int64

End returns the offset of the first byte immediately after this field.

func (*Field) IsDDD

func (f *Field) IsDDD() bool

func (*Field) Nointerface

func (f *Field) Nointerface() bool

func (*Field) SetBroke

func (f *Field) SetBroke(b bool)

func (*Field) SetIsDDD

func (f *Field) SetIsDDD(b bool)

func (*Field) SetNointerface

func (f *Field) SetNointerface(b bool)

type Fields

Fields is a pointer to a slice of *Field. This saves space in Types that do not have fields or methods compared to a simple slice of *Field.

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

func (*Fields) Append

func (f *Fields) Append(s ...*Field)

Append appends entries to f.

func (*Fields) Index

func (f *Fields) Index(i int) *Field

Index returns the i'th element of Fields. It panics if f does not have at least i+1 elements.

func (*Fields) Len

func (f *Fields) Len() int

Len returns the number of entries in f.

func (*Fields) Set

func (f *Fields) Set(s []*Field)

Set sets f to a slice. This takes ownership of the slice.

func (*Fields) Slice

func (f *Fields) Slice() []*Field

Slice returns the entries in f as a slice. Changes to the slice entries will be reflected in f.

type Forward

Forward contains Type fields specific to forward types.

type Forward struct {
        Copyto      []*Node  // where to copy the eventual value to
        Embedlineno src.XPos // first use of this type as an embedded type
}

type Funarg

Fnstruct records the kind of function argument

type Funarg uint8
const (
        FunargNone    Funarg = iota
        FunargRcvr           // receiver
        FunargParams         // input parameters
        FunargResults        // output results
)

type Func

Func contains Type fields specific to func types.

type Func struct {
        Receiver *Type // function receiver
        Results  *Type // function results
        Params   *Type // function params

        Nname *Node

        // Argwid is the total width of the function receiver, params, and results.
        // It gets calculated via a temporary TFUNCARGS type.
        // Note that TFUNC's Width is Widthptr.
        Argwid int64

        Outnamed bool
        // contains filtered or unexported fields
}

type FuncArgs

// FuncArgs contains Type fields specific to TFUNCARGS types.

type FuncArgs struct {
        T *Type // reference to a func type whose elements need a width check
}

type Interface

Interface contains Type fields specific to interface types.

type Interface struct {
        Fields Fields
        // contains filtered or unexported fields
}

type Map

Map contains Type fields specific to maps.

type Map struct {
        Key  *Type // Key type
        Elem *Type // Val (elem) type

        Bucket *Type // internal struct type representing a hash bucket
        Hmap   *Type // internal struct type representing the Hmap (map header object)
        Hiter  *Type // internal struct type representing hash iterator state
}

type Node

Dummy Node so we can refer to *Node without actually having a gc.Node. Necessary to break import cycles. TODO(gri) try to eliminate soon

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

type Pkg

type Pkg struct {
        Path    string // string literal used in import statement, e.g. "runtime/internal/sys"
        Name    string // package name, e.g. "sys"
        Prefix  string // escaped path for use in symbol table
        Syms    map[string]*Sym
        Pathsym *obj.LSym

        // Height is the package's height in the import graph. Leaf
        // packages (i.e., packages with no imports) have height 0,
        // and all other packages have height 1 plus the maximum
        // height of their imported packages.
        Height int

        Imported bool // export data of this package was parsed
        Direct   bool // imported directly
}

func ImportedPkgList

func ImportedPkgList() []*Pkg

ImportedPkgList returns the list of directly imported packages. The list is sorted by package path.

func NewPkg

func NewPkg(path, name string) *Pkg

NewPkg returns a new Pkg for the given package path and name. Unless name is the empty string, if the package exists already, the existing package name and the provided name must match.

func (*Pkg) Lookup

func (pkg *Pkg) Lookup(name string) *Sym

func (*Pkg) LookupBytes

func (pkg *Pkg) LookupBytes(name []byte) *Sym

func (*Pkg) LookupOK

func (pkg *Pkg) LookupOK(name string) (s *Sym, existed bool)

LookupOK looks up name in pkg and reports whether it previously existed.

type Ptr

Ptr contains Type fields specific to pointer types.

type Ptr struct {
        Elem *Type // element type
}

type Slice

Slice contains Type fields specific to slice types.

type Slice struct {
        Elem *Type // element type
}

type Struct

StructType contains Type fields specific to struct types.

type Struct struct {

        // Maps have three associated internal structs (see struct MapType).
        // Map links such structs back to their map type.
        Map *Type

        Funarg Funarg // type of function arguments for arg struct
        // contains filtered or unexported fields
}

type Sym

Sym represents an object name. Most commonly, this is a Go identifier naming an object declared within a package, but Syms are also used to name internal synthesized objects.

As an exception, field and method names that are exported use the Sym associated with localpkg instead of the package that declared them. This allows using Sym pointer equality to test for Go identifier uniqueness when handling selector expressions.

type Sym struct {
        Importdef *Pkg   // where imported definition was found
        Linkname  string // link name

        Pkg  *Pkg
        Name string // object name

        // saved and restored by dcopy
        Def        *Node    // definition: ONAME OTYPE OPACK or OLITERAL
        Block      int32    // blocknumber to catch redeclaration
        Lastlineno src.XPos // last declaration for diagnostic

        Label   *Node // corresponding label (ephemeral)
        Origpkg *Pkg  // original package for . import
        // contains filtered or unexported fields
}

func (*Sym) AlgGen

func (sym *Sym) AlgGen() bool

func (*Sym) Asm

func (sym *Sym) Asm() bool

func (*Sym) Format

func (sym *Sym) Format(s fmt.State, verb rune)

func (*Sym) Func

func (sym *Sym) Func() bool

func (*Sym) IsBlank

func (sym *Sym) IsBlank() bool

func (*Sym) Less

func (a *Sym) Less(b *Sym) bool

Less reports whether symbol a is ordered before symbol b.

Symbols are ordered exported before non-exported, then by name, and finally (for non-exported symbols) by package height and path.

Ordering by package height is necessary to establish a consistent ordering for non-exported names with the same spelling but from different packages. We don't necessarily know the path for the package being compiled, but by definition it will have a height greater than any other packages seen within the compilation unit. For more background, see issue #24693.

func (*Sym) Linksym

func (sym *Sym) Linksym() *obj.LSym

func (*Sym) LinksymName

func (sym *Sym) LinksymName() string

func (*Sym) OnExportList

func (sym *Sym) OnExportList() bool

func (*Sym) PkgDef

func (s *Sym) PkgDef() *Node

PkgDef returns the definition associated with s at package scope.

func (*Sym) SetAlgGen

func (sym *Sym) SetAlgGen(b bool)

func (*Sym) SetAsm

func (sym *Sym) SetAsm(b bool)

func (*Sym) SetFunc

func (sym *Sym) SetFunc(b bool)

func (*Sym) SetOnExportList

func (sym *Sym) SetOnExportList(b bool)

func (*Sym) SetPkgDef

func (s *Sym) SetPkgDef(n *Node)

SetPkgDef sets the definition associated with s at package scope.

func (*Sym) SetSiggen

func (sym *Sym) SetSiggen(b bool)

func (*Sym) SetUniq

func (sym *Sym) SetUniq(b bool)

func (*Sym) Siggen

func (sym *Sym) Siggen() bool

func (*Sym) String

func (s *Sym) String() string

func (*Sym) Uniq

func (sym *Sym) Uniq() bool

type Tuple

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

type Type

A Type represents a Go type.

type Type struct {
        // Extra contains extra etype-specific fields.
        // As an optimization, those etype-specific structs which contain exactly
        // one pointer-shaped field are stored as values rather than pointers when possible.
        //
        // TMAP: *Map
        // TFORW: *Forward
        // TFUNC: *Func
        // TSTRUCT: *Struct
        // TINTER: *Interface
        // TDDDFIELD: DDDField
        // TFUNCARGS: FuncArgs
        // TCHANARGS: ChanArgs
        // TCHAN: *Chan
        // TPTR: Ptr
        // TARRAY: *Array
        // TSLICE: Slice
        Extra interface{}

        // Width is the width of this Type in bytes.
        Width int64 // valid if Align > 0

        Nod  *Node // canonical OTYPE node
        Orig *Type // original type (type literal or predefined type)

        // Cache of composite types, with this type being the element type.
        Cache struct {
                // contains filtered or unexported fields
        }

        Sym    *Sym  // symbol containing name, for named types
        Vargen int32 // unique name for OTYPE/ONAME

        Etype EType // kind of type
        Align uint8 // the required alignment of this type, in bytes (0 means Width and Align have not yet been computed)
        // contains filtered or unexported fields
}

func FakeRecvType

func FakeRecvType() *Type

FakeRecvType returns the singleton type used for interface method receivers.

func New

func New(et EType) *Type

New returns a new Type of the specified kind.

func NewArray

func NewArray(elem *Type, bound int64) *Type

NewArray returns a new fixed-length array Type.

func NewChan

func NewChan(elem *Type, dir ChanDir) *Type

NewChan returns a new chan Type with direction dir.

func NewChanArgs

func NewChanArgs(c *Type) *Type

NewChanArgs returns a new TCHANARGS type for channel type c.

func NewDDDArray

func NewDDDArray(elem *Type) *Type

NewDDDArray returns a new [...]T array Type.

func NewDDDField

func NewDDDField(s *Type) *Type

NewDDDField returns a new TDDDFIELD type for slice type s.

func NewFuncArgs

func NewFuncArgs(f *Type) *Type

NewFuncArgs returns a new TFUNCARGS type for func type f.

func NewMap

func NewMap(k, v *Type) *Type

NewMap returns a new map Type with key type k and element (aka value) type v.

func NewPtr

func NewPtr(elem *Type) *Type

NewPtr returns the pointer type pointing to t.

func NewSlice

func NewSlice(elem *Type) *Type

NewSlice returns the slice Type with element type elem.

func NewTuple

func NewTuple(t1, t2 *Type) *Type

func SubstAny

func SubstAny(t *Type, types *[]*Type) *Type

SubstAny walks t, replacing instances of "any" with successive elements removed from types. It returns the substituted type.

func (*Type) Alignment

func (t *Type) Alignment() int64

func (*Type) AllMethods

func (t *Type) AllMethods() *Fields

func (*Type) ArgWidth

func (t *Type) ArgWidth() int64

ArgWidth returns the total aligned argument size for a function. It includes the receiver, parameters, and results.

func (*Type) Broke

func (t *Type) Broke() bool

func (*Type) ChanArgs

func (t *Type) ChanArgs() *Type

ChanArgs returns the channel type for TCHANARGS type t.

func (*Type) ChanDir

func (t *Type) ChanDir() ChanDir

ChanDir returns the direction of a channel type t. The direction will be one of Crecv, Csend, or Cboth.

func (*Type) ChanType

func (t *Type) ChanType() *Chan

ChanType returns t's extra channel-specific fields.

func (*Type) Compare

func (t *Type) Compare(x *Type) Cmp

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 (*Type) DDDField

func (t *Type) DDDField() *Type

DDDField returns the slice ... type for TDDDFIELD type t.

func (*Type) Deferwidth

func (t *Type) Deferwidth() bool

func (*Type) Elem

func (t *Type) Elem() *Type

Elem returns the type of elements of t. Usable with pointers, channels, arrays, slices, and maps.

func (*Type) Field

func (t *Type) Field(i int) *Field

Field returns the i'th field/method of struct/interface type t.

func (*Type) FieldName

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

func (*Type) FieldOff

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

func (*Type) FieldSlice

func (t *Type) FieldSlice() []*Field

FieldSlice returns a slice of containing all fields/methods of struct/interface type t.

func (*Type) FieldType

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

func (*Type) Fields

func (t *Type) Fields() *Fields

func (*Type) Format

func (t *Type) Format(s fmt.State, verb rune)

func (*Type) ForwardType

func (t *Type) ForwardType() *Forward

ForwardType returns t's extra forward-type-specific fields.

func (*Type) FuncArgs

func (t *Type) FuncArgs() *Type

FuncArgs returns the func type for TFUNCARGS type t.

func (*Type) FuncType

func (t *Type) FuncType() *Func

FuncType returns t's extra func-specific fields.

func (*Type) HasHeapPointer

func (t *Type) HasHeapPointer() bool

HasHeapPointer reports whether t contains a heap pointer. This is used for write barrier insertion, so it ignores pointers to go:notinheap types.

func (*Type) IsArray

func (t *Type) IsArray() bool

func (*Type) IsBoolean

func (t *Type) IsBoolean() bool

func (*Type) IsChan

func (t *Type) IsChan() bool

func (*Type) IsComplex

func (t *Type) IsComplex() bool

func (*Type) IsDDDArray

func (t *Type) IsDDDArray() bool

func (*Type) IsEmptyInterface

func (t *Type) IsEmptyInterface() bool

IsEmptyInterface reports whether t is an empty interface type.

func (*Type) IsFlags

func (t *Type) IsFlags() bool

func (*Type) IsFloat

func (t *Type) IsFloat() bool

func (*Type) IsFuncArgStruct

func (t *Type) IsFuncArgStruct() bool

IsFuncArgStruct reports whether t is a struct representing function parameters.

func (*Type) IsInteger

func (t *Type) IsInteger() bool

func (*Type) IsInterface

func (t *Type) IsInterface() bool

func (*Type) IsKind

func (t *Type) IsKind(et EType) bool

IsKind reports whether t is a Type of the specified kind.

func (*Type) IsMap

func (t *Type) IsMap() bool

func (*Type) IsMemory

func (t *Type) IsMemory() bool

func (*Type) IsPtr

func (t *Type) IsPtr() bool

IsPtr reports whether t is a regular Go pointer type. This does not include unsafe.Pointer.

func (*Type) IsPtrElem

func (t *Type) IsPtrElem() bool

IsPtrElem reports whether t is the element of a pointer (to t).

func (*Type) IsPtrShaped

func (t *Type) IsPtrShaped() 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 (*Type) IsSigned

func (t *Type) IsSigned() bool

func (*Type) IsSlice

func (t *Type) IsSlice() bool

func (*Type) IsString

func (t *Type) IsString() bool

func (*Type) IsStruct

func (t *Type) IsStruct() bool

func (*Type) IsTuple

func (t *Type) IsTuple() bool

func (*Type) IsUnsafePtr

func (t *Type) IsUnsafePtr() bool

IsUnsafePtr reports whether t is an unsafe pointer.

func (*Type) IsUntyped

func (t *Type) IsUntyped() bool

IsUntyped reports whether t is an untyped type.

func (*Type) IsVariadic

func (t *Type) IsVariadic() bool

IsVariadic reports whether function type t is variadic.

func (*Type) IsVoid

func (t *Type) IsVoid() bool

func (*Type) Key

func (t *Type) Key() *Type

Key returns the key type of map type t.

func (*Type) LongString

func (t *Type) LongString() string

LongString generates a complete description of t. It is useful for reflection, or when a unique fingerprint or hash of a type is required.

func (*Type) MapType

func (t *Type) MapType() *Map

MapType returns t's extra map-specific fields.

func (*Type) Methods

func (t *Type) Methods() *Fields

func (*Type) Nname

func (t *Type) Nname() *Node

Nname returns the associated function's nname.

func (*Type) Noalg

func (t *Type) Noalg() bool

func (*Type) NotInHeap

func (t *Type) NotInHeap() bool

func (*Type) NumComponents

func (t *Type) NumComponents(countBlank componentsIncludeBlankFields) int64

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 (*Type) NumElem

func (t *Type) NumElem() int64

func (*Type) NumFields

func (t *Type) NumFields() int

func (*Type) NumParams

func (t *Type) NumParams() int

func (*Type) NumRecvs

func (t *Type) NumRecvs() int

func (*Type) NumResults

func (t *Type) NumResults() int

func (*Type) Params

func (t *Type) Params() *Type

func (*Type) Pkg

func (t *Type) Pkg() *Pkg

Pkg returns the package that t appeared in.

Pkg is only defined for function, struct, and interface types (i.e., types with named elements). This information isn't used by cmd/compile itself, but we need to track it because it's exposed by the go/types API.

func (*Type) PtrTo

func (t *Type) PtrTo() *Type

func (*Type) Recur

func (t *Type) Recur() bool

func (*Type) Recv

func (t *Type) Recv() *Field

Recv returns the receiver of function type t, if any.

func (*Type) Recvs

func (t *Type) Recvs() *Type

func (*Type) Results

func (t *Type) Results() *Type

func (*Type) SetBroke

func (t *Type) SetBroke(b bool)

func (*Type) SetDeferwidth

func (t *Type) SetDeferwidth(b bool)

func (*Type) SetFields

func (t *Type) SetFields(fields []*Field)

SetFields sets struct/interface type t's fields/methods to fields.

func (*Type) SetInterface

func (t *Type) SetInterface(methods []*Field)

func (*Type) SetNname

func (t *Type) SetNname(n *Node)

Nname sets the associated function's nname.

func (*Type) SetNoalg

func (t *Type) SetNoalg(b bool)

func (*Type) SetNotInHeap

func (t *Type) SetNotInHeap(b bool)

func (*Type) SetNumElem

func (t *Type) SetNumElem(n int64)

SetNumElem sets the number of elements in an array type. The only allowed use is on array types created with NewDDDArray. For other uses, create a new array with NewArray instead.

func (*Type) SetPkg

func (t *Type) SetPkg(pkg *Pkg)

SetPkg sets the package that t appeared in.

func (*Type) SetRecur

func (t *Type) SetRecur(b bool)

func (*Type) ShortString

func (t *Type) ShortString() string

ShortString generates a short description of t. It is used in autogenerated method names, reflection, and itab names.

func (*Type) SimpleString

func (t *Type) SimpleString() string

func (*Type) Size

func (t *Type) Size() int64

func (*Type) String

func (t *Type) String() string

func (*Type) StructType

func (t *Type) StructType() *Struct

StructType returns t's extra struct-specific fields.

func (*Type) Symbol

func (t *Type) Symbol() *obj.LSym

func (*Type) Tie

func (t *Type) Tie() byte

Tie returns 'T' if t is a concrete type, 'I' if t is an interface type, and 'E' if t is an empty interface type. It is used to build calls to the conv* and assert* runtime routines.

func (*Type) ToUnsigned

func (t *Type) ToUnsigned() *Type

ToUnsigned returns the unsigned equivalent of integer type t.

func (*Type) WidthCalculated

func (t *Type) WidthCalculated() bool