package gotypes
import "github.com/mmcloughlin/avo/gotypes"
Package gotypes provides helpers for interacting with Go types within avo functions.
Index ¶
- Variables
- type Basic
- type Component
- type Signature
- func LookupSignature(pkg *types.Package, name string) (*Signature, error)
- func NewSignature(pkg *types.Package, sig *types.Signature) *Signature
- func NewSignatureVoid() *Signature
- func ParseSignature(expr string) (*Signature, error)
- func ParseSignatureInPackage(pkg *types.Package, expr string) (*Signature, error)
- func (s *Signature) Bytes() int
- func (s *Signature) Params() *Tuple
- func (s *Signature) Results() *Tuple
- func (s *Signature) String() string
- type Tuple
Examples ¶
Variables ¶
var PointerSize = Sizes.Sizeof(types.Typ[types.UnsafePointer])
PointerSize is the size of a pointer on amd64.
Sizes provides type sizes used by the standard Go compiler on amd64.
Types ¶
type Basic ¶
Basic represents a primitive/basic type at a given memory address.
type Component ¶
type Component interface { // When the component has no further sub-components, Resolve will return a // reference to the components type and memory address. If there was an error // during any previous calls to Component methods, they will be returned at // resolution time. Resolve() (*Basic, error) Dereference(r reg.Register) Component // dereference a pointer Base() Component // base pointer of a string or slice Len() Component // length of a string or slice Cap() Component // capacity of a slice Real() Component // real part of a complex value Imag() Component // imaginary part of a complex value Index(int) Component // index into an array Field(string) Component // access a struct field }
Component provides access to sub-components of a Go type.
func NewComponent ¶
NewComponent builds a component for the named type at the given address.
type Signature ¶
type Signature struct {
// contains filtered or unexported fields
}
Signature represents a Go function signature.
func LookupSignature ¶
LookupSignature returns the signature of the named function in the provided package.
func NewSignature ¶
NewSignature constructs a Signature.
func NewSignatureVoid ¶
func NewSignatureVoid() *Signature
NewSignatureVoid builds the void signature "func()".
func ParseSignature ¶
ParseSignature builds a Signature by parsing a Go function type expression. The function type must reference builtin types only; see ParseSignatureInPackage if custom types are required.
func ParseSignatureInPackage ¶
ParseSignatureInPackage builds a Signature by parsing a Go function type expression. The expression may reference types in the provided package.
func (*Signature) Bytes ¶
Bytes returns the total size of the function arguments and return values.
func (*Signature) Params ¶
Params returns the function signature argument types.
func (*Signature) Results ¶
Results returns the function return types.
func (*Signature) String ¶
String writes Signature as a string. This does not include the "func" keyword.
type Tuple ¶
type Tuple struct {
// contains filtered or unexported fields
}
Tuple represents a tuple of variables, such as function arguments or results.
func (*Tuple) At ¶
At returns the variable at index i.
func (*Tuple) Bytes ¶
Bytes returns the size of the Tuple. This may include additional padding.
func (*Tuple) Lookup ¶
Lookup returns the variable with the given name.
Source Files ¶
components.go doc.go signature.go
- Version
- v0.6.0 (latest)
- Published
- Jan 7, 2024
- Platform
- js/wasm
- Imports
- 8 packages
- Last checked
- 3 weeks ago –
Tools for package owners.