Documentation
¶
Index ¶
- Constants
- Variables
- func Check(fset *token.FileSet, pkg *ast.Package) (types map[ast.Expr]Type, err error)
- func ExportData(filename string) (rc io.ReadCloser, err error)
- func GcImporter(imports map[string]*ast.Object, path string) (pkg *ast.Object, err error)
- func Identical(x, y Type) bool
- type Array
- type Bad
- type Basic
- type BasicTypeKind
- type Chan
- type Const
- type Func
- type ImplementsType
- type Interface
- type Map
- type Name
- type ObjList
- type Pointer
- type Slice
- type Struct
- type Type
Constants ¶
const ( BoolKind = BasicTypeKind(reflect.Bool) IntKind = BasicTypeKind(reflect.Int) Int8Kind = BasicTypeKind(reflect.Int8) Int16Kind = BasicTypeKind(reflect.Int16) Int32Kind = BasicTypeKind(reflect.Int32) Int64Kind = BasicTypeKind(reflect.Int64) UintKind = BasicTypeKind(reflect.Uint) Uint8Kind = BasicTypeKind(reflect.Uint8) Uint16Kind = BasicTypeKind(reflect.Uint16) Uint32Kind = BasicTypeKind(reflect.Uint32) Uint64Kind = BasicTypeKind(reflect.Uint64) UintptrKind = BasicTypeKind(reflect.Uintptr) Float32Kind = BasicTypeKind(reflect.Float32) Float64Kind = BasicTypeKind(reflect.Float64) Complex64Kind = BasicTypeKind(reflect.Complex64) Complex128Kind = BasicTypeKind(reflect.Complex128) StringKind = BasicTypeKind(reflect.String) UnsafePointerKind = BasicTypeKind(reflect.UnsafePointer) )
Constants for basic types.
Variables ¶
Functions ¶
func Check ¶
Check typechecks a package. It augments the AST by assigning types to all ast.Objects and returns a map of types for all expression nodes in statements, and a scanner.ErrorList if there are errors.
func ExportData ¶
func ExportData(filename string) (rc io.ReadCloser, err error)
ExportData returns a readCloser positioned at the beginning of the export data section of the given object/archive file, or an error. It is the caller's responsibility to close the readCloser.
func GcImporter ¶
GcImporter implements the ast.Importer signature.
Types ¶
type Array ¶
type Array struct {
ImplementsType
Len uint64
Elt Type
}
An Array represents an array type [Len]Elt.
type Bad ¶
type Bad struct {
ImplementsType
Msg string // for better error reporting/debugging
}
A Bad type is a non-nil placeholder type when we don't know a type.
type Basic ¶
type Basic struct {
ImplementsType
Kind BasicTypeKind
}
A Basic represents a (unnamed) basic type.
type BasicTypeKind ¶
func (BasicTypeKind) String ¶
func (k BasicTypeKind) String() string
type Chan ¶
type Chan struct {
ImplementsType
Dir ast.ChanDir
Elt Type
}
A Chan represents a channel type chan Elt, <-chan Elt, or chan<-Elt.
type Const ¶
type Const struct {
// representation of constant values:
// ideal bool -> bool
// ideal int -> *big.Int
// ideal float -> *big.Rat
// ideal complex -> cmplx
// ideal string -> string
Val interface{}
}
A Const implements an ideal constant Value. The zero value z for a Const is not a valid constant value.
func MakeConst ¶
MakeConst makes an ideal constant from a literal token and the corresponding literal string.
func (*Const) Convert ¶
Convert attempts to convert the constant x to a given type. If the attempt is successful, the result is the new constant; otherwise the result is invalid.
type Func ¶
type Func struct {
ImplementsType
Recv *ast.Object // nil if not a method
Params ObjList // (incoming) parameters from left to right; or nil
Results ObjList // (outgoing) results from left to right; or nil
IsVariadic bool // true if the last parameter's type is of the form ...T
}
A Func represents a function type func(...) (...). Unnamed parameters are represented by objects with empty names.
type ImplementsType ¶
type ImplementsType struct{}
All concrete types embed ImplementsType which ensures that all types implement the Type interface.
type Interface ¶
type Interface struct {
ImplementsType
Methods ObjList // interface methods sorted by name; or nil
}
An Interface represents an interface type interface{...}.
type Map ¶
type Map struct {
ImplementsType
Key, Elt Type
}
A Map represents a map type map[Key]Elt.
type Name ¶
type Name struct {
ImplementsType
Underlying Type // nil if not fully declared
Obj *ast.Object // corresponding declared object
Methods ObjList
}
A Name represents a named type as declared in a type declaration.
var ( Uint, Uint8, Uint16, Uint32, Uint64, Int, Int8, Int16, Int32, Int64, Float32, Float64, Complex64, Complex128, Byte, Bool, Uintptr, Rune, UnsafePointer, String *Name )
type Pointer ¶
type Pointer struct {
ImplementsType
Base Type
}
A Pointer represents a pointer type *Base.
type Struct ¶
type Struct struct {
ImplementsType
Fields ObjList // struct fields; or nil
Tags []string // corresponding tags; or nil
FieldIndices map[string]uint64 // fast field lookup (name -> index)
}
A Struct represents a struct type struct{...}. Anonymous fields are represented by objects with empty names.