Documentation
¶
Index ¶
Constants ¶
const ( // TODO (khr, drchase) why aren't these in TFlag? Investigate, fix if possible. KindDirectIface Kind = 1 << 5 KindMask Kind = (1 << 5) - 1 )
Variables ¶
This section is empty.
Functions ¶
func NoEscape ¶ added in v0.0.13
NoEscape hides the pointer p from escape analysis, preventing it from escaping to the heap. It compiles down to nothing.
WARNING: This is very subtle to use correctly. The caller must ensure that it's truly safe for p to not escape to the heap by maintaining runtime pointer invariants (for example, that globals and the heap may not generally point into a stack).
Types ¶
type EmptyInterface ¶ added in v0.0.13
EmptyInterface describes the layout of a "interface{}" or a "any." These are represented differently than non-empty interface, as the first word always points to an abi.Type.
type Name ¶ added in v0.0.13
type Name struct {
Bytes *byte
}
func (Name) DataChecked ¶ added in v0.0.13
DataChecked does pointer arithmetic on n's Bytes, and that arithmetic is asserted to be safe for the reason in whySafe (which can appear in a backtrace, etc.)
func (Name) IsEmbedded ¶ added in v0.0.13
IsEmbedded returns true iff n is embedded (an anonymous field).
func (Name) IsExported ¶ added in v0.0.13
IsExported reports whether the name is exported.
func (Name) ReadVarint ¶ added in v0.0.13
ReadVarint parses a varint as encoded by encoding/binary. It returns the number of encoded bytes and the encoded value.
type NameOff ¶ added in v0.0.13
type NameOff int32
NameOff is the Offset to a Name from moduledata.types. See resolveNameOff in runtime.
type StructField ¶ added in v0.0.13
type StructField struct {
Name Name // name is always non-empty
Typ *Type // type of field
Off uintptr // offset within struct, in bytes
}
A StructField describes a single field in a struct.
func (*StructField) Embedded ¶ added in v0.0.13
func (f *StructField) Embedded() bool
func (StructField) Tag ¶ added in v0.0.13
func (f StructField) Tag() StructTag
Tag returns the field's tag as a StructTag.
type StructTag ¶ added in v0.0.13
type StructTag string
StructTag is the tag string in a struct field (similar to reflect.StructTag)
func (StructTag) Get ¶ added in v0.0.13
Get returns the value associated with key in the tag string. If there is no such key in the tag, Get returns the empty string.
func (StructTag) Lookup ¶ added in v0.0.13
Lookup returns the value associated with key in the tag string. If the key is present in the tag the value (which may be empty) is returned. Otherwise the returned value will be the empty string. The ok return value reports whether the value was explicitly set in the tag string.
type StructType ¶ added in v0.0.13
type StructType struct {
Type
PkgPath Name
Fields []StructField
}
type TFlag ¶ added in v0.0.13
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.
type Type ¶ added in v0.0.13
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_ Kind // enumeration for C
// function for comparing objects of this type
Equal func(unsafe.Pointer, unsafe.Pointer) bool
// GCData stores the GC type data for the garbage collector.
// Normally, GCData points to a bitmask that describes the
// ptr/nonptr Fields of the type. The bitmask will have at
// least PtrBytes/ptrSize bits.
// If the TFlagGCMaskOnDemand bit is set, GCData is instead a
// **byte and the pointer to the bitmask is one dereference away.
// The runtime will build the bitmask if needed.
// (See runtime/type.go:getGCMask.)
// Note: multiple types may have the same value of GCData,
// including when TFlagGCMaskOnDemand is set. The types will, of course,
// have the same pointer layout (but not necessarily the same size).
GCData *byte
Str NameOff // string form
PtrToThis TypeOff // type for pointer to this type, may be zero
}
Type is the runtime representation of a Go type.
Be careful about accessing this type at build time, as the version of this type in the compiler/linker may not have the same layout as the version in the target binary, due to pointer width differences and any experiments. Use cmd/compile/internal/rttype or the functions in compiletype.go to access this type instead. (TODO: this admonition applies to every type in this package. Put it in some shared location?)
func TypeOf ¶ added in v0.0.13
TypeOf returns the reflection Type that represents the dynamic type of i. If i is a nil interface value, TypeOf returns nil.
func (*Type) Field ¶ added in v0.0.13
func (t *Type) Field(i int) (StructField, error)
Field returns the i'th field of the struct type. It returns an error if the type is not a struct or the index is out of range.
func (*Type) IfaceIndir ¶ added in v0.0.13
IfaceIndir reports whether t is stored indirectly in an interface value.
func (*Type) NumField ¶ added in v0.0.13
NumField returns the number of fields in the struct type. It returns an error if the type is not a struct.
func (*Type) StructType ¶ added in v0.0.13
func (t *Type) StructType() *StructType
StructType returns t cast to a *StructType, or nil if its tag does not match.
type TypeOff ¶ added in v0.0.13
type TypeOff int32
TypeOff is the Offset to a type from moduledata.types. See resolveTypeOff in runtime.
type Value ¶ added in v0.0.13
type Value struct {
// contains filtered or unexported fields
}
func ValueOf ¶ added in v0.0.13
ValueOf returns a new Value initialized to the concrete value stored in the interface i. ValueOf(nil) returns the zero Value.