types

Imports

Imports #

"cmd/compile/internal/base"
"fmt"
"internal/goversion"
"internal/lazyregexp"
"log"
"strconv"
"cmd/compile/internal/base"
"cmd/compile/internal/base"
"cmd/internal/obj"
"strings"
"unicode"
"unicode/utf8"
"cmd/compile/internal/base"
"cmd/internal/objabi"
"cmd/internal/src"
"fmt"
"go/constant"
"internal/buildcfg"
"internal/types/errors"
"sync"
"cmd/compile/internal/base"
"cmd/internal/src"
"strconv"
"bytes"
"encoding/binary"
"fmt"
"strconv"
"sync"
"cmd/compile/internal/base"
"cmd/internal/hash"
"strconv"
"cmd/internal/obj"
"cmd/internal/objabi"
"fmt"
"strconv"
"sync"
"math"
"slices"
"cmd/compile/internal/base"
"cmd/internal/src"
"internal/types/errors"

Constants & Variables

ACPLX128 const #

const ACPLX128

ACPLX64 const #

const ACPLX64

AFLOAT32 const #

const AFLOAT32

AFLOAT64 const #

const AFLOAT64

AINTER const #

const AINTER

AMEM const #

const AMEM

AMEM0 const #

const AMEM0

AMEM128 const #

const AMEM128

AMEM16 const #

const AMEM16

AMEM32 const #

const AMEM32

AMEM64 const #

const AMEM64

AMEM8 const #

const AMEM8

ANILINTER const #

const ANILINTER

ANOALG const #

const ANOALG

ANOEQ const #

const ANOEQ

ASPECIAL const #

const ASPECIAL

ASTRING const #

const ASTRING

AUNK const #

const AUNK AlgKind = iota

AnyType var #

Predeclared alias types. These are actually created as distinct defined types for better error messages, but are then specially treated as identical to their respective underlying types.

var AnyType *Type

BADWIDTH const #

const BADWIDTH = *ast.UnaryExpr

BasicTypeNames var #

var BasicTypeNames = []string{...}

BlankSym var #

BlankSym is the blank (_) symbol.

var BlankSym *Sym

BuiltinPkg var #

BuiltinPkg is a fake package that declares the universe block.

var BuiltinPkg *Pkg

ByteType var #

var ByteType *Type

CMPeq const #

const CMPeq = *ast.CallExpr

CMPgt const #

const CMPgt = *ast.CallExpr

CMPlt const #

const CMPlt = *ast.CallExpr

CalcSizeDisabled var #

CalcSizeDisabled indicates whether it is safe to calculate Types' widths and alignments. See CalcSize.

var CalcSizeDisabled bool

Cboth const #

const Cboth ChanDir = *ast.BinaryExpr

ComparableType var #

Predeclared comparable interface type.

var ComparableType *Type

CountBlankFields const #

const CountBlankFields componentsIncludeBlankFields = true

Crecv const #

types of channel must match ../../../../reflect/type.go:/ChanDir

const Crecv ChanDir = *ast.BinaryExpr

Csend const #

const Csend ChanDir = *ast.BinaryExpr

DefaultKinds var #

DefaultKinds maps from a constant.Kind to its default Kind.

var DefaultKinds = [...]Kind{...}

ErrorType var #

Predeclared error interface type.

var ErrorType *Type

IgnoreBlankFields const #

const IgnoreBlankFields componentsIncludeBlankFields = false

IsComplex var #

var IsComplex [NTYPE]bool

IsFloat var #

var IsFloat [NTYPE]bool

IsInt var #

var IsInt [NTYPE]bool

IsOrdered var #

var IsOrdered [NTYPE]bool

IsSimple var #

var IsSimple [NTYPE]bool

LocalPkg var #

LocalPkg is the package being compiled.

var LocalPkg *Pkg

MaxWidth var #

MaxWidth is the maximum size of a value on the target architecture.

var MaxWidth int64

NTYPE const #

const NTYPE

NewPtrCacheEnabled var #

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

NumImport var #

numImport tracks how often a package with a given name is imported. It is used to provide a better error message (by using the package path to disambiguate) if a package that appears multiple times with the same name appears in an error message.

var NumImport = *ast.CallExpr

PtrSize var #

var PtrSize int

RegSize var #

var RegSize int

RuneType var #

var RuneType *Type

ShapePkg var #

Fake package for shape types (see typecheck.Shapify()).

var ShapePkg = *ast.CallExpr

SimType var #

var SimType [NTYPE]Kind

SkipSizeForTracing var #

var SkipSizeForTracing bool

SliceCapOffset var #

Slices in the runtime are represented by three components: type slice struct { ptr unsafe.Pointer len int cap int } Strings in the runtime are represented by two components: type string struct { ptr unsafe.Pointer len int } These variables are the offsets of fields and sizes of these structs.

var SliceCapOffset int64

SliceLenOffset var #

Slices in the runtime are represented by three components: type slice struct { ptr unsafe.Pointer len int cap int } Strings in the runtime are represented by two components: type string struct { ptr unsafe.Pointer len int } These variables are the offsets of fields and sizes of these structs.

var SliceLenOffset int64

SlicePtrOffset var #

Slices in the runtime are represented by three components: type slice struct { ptr unsafe.Pointer len int cap int } Strings in the runtime are represented by two components: type string struct { ptr unsafe.Pointer len int } These variables are the offsets of fields and sizes of these structs.

var SlicePtrOffset int64

SliceSize var #

Slices in the runtime are represented by three components: type slice struct { ptr unsafe.Pointer len int cap int } Strings in the runtime are represented by two components: type string struct { ptr unsafe.Pointer len int } These variables are the offsets of fields and sizes of these structs.

var SliceSize int64

StringSize var #

Slices in the runtime are represented by three components: type slice struct { ptr unsafe.Pointer len int cap int } Strings in the runtime are represented by two components: type string struct { ptr unsafe.Pointer len int } These variables are the offsets of fields and sizes of these structs.

var StringSize int64

TANY const #

const TANY

TARRAY const #

const TARRAY

TBLANK const #

const TBLANK

TBOOL const #

const TBOOL

TCHAN const #

const TCHAN

TCHANARGS const #

const TCHANARGS

TCOMPLEX128 const #

const TCOMPLEX128

TCOMPLEX64 const #

const TCOMPLEX64

TFLOAT32 const #

const TFLOAT32

TFLOAT64 const #

const TFLOAT64

TFORW const #

const TFORW

TFUNC const #

const TFUNC

TFUNCARGS const #

pseudo-types used temporarily only during frame layout (CalcSize())

const TFUNCARGS

TIDEAL const #

pseudo-types for literals

const TIDEAL

TINT const #

const TINT

TINT16 const #

const TINT16

TINT32 const #

const TINT32

TINT64 const #

const TINT64

TINT8 const #

const TINT8

TINTER const #

const TINTER

TMAP const #

const TMAP

TNIL const #

const TNIL

TPTR const #

const TPTR

TRESULTS const #

const TRESULTS

TSLICE const #

const TSLICE

TSSA const #

SSA backend types

const TSSA

TSTRING const #

const TSTRING

TSTRUCT const #

const TSTRUCT

TTUPLE const #

const TTUPLE

TUINT const #

const TUINT

TUINT16 const #

const TUINT16

TUINT32 const #

const TUINT32

TUINT64 const #

const TUINT64

TUINT8 const #

const TUINT8

TUINTPTR const #

const TUINTPTR

TUNSAFEPTR const #

const TUNSAFEPTR

Txxx const #

const Txxx Kind = iota

TypeFlags var #

var TypeFlags = *ast.CallExpr

TypeInt128 var #

var TypeInt128 = *ast.CallExpr

TypeInvalid var #

TSSA types. HasPointers assumes these are pointer-free.

var TypeInvalid = *ast.CallExpr

TypeMem var #

var TypeMem = *ast.CallExpr

TypeResultMem var #

var TypeResultMem = *ast.CallExpr

TypeVoid var #

var TypeVoid = *ast.CallExpr

Types var #

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[TINTER] is the canonical "interface{}" type. - Types[TNIL] represents the predeclared "nil" value's type. - Types[TUNSAFEPTR] is package unsafe's Pointer type.

var Types [NTYPE]*Type

UnsafePkg var #

UnsafePkg is package unsafe.

var UnsafePkg *Pkg

UntypedBool var #

var UntypedBool = *ast.CallExpr

UntypedComplex var #

var UntypedComplex = *ast.CallExpr

UntypedFloat var #

var UntypedFloat = *ast.CallExpr

UntypedInt var #

Types to represent untyped numeric constants.

var UntypedInt = *ast.CallExpr

UntypedRune var #

var UntypedRune = *ast.CallExpr

UntypedString var #

Types to represent untyped string and boolean constants.

var UntypedString = *ast.CallExpr

UntypedTypes var #

UntypedTypes maps from a constant.Kind to its untyped Type representation.

var UntypedTypes = [...]*Type{...}

_AlgKind_index var #

var _AlgKind_index = [...]uint8{...}

_AlgKind_name const #

const _AlgKind_name = "UNKNOEQNOALGMEMMEM0MEM8MEM16MEM32MEM64MEM128STRINGINTERNILINTERFLOAT32FLOAT64CPLX64CPLX128SPECIAL"

_Kind_index var #

var _Kind_index = [...]uint8{...}

_Kind_name const #

const _Kind_name = "xxxINT8UINT8INT16UINT16INT32UINT32INT64UINT64INTUINTUINTPTRCOMPLEX64COMPLEX128FLOAT32FLOAT64BOOLPTRFUNCSLICEARRAYSTRUCTCHANMAPINTERFORWANYSTRINGUNSAFEPTRIDEALNILBLANKFUNCARGSCHANARGSSSATUPLERESULTSNTYPE"

algPriority var #

Most kinds are priority 0. Higher numbers are higher priority, in that the higher priority kinds override lower priority kinds.

var algPriority = [*ast.BinaryExpr]int8{...}

basicTypes var #

var basicTypes = [...]struct{...}{...}

defercalc var #

machine size and rounding alignment is dictated around the size of a pointer, set in gc.Main (see ../gc/main.go).

var defercalc int

deferredTypeStack var #

var deferredTypeStack []*Type

fieldIsDDD const #

const fieldIsDDD = *ast.BinaryExpr

fieldNointerface const #

const fieldNointerface

fmtBufferPool var #

var fmtBufferPool = sync.Pool{...}

fmtDebug const #

const fmtDebug

fmtGo const #

const fmtGo fmtMode = iota

fmtTypeID const #

const fmtTypeID

fmtTypeIDName const #

const fmtTypeIDName

goVersionRE var #

goVersionRE is a regular expression that matches the valid arguments to the -lang flag.

var goVersionRE = *ast.CallExpr

identIgnoreTags const #

const identIgnoreTags = *ast.BinaryExpr

identStrict const #

const identStrict

internedStrings var #

var internedStrings = map[string]string{...}

internedStringsmu var #

var internedStringsmu sync.Mutex

langWant var #

langWant is the desired language version set by the -lang flag. If the -lang flag is not set, this is the zero value, meaning that any language version is supported.

var langWant lang

nopkg var #

var nopkg = *ast.UnaryExpr

pkgMap var #

pkgMap maps a package path to a package.

var pkgMap = *ast.CallExpr

recvType var #

var recvType *Type

symAsm const #

const symAsm

symFunc const #

const symFunc

symOnExportList const #

const symOnExportList = *ast.BinaryExpr

symSiggen const #

const symSiggen

symUniq const #

const symUniq

typeDeferwidth const #

const typeDeferwidth

typeHasShape const #

const typeHasShape

typeIsFullyInstantiated const #

typeIsFullyInstantiated reports whether a type is fully instantiated generic type; i.e. an instantiated generic type where all type arguments are non-generic or fully instantiated generic types.

const typeIsFullyInstantiated

typeIsShape const #

const typeIsShape

typeNoalg const #

const typeNoalg

typeNotInHeap const #

const typeNotInHeap = *ast.BinaryExpr

typeRecur const #

const typeRecur

typedefs var #

var typedefs = [...]struct{...}{...}

typepkg var #

Fake package for runtime type info (headers) Don't access directly, use typeLookup below.

var typepkg = *ast.CallExpr

typepkgmu var #

Fake package for runtime type info (headers) Don't access directly, use typeLookup below.

var typepkgmu sync.Mutex

unsignedEType var #

var unsignedEType = [...]Kind{...}

Type Aliases

AlgKind type #

AlgKind describes the kind of algorithms used for comparing and hashing a Type.

type AlgKind int8

ChanDir type #

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

type ChanDir uint8

Cmp type #

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

type Cmp int8

Kind type #

Kind describes a kind of type.

type Kind uint8

bitset8 type #

type bitset8 uint8

componentsIncludeBlankFields type #

type componentsIncludeBlankFields bool

fmtMode type #

fmtMode represents the kind of printing being done. The default is regular Go syntax (fmtGo). fmtDebug is like fmtGo but for debugging dumps and prints the type kind too. fmtTypeID and fmtTypeIDName are for generating various unique representations of types used in hashes, the linker, and function/method instantiations.

type fmtMode int

Interfaces

Object interface #

Object represents an ir.Node, but without needing to import cmd/compile/internal/ir, which would cause an import cycle. The uses in other packages must type assert values of type Object to ir.Node or a more specific type.

type Object interface {
Pos() src.XPos
Sym() *Sym
Type() *Type
}

Structs

Array struct #

Array contains Type fields specific to array types.

type Array struct {
Elem *Type
Bound int64
}

Chan struct #

Chan contains Type fields specific to channel types.

type Chan struct {
Elem *Type
Dir ChanDir
}

ChanArgs struct #

ChanArgs contains Type fields specific to TCHANARGS types.

type ChanArgs struct {
T *Type
}

Field struct #

A Field is a (Sym, Type) pairing along with some other information, and, depending on the context, is used to represent: - a field in a struct - a method in an interface or associated with a named type - a function parameter

type Field struct {
flags bitset8
Embedded uint8
Pos src.XPos
Sym *Sym
Type *Type
Note string
Nname Object
Offset int64
}

Forward struct #

Forward contains Type fields specific to forward types.

type Forward struct {
Copyto []*Type
Embedlineno src.XPos
}

Func struct #

Func contains Type fields specific to func types.

type Func struct {
allParams []*Field
startParams int
startResults int
resultsTuple *Type
Argwid int64
}

FuncArgs struct #

FuncArgs contains Type fields specific to TFUNCARGS types.

type FuncArgs struct {
T *Type
}

Interface struct #

Interface contains Type fields specific to interface types.

type Interface struct {

}

Map struct #

Map contains Type fields specific to maps.

type Map struct {
Key *Type
Elem *Type
OldBucket *Type
SwissGroup *Type
}

Pkg struct #

type Pkg struct {
Path string
Name string
Prefix string
Syms map[string]*Sym
Pathsym *obj.LSym
Direct bool
}

Ptr struct #

Ptr contains Type fields specific to pointer types.

type Ptr struct {
Elem *Type
}

Results struct #

Results are the output from calls that will be late-expanded.

type Results struct {
Types []*Type
}

Slice struct #

Slice contains Type fields specific to slice types.

type Slice struct {
Elem *Type
}

Struct struct #

StructType contains Type fields specific to struct types.

type Struct struct {
fields fields
Map *Type
ParamTuple bool
}

Sym struct #

Sym represents an object name in a segmented (pkg, name) namespace. 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. Ideally, Sym should be used for representing Go language constructs, while cmd/internal/obj.LSym is used for representing emitted artifacts. NOTE: In practice, things can be messier than the description above for various reasons (historical, convenience).

type Sym struct {
Linkname string
Pkg *Pkg
Name string
Def Object
flags bitset8
}

Tuple struct #

type Tuple struct {
first *Type
second *Type
}

Type struct #

A Type represents a Go type. There may be multiple unnamed types with identical structure. However, there must be a unique Type object for each unique named (defined) type. After noding, a package-level type can be looked up by building its unique symbol sym (sym = package.Lookup(name)) and checking sym.Def. If sym.Def is non-nil, the type already exists at package scope and is available at sym.Def.(*ir.Name).Type(). Local types (which may have the same name as a package-level type) are distinguished by their vargen, which is embedded in their symbol name.

type Type struct {
extra interface{}
width int64
methods fields
allMethods fields
obj Object
underlying *Type
cache struct{...}
kind Kind
align uint8
intRegs uint8
floatRegs uint8
flags bitset8
alg AlgKind
ptrBytes int64
}

fields struct #

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 {
s *[]*Field
}

lang struct #

A lang is a language version broken into major and minor numbers.

type lang struct {
major int
minor int
}

typePair struct #

type typePair struct {
t1 *Type
t2 *Type
}

Functions

AlgType function #

AlgType returns the AlgKind used for comparing and hashing Type t.

func AlgType(t *Type) AlgKind

Alignment method #

func (t *Type) Alignment() int64

AllMethods method #

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

AllowsGoVersion function #

AllowsGoVersion reports whether local package is allowed to use Go version major.minor.

func AllowsGoVersion(major int, minor int) bool

ArgWidth method #

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

func (t *Type) ArgWidth() int64

Asm method #

func (sym *Sym) Asm() bool

CalcSize function #

CalcSize calculates and stores the size, alignment, eq/hash algorithm, and ptrBytes for t. If CalcSizeDisabled is set, and the size/alignment have not already been calculated, it calls Fatal. This is used to prevent data races in the back end.

func CalcSize(t *Type)

CalcStructSize function #

CalcStructSize calculates the size of t, filling in t.width, t.align, t.intRegs, and t.floatRegs, even if size calculation is otherwise disabled.

func CalcStructSize(t *Type)

CanBeAnSSAAux method #

func (*Type) CanBeAnSSAAux()

CanRecv method #

func (c ChanDir) CanRecv() bool

CanSend method #

func (c ChanDir) CanSend() bool

ChanArgs method #

ChanArgs returns the channel type for TCHANARGS type t.

func (t *Type) ChanArgs() *Type

ChanDir method #

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

func (t *Type) ChanDir() ChanDir

CheckSize function #

func CheckSize(t *Type)

Compare method #

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

CompareFields function #

CompareFields compares two Field values by name.

func CompareFields(a *Field, b *Field) int

CompareSyms function #

CompareSyms return the ordering of a and b, as for [cmp.Compare]. Symbols are ordered exported before non-exported, then by name, and finally (for non-exported symbols) by package path.

func CompareSyms(a *Sym, b *Sym) int

ComplexForFloat function #

func ComplexForFloat(t *Type) *Type

Copy method #

func (f *Field) Copy() *Field

DeferCheckSize function #

func DeferCheckSize()

Deferwidth method #

func (t *Type) Deferwidth() bool

Elem method #

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

func (t *Type) Elem() *Type

End method #

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

func (f *Field) End() int64

FakeRecv function #

func FakeRecv() *Field

FakeRecvType function #

FakeRecvType returns the singleton type used for interface method receivers.

func FakeRecvType() *Type

Field method #

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

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

FieldName method #

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

FieldOff method #

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

FieldType method #

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

Fields method #

Fields returns a slice of containing all fields of a struct type t.

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

FloatForComplex function #

func FloatForComplex(t *Type) *Type

Format method #

Format implements formatting for a Type. The valid formats are: %v Go syntax %+v Debug syntax: Go syntax with a KIND- prefix for all but builtins. %L Go syntax for underlying type if t is named %S short Go syntax: drop leading "func" in function type %-S special case for method receiver symbol

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

Format method #

Format implements formatting for a Sym. The valid formats are: %v Go syntax: Name for symbols in the local package, PkgName.Name for imported symbols. %+v Debug syntax: always include PkgName. prefix even for local names. %S Short syntax: Name only, no matter what.

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

Func method #

func (sym *Sym) Func() bool

FuncArgs method #

FuncArgs returns the func type for TFUNCARGS type t.

func (t *Type) FuncArgs() *Type

HasNil method #

HasNil reports whether the set of values determined by t includes nil.

func (t *Type) HasNil() bool

HasPointers method #

HasPointers reports whether t contains a heap pointer. Note that this function ignores pointers to not-in-heap types.

func (t *Type) HasPointers() bool

HasShape method #

func (t *Type) HasShape() bool

Identical function #

Identical reports whether t1 and t2 are identical types, following the spec rules. Receiver parameter types are ignored. Named (defined) types are only equal if they are pointer-equal - i.e. there must be a unique types.Type for each specific named type. Also, a type containing a shape type is considered identical to another type (shape or not) if their underlying types are the same, or they are both pointers.

func Identical(t1 *Type, t2 *Type) bool

IdenticalIgnoreTags function #

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

func IdenticalIgnoreTags(t1 *Type, t2 *Type) bool

IdenticalStrict function #

IdenticalStrict is like Identical, but matches types exactly, without the exception for shapes.

func IdenticalStrict(t1 *Type, t2 *Type) bool

IncomparableField function #

IncomparableField returns an incomparable Field of struct Type t, if any.

func IncomparableField(t *Type) *Field

InitTypes function #

func InitTypes(defTypeName func(sym *Sym, typ *Type) Object)

InternString function #

func InternString(b []byte) string

IsArray method #

func (t *Type) IsArray() bool

IsBlank method #

func (sym *Sym) IsBlank() bool

IsBoolean method #

func (t *Type) IsBoolean() bool

IsChan method #

func (t *Type) IsChan() bool

IsComparable function #

IsComparable reports whether t is a comparable type.

func IsComparable(t *Type) bool

IsComplex method #

func (t *Type) IsComplex() bool

IsDDD method #

func (f *Field) IsDDD() bool

IsDirectIface function #

Can this type be stored directly in an interface word? Yes, if the representation is a single pointer.

func IsDirectIface(t *Type) bool

IsEmptyInterface method #

IsEmptyInterface reports whether t is an empty interface type.

func (t *Type) IsEmptyInterface() bool

IsExported function #

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

func IsExported(name string) bool

IsFlags method #

func (t *Type) IsFlags() bool

IsFloat method #

func (t *Type) IsFloat() bool

IsFullyInstantiated method #

func (t *Type) IsFullyInstantiated() bool

IsFuncArgStruct method #

IsFuncArgStruct reports whether t is a struct representing function parameters or results.

func (t *Type) IsFuncArgStruct() bool

IsInteger method #

func (t *Type) IsInteger() bool

IsInterface method #

func (t *Type) IsInterface() bool

IsInterfaceMethod function #

IsInterfaceMethod reports whether (field) m is an interface method. Such methods have the special receiver type types.FakeRecvType().

func IsInterfaceMethod(f *Type) bool

IsKind method #

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

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

IsMap method #

func (t *Type) IsMap() bool

IsMemory method #

func (t *Type) IsMemory() bool

IsMethod method #

IsMethod reports whether f represents a method rather than a struct field.

func (f *Field) IsMethod() bool

IsMethodApplicable function #

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

IsNoInstrumentPkg function #

IsNoInstrumentPkg reports whether p is a package that should not be instrumented.

func IsNoInstrumentPkg(p *Pkg) bool

IsNoRacePkg function #

IsNoRacePkg reports whether p is a package that should not be race instrumented.

func IsNoRacePkg(p *Pkg) bool

IsPaddedField function #

IsPaddedField reports whether the i'th field of struct type t is followed by padding.

func IsPaddedField(t *Type, i int) bool

IsPtr method #

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

func (t *Type) IsPtr() bool

IsPtrElem method #

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

func (t *Type) IsPtrElem() bool

IsPtrShaped method #

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

IsReflexive function #

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

IsResults method #

func (t *Type) IsResults() bool

IsRuntimePkg function #

IsRuntimePkg reports whether p is a runtime package.

func IsRuntimePkg(p *Pkg) bool

IsScalar method #

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

IsShape method #

func (t *Type) IsShape() bool

IsSigned method #

func (t *Type) IsSigned() bool

IsSlice method #

func (t *Type) IsSlice() bool

IsString method #

func (t *Type) IsString() bool

IsStruct method #

func (t *Type) IsStruct() bool

IsTuple method #

func (t *Type) IsTuple() bool

IsUintptr method #

IsUintptr reports whether t is a uintptr.

func (t *Type) IsUintptr() bool

IsUnsafePtr method #

IsUnsafePtr reports whether t is an unsafe pointer.

func (t *Type) IsUnsafePtr() bool

IsUnsigned method #

func (t *Type) IsUnsigned() bool

IsUntyped method #

IsUntyped reports whether t is an untyped type.

func (t *Type) IsUntyped() bool

IsVariadic method #

IsVariadic reports whether function type t is variadic.

func (t *Type) IsVariadic() bool

IsVoid method #

func (t *Type) IsVoid() bool

Key method #

Key returns the key type of map type t.

func (t *Type) Key() *Type

Kind method #

Kind returns the kind of type t.

func (t *Type) Kind() Kind

LinkString method #

LinkString returns a string description of t, suitable for use in link symbols. The description corresponds to type identity. That is, for any pair of types t1 and t2, Identical(t1, t2) == (t1.LinkString() == t2.LinkString()) is true. Thus it's safe to use as a map key to implement a type-identity-keyed map.

func (t *Type) LinkString() string

Linksym method #

Deprecated: This method should not be used directly. Instead, use a higher-level abstraction that directly returns the linker symbol for a named object. For example, reflectdata.TypeLinksym(t) instead of reflectdata.TypeSym(t).Linksym().

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

LinksymABI method #

Deprecated: This method should not be used directly. Instead, use a higher-level abstraction that directly returns the linker symbol for a named object. For example, (*ir.Name).LinksymABI(abi) instead of (*ir.Name).Sym().LinksymABI(abi).

func (sym *Sym) LinksymABI(abi obj.ABI) *obj.LSym

Lookup method #

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

LookupBytes method #

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

LookupNum method #

LookupNum looks up the symbol starting with prefix and ending with the decimal n. If prefix is too long, LookupNum panics.

func (pkg *Pkg) LookupNum(prefix string, n int) *Sym

LookupOK method #

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

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

MapType method #

MapType returns t's extra map-specific fields.

func (t *Type) MapType() *Map

Methods method #

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

NameString method #

NameString generates a user-readable, mostly unique string description of t. NameString always returns the same description for identical types, even across compilation units. NameString qualifies identifiers by package name, so it has collisions when different packages share the same names and identifiers. It also does not distinguish function-scope defined types from package-scoped defined types or from each other.

func (t *Type) NameString() string

NewArray function #

NewArray returns a new fixed-length array Type.

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

NewChan function #

NewChan returns a new chan Type with direction dir.

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

NewChanArgs function #

NewChanArgs returns a new TCHANARGS type for channel type c.

func NewChanArgs(c *Type) *Type

NewField function #

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

NewFuncArgs function #

NewFuncArgs returns a new TFUNCARGS type for func type f.

func NewFuncArgs(f *Type) *Type

NewInterface function #

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

NewMap function #

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

func NewMap(k *Type, v *Type) *Type

NewNamed function #

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

NewPkg function #

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 NewPkg(path string, name string) *Pkg

NewPtr function #

NewPtr returns the pointer type pointing to t.

func NewPtr(elem *Type) *Type

NewResults function #

func NewResults(types []*Type) *Type

NewSignature function #

NewSignature returns a new function type for the given receiver, parameters, and results, any of which may be nil.

func NewSignature(recv *Field, params []*Field, results []*Field) *Type

NewSlice function #

NewSlice returns the slice Type with element type elem.

func NewSlice(elem *Type) *Type

NewStruct function #

NewStruct returns a new struct with the given fields.

func NewStruct(fields []*Field) *Type

NewTuple function #

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

Noalg method #

func (t *Type) Noalg() bool

Nointerface method #

func (f *Field) Nointerface() bool

NotInHeap method #

func (t *Type) NotInHeap() bool

NumComponents method #

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

NumElem method #

func (t *Type) NumElem() int64

NumFields method #

func (t *Type) NumFields() int

NumParams method #

func (t *Type) NumParams() int

NumRecvs method #

func (t *Type) NumRecvs() int

NumResults method #

func (t *Type) NumResults() int

Obj method #

Obj returns the canonical type name node for a named type t, nil for an unnamed type.

func (t *Type) Obj() Object

OffsetOf method #

OffsetOf reports the offset of the field of a struct. The field is looked up by name.

func (t *Type) OffsetOf(name string) int64

OnExportList method #

func (sym *Sym) OnExportList() bool

Param method #

Param returns the i'th parameter of signature type t.

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

Params method #

Params returns a slice of regular parameters of signature type t.

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

ParamsResults method #

ParamsResults returns a slice containing the signature's (normal) parameters followed by its results.

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

ParseLangFlag function #

ParseLangFlag verifies that the -lang flag holds a valid value, and exits if not. It initializes data used by AllowsGoVersion.

func ParseLangFlag()

PkgMap function #

func PkgMap() map[string]*Pkg

Pos method #

Pos returns a position associated with t, if any. This should only be used for diagnostics.

func (t *Type) Pos() src.XPos

PtrDataSize function #

PtrDataSize returns the length in bytes of the prefix of t containing pointer data. Anything after this offset is scalar data. PtrDataSize is only defined for actual Go types. It's an error to use it on compiler-internal types (e.g., TSSA, TRESULTS).

func PtrDataSize(t *Type) int64

PtrTo method #

func (t *Type) PtrTo() *Type

ReceiverBaseType function #

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

Recur method #

func (t *Type) Recur() bool

Recv method #

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

func (t *Type) Recv() *Field

RecvParams method #

RecvParams returns a slice containing the signature's receiver (if any) followed by its (normal) parameters.

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

RecvParamsResults method #

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

Recvs method #

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

ReflectSymName function #

ReflectSymName returns the name of s if it's in package "reflect"; otherwise it returns "".

func ReflectSymName(s *Sym) string

Registers method #

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)

Result method #

Result returns the i'th result of signature type t.

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

Results method #

Results returns a slice of result parameters of signature type t.

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

ResultsTuple method #

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

ResumeCheckSize function #

func ResumeCheckSize()

RoundUp function #

RoundUp rounds o to a multiple of r, r is a power of 2.

func RoundUp(o int64, r int64) int64

RuntimeSymName function #

RuntimeSymName returns the name of s if it's in package "runtime"; otherwise it returns "".

func RuntimeSymName(s *Sym) string

Selector method #

Selector looks up a selector identifier.

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

Set method #

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

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

SetAllMethods method #

SetAllMethods sets the set of all methods for type t (i.e., including promoted methods from embedded types).

func (t *Type) SetAllMethods(fs []*Field)

SetAsm method #

func (sym *Sym) SetAsm(b bool)

SetDeferwidth method #

func (t *Type) SetDeferwidth(b bool)

SetFunc method #

func (sym *Sym) SetFunc(b bool)

SetHasShape method #

func (t *Type) SetHasShape(b bool)

SetInterface method #

SetInterface sets the base methods of an interface type t.

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

SetIsDDD method #

func (f *Field) SetIsDDD(b bool)

SetIsFullyInstantiated method #

func (t *Type) SetIsFullyInstantiated(b bool)

SetIsShape method #

Should always do SetHasShape(true) when doing SetIsShape(true).

func (t *Type) SetIsShape(b bool)

SetMethods method #

SetMethods sets the direct method set for type t (i.e., *not* including promoted methods from embedded types).

func (t *Type) SetMethods(fs []*Field)

SetNoalg method #

func (t *Type) SetNoalg(b bool)

SetNointerface method #

func (f *Field) SetNointerface(b bool)

SetNotInHeap method #

func (t *Type) SetNotInHeap(b bool)

SetOnExportList method #

func (sym *Sym) SetOnExportList(b bool)

SetRecur method #

func (t *Type) SetRecur(b bool)

SetSiggen method #

func (sym *Sym) SetSiggen(b bool)

SetUnderlying method #

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)

SetUniq method #

func (sym *Sym) SetUniq(b bool)

Siggen method #

func (sym *Sym) Siggen() bool

SimpleString method #

func (t *Type) SimpleString() string

Size method #

func (t *Type) Size() int64

Slice method #

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

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

SoleComponent method #

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

SplitVargenSuffix function #

SplitVargenSuffix returns name split into a base string and a ·N suffix, if any.

func SplitVargenSuffix(name string) (base string, suffix string)

String method #

func (s *Sym) String() string

String method #

func (i AlgKind) String() string

String method #

func (i Kind) String() string

String method #

String returns the Go syntax for the type t.

func (t *Type) String() string

StructType method #

StructType returns t's extra struct-specific fields.

func (t *Type) StructType() *Struct

SubstAny function #

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

Sym method #

Sym returns the name of type t.

func (t *Type) Sym() *Sym

ToUnsigned method #

ToUnsigned returns the unsigned equivalent of integer type t.

func (t *Type) ToUnsigned() *Type

TypeHasNoAlg function #

TypeHasNoAlg reports whether t does not have any associated hash/eq algorithms because t, or some component of t, is marked Noalg.

func TypeHasNoAlg(t *Type) bool

TypeHash function #

TypeHash computes a hash value for type t to use in type switch statements.

func TypeHash(t *Type) uint32

TypeSym function #

func TypeSym(t *Type) *Sym

TypeSymLookup function #

func TypeSymLookup(name string) *Sym

TypeSymName function #

func TypeSymName(t *Type) string

Underlying method #

Underlying returns the underlying type of type t.

func (t *Type) Underlying() *Type

Uniq method #

func (sym *Sym) Uniq() bool

_ function #

func _()

_ function #

func _()

calcStructOffset function #

calcStructOffset computes the offsets of a sequence of fields, starting at the given offset. It returns the resulting offset and maximum field alignment.

func calcStructOffset(t *Type, fields []*Field, offset int64) int64

chanType method #

chanType returns t's extra channel-specific fields.

func (t *Type) chanType() *Chan

cmp method #

cmp compares two *Types t and x, returning CMPlt, CMPeq, CMPgt as tx, 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

cmpForNe function #

func cmpForNe(x bool) Cmp

cmpsym method #

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

copy method #

copy returns a shallow copy of the Type.

func (t *Type) copy() *Type

currentLang function #

currentLang returns the current language version.

func currentLang() string

expandiface function #

expandiface computes the method set for interface type t by expanding embedded interfaces.

func expandiface(t *Type)

fields method #

fields returns the fields of struct type t.

func (t *Type) fields() *fields

fieldsHasShape function #

func fieldsHasShape(fields []*Field) bool

fldconv function #

func fldconv(b *bytes.Buffer, f *Field, verb rune, mode fmtMode, visited map[*Type]int, isParam bool)

formatParams function #

func formatParams(b *bytes.Buffer, params []*Field, mode fmtMode, visited map[*Type]int)

forwardType method #

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

func (t *Type) forwardType() *Forward

funcType method #

funcType returns t's extra func-specific fields.

func (t *Type) funcType() *Func

identical function #

func identical(t1 *Type, t2 *Type, flags int, assumedEqual map[typePair]struct{...}) bool

init function #

func init()

isAtomicStdPkg function #

func isAtomicStdPkg(p *Pkg) bool

makeComparableInterface function #

makeComparableInterface makes the predefined "comparable" interface in the built-in package. It has a unique name, but no methods.

func makeComparableInterface() *Type

makeErrorInterface function #

func makeErrorInterface() *Type

newBasic function #

newBasic returns a new basic type of the given kind.

func newBasic(kind Kind, obj Object) *Type

newResults function #

func newResults(types []*Type) *Type

newSSA function #

func newSSA(name string) *Type

newType function #

newType returns a new Type of the specified kind.

func newType(et Kind) *Type

params method #

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

paramsResults method #

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

parseLang function #

parseLang parses a -lang option into a langVer.

func parseLang(s string) (lang, error)

pkgqual function #

pkgqual returns the qualifier that should be used for printing symbols from the given package in the given mode. If it returns the empty string, no qualification is needed.

func pkgqual(pkg *Pkg, verb rune, mode fmtMode) string

recvParams method #

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

recvs method #

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

results method #

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

sconv function #

See #16897 for details about performance implications before changing the implementation of sconv.

func sconv(s *Sym, verb rune, mode fmtMode) string

sconv2 function #

func sconv2(b *bytes.Buffer, s *Sym, verb rune, mode fmtMode)

set method #

func (f *bitset8) set(mask uint8, b bool)

setAlg method #

setAlg sets the algorithm type of t to a, if it is of higher priority to the current algorithm type.

func (t *Type) setAlg(a AlgKind)

setFields method #

setFields sets struct type t's fields to fields.

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

substFields function #

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

symfmt function #

func symfmt(b *bytes.Buffer, s *Sym, verb rune, mode fmtMode)

tconv function #

func tconv(t *Type, verb rune, mode fmtMode) string

tconv2 function #

tconv2 writes a string representation of t to b. flag and mode control exactly what is printed. Any types x that are already in the visited map get printed as @%d where %d=visited[x]. See #16897 before changing the implementation of tconv.

func tconv2(b *bytes.Buffer, t *Type, verb rune, mode fmtMode, visited map[*Type]int)

typePos function #

typePos returns the position associated with t. This is where t was declared or where it appeared as a type expression.

func typePos(t *Type) src.XPos

wantEtype method #

func (t *Type) wantEtype(et Kind)

widthCalculated method #

func (t *Type) widthCalculated() bool

Generated with Arrow