Documentation
¶
Index ¶
- Variables
- func RegisterTypesGob()
- func RegisterTypesStablegob()
- func TypeString(typ Type, qf Qualifier) string
- func WriteSignature(buf *bytes.Buffer, sig *Signature, qf Qualifier)
- func WriteType(buf *bytes.Buffer, typ Type, qf Qualifier)
- type Array
- type Basic
- type BasicInfo
- type BasicKind
- type Builtin
- type BuiltinId
- type Chan
- type ChanDir
- type Const
- type ConstKind
- type Func
- type Identifier
- type Interface
- func (t Interface) Embedded(i int) Type
- func (t Interface) Empty() bool
- func (t Interface) ExplicitMethod(i int) *Func
- func (t Interface) Method(i int) *Func
- func (t Interface) NumEmbeddeds() int
- func (t Interface) NumExplicitMethods() int
- func (t Interface) NumMethods() int
- func (t *Interface) String() string
- func (t *Interface) Underlying() Type
- type Label
- type Map
- type Named
- type Nil
- type Obj
- type Object
- type PkgName
- type Pointer
- type Qualifier
- type Reference
- type Signature
- type Slice
- type Struct
- type Tuple
- type Type
- type TypeName
- type Var
Constants ¶
This section is empty.
Variables ¶
var BuiltinNames = map[string]BuiltinId{ "append": Append, "cap": Cap, "close": Close, "complex": Complex, "copy": Copy, "delete": Delete, "imag": Imag, "len": Len, "make": Make, "new": New, "panic": Panic, "print": Print, "println": Println, "real": Real, "recover": Recover, "Alignof": Alignof, "Offsetof": Offsetof, "Sizeof": Sizeof, "assert": Assert, "trace": Trace, }
var EmptyInterface = Interface{AllMethods: MarkComplete}
EmptyInterface represents the empty (completed) interface
var MarkComplete = make([]*Func, 0)
MarkComplete is used to mark an empty interface as completely set up by setting the allMethods field to a non-nil empty slice.
var Typ = []*Basic{ Invalid: {Invalid, 0, "invalid type"}, Bool: {Bool, IsBoolean, "bool"}, Int: {Int, IsInteger, "int"}, Int8: {Int8, IsInteger, "int8"}, Int16: {Int16, IsInteger, "int16"}, Int32: {Int32, IsInteger, "int32"}, Int64: {Int64, IsInteger, "int64"}, Uint: {Uint, IsInteger | IsUnsigned, "uint"}, Uint8: {Uint8, IsInteger | IsUnsigned, "uint8"}, Uint16: {Uint16, IsInteger | IsUnsigned, "uint16"}, Uint32: {Uint32, IsInteger | IsUnsigned, "uint32"}, Uint64: {Uint64, IsInteger | IsUnsigned, "uint64"}, Uintptr: {Uintptr, IsInteger | IsUnsigned, "uintptr"}, Float32: {Float32, IsFloat, "float32"}, Float64: {Float64, IsFloat, "float64"}, Complex64: {Complex64, IsComplex, "complex64"}, Complex128: {Complex128, IsComplex, "complex128"}, String: {String, IsString, "string"}, UnsafePointer: {UnsafePointer, 0, "Pointer"}, UntypedBool: {UntypedBool, IsBoolean | IsUntyped, "untyped bool"}, UntypedInt: {UntypedInt, IsInteger | IsUntyped, "untyped int"}, UntypedRune: {UntypedRune, IsInteger | IsUntyped, "untyped rune"}, UntypedFloat: {UntypedFloat, IsFloat | IsUntyped, "untyped float"}, UntypedComplex: {UntypedComplex, IsComplex | IsUntyped, "untyped complex"}, UntypedString: {UntypedString, IsString | IsUntyped, "untyped string"}, UntypedNil: {UntypedNil, IsUntyped, "untyped nil"}, }
Functions ¶
func RegisterTypesGob ¶
func RegisterTypesGob()
func RegisterTypesStablegob ¶
func RegisterTypesStablegob()
func TypeString ¶
TypeString returns the string representation of typ. The Qualifier controls the printing of package-level objects, and may be nil.
func WriteSignature ¶
WriteSignature writes the representation of the signature sig to buf, without a leading "func" keyword. The Qualifier controls the printing of package-level objects, and may be nil.
Types ¶
type Array ¶
type Array struct { Len int64 // Len returns the length of array a. Elem Type // Elem returns element type of array a. }
An Array represents an array type.
func (*Array) Underlying ¶
type Basic ¶
type Basic struct { Kind BasicKind // Kind returns the kind of basic type b. Info BasicInfo // Info returns information about properties of basic type b. Name string // Name returns the name of basic type b. }
A Basic represents a basic type.
func (*Basic) Underlying ¶
type BasicInfo ¶
type BasicInfo int
BasicInfo is a set of flags describing properties of a basic type.
type BasicKind ¶
type BasicKind int
BasicKind describes the kind of basic type.
const ( Invalid BasicKind = iota // type is invalid // predeclared types Bool Int Int8 Int16 Int32 Int64 Uint Uint8 Uint16 Uint32 Uint64 Uintptr Float32 Float64 Complex64 Complex128 String UnsafePointer // types for untyped values UntypedBool UntypedInt UntypedRune UntypedFloat UntypedComplex UntypedString UntypedNil // aliases Byte = Uint8 Rune = Int32 )
type Chan ¶
type Chan struct { Dir ChanDir // Dir returns the direction of channel c. Elem Type // Elem returns the element type of channel c. }
A Chan represents a channel type.
func (*Chan) Underlying ¶
type Func ¶
type Func struct {
Obj
}
A Func represents a declared function, concrete method, or abstract (interface) method. Its Type() is always a Signature. An abstract method may belong to many interfaces due to embedding.
type Identifier ¶
func (Identifier) Exported ¶
func (i Identifier) Exported() bool
func (Identifier) String ¶
func (i Identifier) String() string
String returns name if it is exported, otherwise it returns the name qualified with the package path.
type Interface ¶
type Interface struct { Methods []*Func // ordered list of explicitly declared methods Embeddeds []*Reference // ordered list of explicitly embedded types AllMethods []*Func // ordered list of methods declared with or embedded in this interface (TODO(gri): replace with mset) }
An Interface represents an interface type.
func (Interface) Embedded ¶
Embedded returns the i'th embedded type of interface t for 0 <= i < t.NumEmbeddeds(). The types are ordered by the corresponding TypeName's unique Id.
func (Interface) ExplicitMethod ¶
ExplicitMethod returns the i'th explicitly declared method of interface t for 0 <= i < t.NumExplicitMethods(). The methods are ordered by their unique Id.
func (Interface) Method ¶
Method returns the i'th method of interface t for 0 <= i < t.NumMethods(). The methods are ordered by their unique Id.
func (Interface) NumEmbeddeds ¶
NumEmbeddeds returns the number of embedded types in interface t.
func (Interface) NumExplicitMethods ¶
NumExplicitMethods returns the number of explicitly declared methods of interface t.
func (Interface) NumMethods ¶
NumMethods returns the total number of methods of interface t.
func (*Interface) Underlying ¶
type Label ¶
type Label struct {
Obj
}
A Label represents a declared label. Labels don't have a type.
type Map ¶
type Map struct { Key Type // Key returns the key type of map m. Elem Type // Elem returns the element type of map m. }
A Map represents a map type.
func (*Map) Underlying ¶
type Named ¶
type Named struct { Type Type // possibly a Named during setup; never a Named once set up completely Methods []*Func // methods declared for this type (not the method set of this type) }
A Named represents a named type.
func (Named) NumMethods ¶
NumMethods returns the number of explicit methods whose receiver is named type t.
func (*Named) Underlying ¶
type Obj ¶
type Obj struct { Identifier Type Type }
An object implements the common parts of an Object.
func (Obj) Id ¶
func (obj Obj) Id() Identifier
type PkgName ¶
type PkgName struct { Obj Imported string // Imported returns the package that was imported. It is distinct from Pkg(), which is the package containing the import statement. }
A PkgName represents an imported Go package. PkgNames don't have a type.
type Pointer ¶
type Pointer struct {
Elem Type // Elem returns the element type for the given pointer p.
}
A Pointer represents a pointer type.
func (*Pointer) Underlying ¶
type Qualifier ¶
A Qualifier controls how named package-level objects are printed in calls to TypeString, ObjectString, and SelectionString.
These three formatting routines call the Qualifier for each package-level object O, and if the Qualifier returns a non-empty string p, the object is printed in the form p.O. If it returns an empty string, only the object name O is printed.
Using a nil Qualifier is equivalent to using (*Package).Path: the object is qualified by the import path, e.g., "encoding/json.Marshal".
func RelativeTo ¶
RelativeTo(pkg) returns a Qualifier that fully qualifies members of all packages other than pkg.
type Signature ¶
type Signature struct { // Recv returns the receiver of signature s (if a method), or nil if a // function. It is ignored when comparing signatures for identity. // // For an abstract method, Recv returns the enclosing interface either // as a *Named or an *Interface. Due to embedding, an interface may // contain methods whose receiver type is a different interface. Recv *Var Params *Tuple // Params returns the parameters of signature s, or nil. Results *Tuple // Results returns the results of signature s, or nil. Variadic bool // Variadic reports whether the signature s is variadic. }
A Signature represents a (non-builtin) function or method type. The receiver is ignored when comparing signatures for identity.
func (*Signature) Underlying ¶
type Slice ¶
type Slice struct {
Elem Type // Elem returns the element type of slice s.
}
A Slice represents a slice type.
func (*Slice) Underlying ¶
type Struct ¶
A Struct represents a struct type.
func (Struct) NumFields ¶
NumFields returns the number of fields in the struct (including blank and anonymous fields).
func (*Struct) Underlying ¶
type Tuple ¶
type Tuple struct {
Vars []*Var
}
A Tuple represents an ordered list of variables; a nil *Tuple is a valid (empty) tuple. Tuples are used as components of signatures and to represent the type of multiple assignments; they are not first class types of Go.
func (*Tuple) Underlying ¶
type Type ¶
type Type interface { // Underlying returns the underlying type of a type. Underlying() Type // String returns a string representation of a type. String() string }
A Type represents a type of Go. All types implement the Type interface.
type TypeName ¶
type TypeName struct {
Obj
}
A TypeName represents a name for a (named or alias) type.
type Var ¶
type Var struct { Obj Anonymous bool // Anonymous reports whether the variable is an anonymous field. If set, the variable is an anonymous struct field, and name is the type name IsField bool // IsField reports whether the variable is a struct field. }
A Variable represents a declared variable (including function parameters and results, and struct fields).