Documentation
¶
Index ¶
- Constants
- func NoEscape(p unsafe.Pointer) unsafe.Pointer
- type EmptyInterface
- type Name
- type NameOff
- type PtrType
- type StructField
- type StructTag
- type StructType
- type TFlag
- type Type
- func (t *Type) Field(i int) (StructField, error)
- func (t *Type) IfaceIndir() bool
- func (t *Type) Kind() Kind
- func (t *Type) Name() string
- func (t *Type) NameByIndex(i int) (string, error)
- func (t *Type) NumField() (int, error)
- func (t *Type) String() string
- func (t *Type) StructID() uint32
- func (t *Type) StructType() *StructType
- type TypeOff
- type Value
Constants ¶
const ( KindDirectIface Kind = 1 << 5 KindMask Kind = (1 << 5) - 1 )
Essential constants for type operations
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."
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)
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
}
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) Name ¶ added in v0.0.16
Name returns the type's name within its package for a defined type. For TinyGo compatibility, struct names are resolved using the StructDictionary
func (*Type) NameByIndex ¶ added in v0.0.19
Name returns the name of a struct type's i'th field. It panics if the type's Kind is not Struct. It panics if i is out of range.
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) StructID ¶ added in v0.0.16
StructID returns a unique identifier for struct types based on runtime hash Returns 0 for non-struct types
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.
func (Value) Elem ¶ added in v0.0.17
Elem returns the value that the pointer v points to. It panics if v's Kind is not Ptr. It returns the zero Value if v is a nil pointer.
func (Value) Field ¶ added in v0.0.13
Field returns the i'th field of the struct v. Returns an error if v is not a struct or i is out of range.
func (Value) Interface ¶ added in v0.0.19
Interface returns v's current value as an interface{}. It is equivalent to:
var i interface{} = (v's underlying value)
For a Value created from a nil interface value, Interface returns nil.