Documentation ¶
Index ¶
- Constants
- func IsExported(name string) bool
- type ArrayType
- type ChanDir
- type ChanType
- type FuncType
- type Imethod
- type InterfaceType
- type Kind
- type MapType
- type Method
- type PtrType
- type SliceType
- type StructField
- type StructType
- type TFlag
- type Text
- type Type
- func (t *Type) Align() int
- func (t *Type) ArrayType() *ArrayType
- func (t *Type) Common() *Type
- func (t *Type) Elem() *Type
- func (t *Type) FieldAlign() int
- func (t *Type) FuncType() *FuncType
- func (t *Type) HasName() bool
- func (t *Type) IfaceIndir() bool
- func (t *Type) InterfaceType() *InterfaceType
- func (t *Type) IsDirectIface() bool
- func (t *Type) Kind() Kind
- func (t *Type) Len() int
- func (t *Type) MapType() *MapType
- func (t *Type) Pointers() bool
- func (t *Type) Size() uintptr
- func (t *Type) String() string
- func (t *Type) StructType() *StructType
- func (t *Type) Uncommon() *UncommonType
- type UncommonType
Constants ¶
const ( MapBucketCountBits = 3 // log2 of number of elements in a bucket. MapBucketCount = 1 << MapBucketCountBits MapMaxKeyBytes = 128 // Must fit in a uint8. MapMaxElemBytes = 128 // Must fit in a uint8. )
Map constants common to several packages runtime/runtime-gdb.py:MapTypePrinter contains its own copy
const ( // TODO (khr, drchase) why aren't these in TFlag? Investigate, fix if possible. KindDirectIface = 1 << 5 KindGCProg = 1 << 6 // Type.gc points to GC program KindMask = (1 << 5) - 1 )
Variables ¶
This section is empty.
Functions ¶
func IsExported ¶ added in v0.8.5
IsExported reports whether name starts with an upper-case letter.
Types ¶
type ArrayType ¶
type ArrayType struct { Type Elem *Type // array element type Slice *Type // slice type Len uintptr }
ArrayType represents a fixed array type.
type Imethod ¶
Imethod represents a method on an interface type
type InterfaceType ¶
type Kind ¶
type Kind uint
A Kind represents the specific kind of type that a Type represents. The zero Kind is not a valid kind.
type MapType ¶
type MapType struct { Type Key *Type Elem *Type Bucket *Type // internal type representing a hash bucket // function for hashing keys (ptr to key, seed) -> hash Hasher func(unsafe.Pointer, uintptr) uintptr KeySize uint8 // size of key slot ValueSize uint8 // size of elem slot BucketSize uint16 // size of bucket Flags uint32 }
func (*MapType) HashMightPanic ¶ added in v0.8.8
func (*MapType) IndirectElem ¶ added in v0.8.8
func (*MapType) IndirectKey ¶ added in v0.8.8
Note: flag values must match those used in the TMAP case in ../cmd/compile/internal/reflectdata/reflect.go:writeType.
func (*MapType) NeedKeyUpdate ¶ added in v0.8.8
func (*MapType) ReflexiveKey ¶ added in v0.8.8
type Method ¶ added in v0.8.5
type Method struct { Name_ string // name of method Mtyp_ *FuncType // method type (without receiver) Ifn_ Text // fn used in interface call (one-word receiver) Tfn_ Text // fn used for normal method call }
Method on non-interface type
type StructField ¶
type StructField struct { Name_ string // name is always non-empty Typ *Type // type of field Offset uintptr // byte offset of field Tag_ string Embedded_ bool }
func (*StructField) Embedded ¶ added in v0.8.5
func (f *StructField) Embedded() bool
Embedded reports whether the field is embedded.
func (*StructField) Exported ¶ added in v0.8.5
func (f *StructField) Exported() bool
Exported reports whether the field is exported.
type StructType ¶
type StructType struct { Type PkgPath_ string Fields []StructField }
type TFlag ¶
type TFlag uint8
TFlag is used by a Type to signal what extra type information is available in the memory directly following the Type value.
const ( // TFlagUncommon means that there is a data with a type, UncommonType, // just beyond the shared-per-type common data. That is, the data // for struct types will store their UncommonType at one offset, the // data for interface types will store their UncommonType at a different // offset. UncommonType is always accessed via a pointer that is computed // using trust-us-we-are-the-implementors pointer arithmetic. // // For example, if t.Kind() == Struct and t.tflag&TFlagUncommon != 0, // then t has UncommonType data and it can be accessed as: // // type structTypeUncommon struct { // structType // u UncommonType // } // u := &(*structTypeUncommon)(unsafe.Pointer(t)).u TFlagUncommon TFlag = 1 << 0 // TFlagExtraStar means the name in the str field has an // extraneous '*' prefix. This is because for most types T in // a program, the type *T also exists and reusing the str data // saves binary size. TFlagExtraStar TFlag = 1 << 1 // TFlagNamed means the type has a name. TFlagNamed TFlag = 1 << 2 // TFlagRegularMemory means that equal and hash functions can treat // this type as a single region of t.size bytes. TFlagRegularMemory TFlag = 1 << 3 // TFlagVariadic means a funcType with variadic parameters TFlagVariadic TFlag = 1 << 4 // TFlagUninited means this type is not fully initialized. TFlagUninited TFlag = 1 << 7 )
type Type ¶
type Type struct { Size_ uintptr PtrBytes uintptr // number of (prefix) bytes in the type that can contain pointers Hash uint32 // hash of type; avoids computation in hash tables TFlag TFlag // extra type information flags Align_ uint8 // alignment of variable with this type FieldAlign_ uint8 // alignment of struct field with this type Kind_ uint8 // enumeration for C // function for comparing objects of this type // (ptr to object A, ptr to object B) -> ==? Equal func(unsafe.Pointer, unsafe.Pointer) bool // GCData stores the GC type data for the garbage collector. // If the KindGCProg bit is set in kind, GCData is a GC program. // Otherwise it is a ptrmask bitmap. See mbitmap.go for details. GCData *byte Str_ string // string form PtrToThis_ *Type // type for pointer to this type, may be nil }
Type is the runtime representation of a Go type.
Type is also referenced implicitly (in the form of expressions involving constants and arch.PtrSize) in cmd/compile/internal/reflectdata/reflect.go and cmd/link/internal/ld/decodesym.go (e.g. data[2*arch.PtrSize+4] references the TFlag field) unsafe.OffsetOf(Type{}.TFlag) cannot be used directly in those places because it varies with cross compilation and experiments.
func (*Type) ArrayType ¶
ArrayType returns t cast to a *ArrayType, or nil if its tag does not match.
func (*Type) Elem ¶
Elem returns the element type for t if t is an array, channel, map, pointer, or slice, otherwise nil.
func (*Type) FieldAlign ¶ added in v0.8.5
func (*Type) IfaceIndir ¶ added in v0.8.9
IfaceIndir reports whether t is stored indirectly in an interface value.
func (*Type) InterfaceType ¶
func (t *Type) InterfaceType() *InterfaceType
InterfaceType returns t cast to a *InterfaceType, or nil if its tag does not match.
func (*Type) IsDirectIface ¶ added in v0.8.9
isDirectIface reports whether t is stored directly in an interface value.
func (*Type) StructType ¶
func (t *Type) StructType() *StructType
StructType returns t cast to a *StructType, or nil if its tag does not match.
func (*Type) Uncommon ¶ added in v0.8.5
func (t *Type) Uncommon() *UncommonType
Uncommon returns a pointer to T's "uncommon" data if there is any, otherwise nil
type UncommonType ¶ added in v0.8.5
type UncommonType struct { PkgPath_ string // import path; empty for built-in types like int, string Mcount uint16 // number of methods Xcount uint16 // number of exported methods Moff uint32 // offset from this uncommontype to [mcount]Method }
UncommonType is present only for defined types or types with methods (if T is a defined type, the uncommonTypes for T and *T have methods). Using a pointer to this struct reduces the overall size required to describe a non-defined type with no methods.
func (*UncommonType) ExportedMethods ¶ added in v0.8.5
func (t *UncommonType) ExportedMethods() []Method
func (*UncommonType) Methods ¶ added in v0.8.5
func (t *UncommonType) Methods() []Method