xtypes

package
v0.0.0-...-9dcd13a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2017 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TypBool = types.Typ[types.Bool]

	TypUint   = types.Typ[types.Uint]
	TypUint8  = types.Typ[types.Uint]
	TypUint16 = types.Typ[types.Uint]
	TypUint32 = types.Typ[types.Uint]
	TypUint64 = types.Typ[types.Uint]

	TypInt   = types.Typ[types.Int]
	TypInt8  = types.Typ[types.Int8]
	TypInt16 = types.Typ[types.Int16]
	TypInt32 = types.Typ[types.Int32]
	TypInt64 = types.Typ[types.Int64]

	TypFloat32 = types.Typ[types.Float32]
	TypFloat64 = types.Typ[types.Float64]

	TypString = types.Typ[types.String]
	TypVoid   = types.Typ[types.Invalid]
)

Convenient common types accessors.

View Source
var EmptyTuple = types.NewTuple()

Functions

func AsNamedType

func AsNamedType(typ types.Type) *types.Named

AsNamedType tries to convert given type to "types.Named". Returns nil if not possible. Can perform single pointer dereference if needed.

func Deref

func Deref(typ types.Type) types.Type

Deref performs single pointer dereference. Returns pointer element type. Panics if given type is not a pointer.

func IsArray

func IsArray(typ types.Type) bool

IsArray returns true when given argument underlying type is *types.Array.

func IsGlobal

func IsGlobal(obj types.Object) bool

IsGlobal checks if given object belongs to a global scope.

func IsStruct

func IsStruct(typ types.Type) bool

IsStruct returns true when given argument underlying type is *types.Struct.

func LookupField

func LookupField(name string, typ *types.Struct) int

LookupField find struct field position (index). Returns -1 on lookup failure.

func LookupIfaceMethod

func LookupIfaceMethod(name string, typ *types.Interface) int

LookupIfaceMethod find interface method position (index). Returns -1 on lookup failure.

func MaybeDeref

func MaybeDeref(typ types.Type) types.Type

MaybeDeref is like Deref, but returns passed argument on failure.

Useful for types that are accessed in auto dereferencing manner which is limited to 1 level of indirection.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL