types

package
v0.0.0-...-e758773 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2011 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

PACKAGE UNDER CONSTRUCTION. ANY AND ALL PARTS MAY CHANGE. Package types declares the types used to represent Go types.

Index

Constants

This section is empty.

Variables

View Source
var (
	Universe *ast.Scope
	Unsafe   *ast.Object // package unsafe
)

Functions

func Check

func Check(fset *token.FileSet, pkg *ast.Package) (types map[ast.Expr]Type, err os.Error)

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 os.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

func GcImporter(imports map[string]*ast.Object, path string) (pkg *ast.Object, err os.Error)

GcImporter implements the ast.Importer signature.

func Identical

func Identical(x, y Type) bool

Identical returns true if two types are identical.

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
}

A Basic represents a (unnamed) basic 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

func MakeConst(tok token.Token, lit string) Const

MakeConst makes an ideal constant from a literal token and the corresponding literal string.

func MakeZero

func MakeZero(typ *Type) Const

MakeZero returns the zero constant for the given type.

func (Const) BinaryOp

func (x Const) BinaryOp(op token.Token, y Const) Const

func (Const) Convert

func (x Const) Convert(typ *Type) Const

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.

func (Const) Match

func (x Const) Match(y Const) (u, v Const)

Match attempts to match the internal constant representations of x and y. If the attempt is successful, the result is the values of x and y, if necessary converted to have the same internal representation; otherwise the results are invalid.

func (Const) String

func (x Const) String() string

func (Const) UnaryOp

func (x Const) UnaryOp(op token.Token) Const

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 ObjList

type ObjList []*ast.Object

An ObjList represents an ordered (in some fashion) list of objects.

func (ObjList) Len

func (list ObjList) Len() int

ObjList implements sort.Interface.

func (ObjList) Less

func (list ObjList) Less(i, j int) bool

func (ObjList) Sort

func (list ObjList) Sort()

Sort sorts an object list by object name.

func (ObjList) Swap

func (list ObjList) Swap(i, j int)

type Pointer

type Pointer struct {
	ImplementsType
	Base Type
}

A Pointer represents a pointer type *Base.

type Slice

type Slice struct {
	ImplementsType
	Elt Type
}

A Slice represents a slice type []Elt.

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.

type Type

type Type interface {
	// contains filtered or unexported methods
}

All types implement the Type interface.

func Deref

func Deref(typ Type) Type

If typ is a pointer type, Deref returns the pointer's base type; otherwise it returns typ.

func Underlying

func Underlying(typ Type) Type

Underlying returns the underlying type of a type.

Jump to

Keyboard shortcuts

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