Documentation
¶
Overview ¶
Package types declares the types used to represent Go types (UNDER CONSTRUCTION). ANY AND ALL PARTS MAY CHANGE.
Index ¶
- 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 Chan
- type Const
- type Func
- type ImplementsType
- type Interface
- type Map
- type Name
- type ObjList
- type Pointer
- type Slice
- type Struct
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( Universe *ast.Scope Unsafe *ast.Object // package unsafe )
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 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 {
// contains filtered or unexported fields
}
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
}
A Name represents a named type as declared in a type declaration.
var ( Bool, Int, Float64, Complex128, 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
}
A Struct represents a struct type struct{...}. Anonymous fields are represented by objects with empty names.