types

package
v0.0.0-...-2cdba53 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyType vm.Type = NewMultiType([]vm.Type{})

Functions

This section is empty.

Types

type ArrayType

type ArrayType struct {
	Len  int64   // The length of the array
	Elem vm.Type // The type of the array elements
	// contains filtered or unexported fields
}

ArrayType is used to represent array types (https://golang.ir/ref/spec#Array_types).

func NewArrayType

func NewArrayType(len int64, elem vm.Type) *ArrayType

NewArrayType creates a new array type with the specified length and element type.

func (*ArrayType) Compat

func (t *ArrayType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*ArrayType) IsBoolean

func (t *ArrayType) IsBoolean() bool

func (*ArrayType) IsFloat

func (t *ArrayType) IsFloat() bool

func (*ArrayType) IsIdeal

func (t *ArrayType) IsIdeal() bool

func (*ArrayType) IsInteger

func (t *ArrayType) IsInteger() bool

func (*ArrayType) Lit

func (t *ArrayType) Lit() vm.Type

Lit returns this type's literal.

func (*ArrayType) String

func (t *ArrayType) String() string

String returns the string representation of this type.

func (*ArrayType) Zero

func (t *ArrayType) Zero() vm.Value

Zero returns a new zero value of this type.

type BoolType

type BoolType struct {
	// contains filtered or unexported fields
}

BoolType is used to represent boolean types (https://golang.ir/ref/spec#Boolean_types).

func (*BoolType) Compat

func (t *BoolType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*BoolType) IsBoolean

func (t *BoolType) IsBoolean() bool

IsBoolean returns true if this is a boolean type.

func (*BoolType) IsFloat

func (t *BoolType) IsFloat() bool

func (*BoolType) IsIdeal

func (t *BoolType) IsIdeal() bool

func (*BoolType) IsInteger

func (t *BoolType) IsInteger() bool

func (*BoolType) Lit

func (t *BoolType) Lit() vm.Type

Lit returns this type's literal.

func (*BoolType) String

func (t *BoolType) String() string

String returns the string representation of this type.

func (*BoolType) Zero

func (t *BoolType) Zero() vm.Value

Zero returns a new zero value of this type.

type ChanType

type ChanType struct {
	// contains filtered or unexported fields
}

ChanType is used to represent channel types (https://golang.ir/ref/spec#Channel_types).

func (*ChanType) Compat

func (t *ChanType) Compat(o vm.Type, conv bool) bool

func (*ChanType) IsBoolean

func (t *ChanType) IsBoolean() bool

func (*ChanType) IsFloat

func (t *ChanType) IsFloat() bool

func (*ChanType) IsIdeal

func (t *ChanType) IsIdeal() bool

func (*ChanType) IsInteger

func (t *ChanType) IsInteger() bool

func (*ChanType) Lit

func (t *ChanType) Lit() vm.Type

func (*ChanType) String

func (t *ChanType) String() string

func (*ChanType) Zero

func (t *ChanType) Zero() vm.Value

type ComplexType

type ComplexType struct {
	Bits uint // 0 for architecture-dependent type
	// contains filtered or unexported fields
}

ComplexType is used to represent complex numbers types (https://golang.ir/ref/spec#Numeric_types).

func (*ComplexType) Compat

func (t *ComplexType) Compat(o vm.Type, conv bool) bool

func (*ComplexType) IsBoolean

func (t *ComplexType) IsBoolean() bool

func (*ComplexType) IsFloat

func (t *ComplexType) IsFloat() bool

func (*ComplexType) IsIdeal

func (t *ComplexType) IsIdeal() bool

func (*ComplexType) IsInteger

func (t *ComplexType) IsInteger() bool

func (*ComplexType) Lit

func (t *ComplexType) Lit() vm.Type

func (*ComplexType) String

func (t *ComplexType) String() string

func (*ComplexType) Zero

func (t *ComplexType) Zero() vm.Value

type FloatType

type FloatType struct {
	Bits uint // 0 for architecture-dependent type
	// contains filtered or unexported fields
}

FloatType is used to represent floating-point number types (https://golang.ir/ref/spec#Numeric_types).

func MakeFloatType

func MakeFloatType(bits uint, name string) *FloatType

MakeFloatType creates a new floating-point type of the specified bit size.

func (*FloatType) Compat

func (t *FloatType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*FloatType) IsBoolean

func (t *FloatType) IsBoolean() bool

func (*FloatType) IsFloat

func (t *FloatType) IsFloat() bool

IsFloat returns true if this is a floating type.

func (*FloatType) IsIdeal

func (t *FloatType) IsIdeal() bool

func (*FloatType) IsInteger

func (t *FloatType) IsInteger() bool

func (*FloatType) Lit

func (t *FloatType) Lit() vm.Type

Lit returns this type's literal.

func (*FloatType) MaxVal

func (t *FloatType) MaxVal() *big.Rat

MaxVal returns the largest value of this type.

func (*FloatType) MinVal

func (t *FloatType) MinVal() *big.Rat

MinVal returns the smallest value of this type.

func (*FloatType) String

func (t *FloatType) String() string

String returns the string representation of this type.

func (*FloatType) Zero

func (t *FloatType) Zero() vm.Value

Zero returns a new zero value of this type.

type FuncDecl

type FuncDecl struct {
	Type     *FuncType
	Name     *ast.Ident   // nil for function literals
	InNames  []*ast.Ident // InNames will be one longer than Type.In if this function is variadic.
	OutNames []*ast.Ident
}

func (*FuncDecl) String

func (t *FuncDecl) String() string

type FuncType

type FuncType struct {
	In       []vm.Type
	Variadic bool
	Out      []vm.Type
	Builtin  string
	// contains filtered or unexported fields
}

func NewFuncType

func NewFuncType(in []vm.Type, variadic bool, out []vm.Type) *FuncType

NewFuncType creates a new function type with the specified input and output types.

func (*FuncType) Compat

func (t *FuncType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*FuncType) IsBoolean

func (t *FuncType) IsBoolean() bool

func (*FuncType) IsFloat

func (t *FuncType) IsFloat() bool

func (*FuncType) IsIdeal

func (t *FuncType) IsIdeal() bool

func (*FuncType) IsInteger

func (t *FuncType) IsInteger() bool

func (*FuncType) Lit

func (t *FuncType) Lit() vm.Type

Lit returns this type's literal.

func (*FuncType) String

func (t *FuncType) String() string

String returns the string representation of this type.

func (*FuncType) Zero

func (t *FuncType) Zero() vm.Value

Zero returns a new zero value of this type.

type IdealFloatType

type IdealFloatType struct {
	// contains filtered or unexported fields
}

func (*IdealFloatType) Compat

func (t *IdealFloatType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*IdealFloatType) IsBoolean

func (t *IdealFloatType) IsBoolean() bool

func (*IdealFloatType) IsFloat

func (t *IdealFloatType) IsFloat() bool

IsFloat returns true if this is a floating type.

func (*IdealFloatType) IsIdeal

func (t *IdealFloatType) IsIdeal() bool

IsIdeal returns true if this represents an ideal value.

func (*IdealFloatType) IsInteger

func (t *IdealFloatType) IsInteger() bool

func (*IdealFloatType) Lit

func (t *IdealFloatType) Lit() vm.Type

Lit returns this type's literal.

func (*IdealFloatType) String

func (t *IdealFloatType) String() string

String returns the string representation of this type.

func (*IdealFloatType) Zero

func (t *IdealFloatType) Zero() vm.Value

Zero returns a new zero value of this type.

type IdealIntType

type IdealIntType struct {
	// contains filtered or unexported fields
}

func (*IdealIntType) Compat

func (t *IdealIntType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*IdealIntType) IsBoolean

func (t *IdealIntType) IsBoolean() bool

func (*IdealIntType) IsFloat

func (t *IdealIntType) IsFloat() bool

func (*IdealIntType) IsIdeal

func (t *IdealIntType) IsIdeal() bool

IsIdeal returns true if this represents an ideal value.

func (*IdealIntType) IsInteger

func (t *IdealIntType) IsInteger() bool

IsInteger returns true if this is an integer type.

func (*IdealIntType) Lit

func (t *IdealIntType) Lit() vm.Type

Lit returns this type's literal.

func (*IdealIntType) String

func (t *IdealIntType) String() string

String returns the string representation of this type.

func (*IdealIntType) Zero

func (t *IdealIntType) Zero() vm.Value

Zero returns a new zero value of this type.

type IntType

type IntType struct {
	Bits uint   // 0 for architecture-dependent types
	Name string // The name of the int type
	// contains filtered or unexported fields
}

IntType is used to represent signed integer number types (https://golang.ir/ref/spec#Numeric_types).

func MakeIntType

func MakeIntType(bits uint, name string) *IntType

MakeIntType creates a new integer type of the specified bit size.

func (*IntType) Compat

func (t *IntType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*IntType) IsBoolean

func (t *IntType) IsBoolean() bool

func (*IntType) IsFloat

func (t *IntType) IsFloat() bool

func (*IntType) IsIdeal

func (t *IntType) IsIdeal() bool

func (*IntType) IsInteger

func (t *IntType) IsInteger() bool

IsInteger returns true if this is an integer type.

func (*IntType) Lit

func (t *IntType) Lit() vm.Type

Lit returns this type's literal.

func (*IntType) MaxVal

func (t *IntType) MaxVal() *big.Rat

MaxVal returns the largest value of this type.

func (*IntType) MinVal

func (t *IntType) MinVal() *big.Rat

MinVal returns the smallest value of this type.

func (*IntType) String

func (t *IntType) String() string

String returns the string representation of this type.

func (*IntType) Zero

func (t *IntType) Zero() vm.Value

Zero returns a new zero value of this type.

type InterfaceType

type InterfaceType struct {
	Methods map[string]*FuncType
	// contains filtered or unexported fields
}

func NewInterfaceType

func NewInterfaceType(methods map[string]*FuncType, embeds []*InterfaceType) *InterfaceType

NewInterfaceType creates a new interface type with the specified methods.

func (*InterfaceType) Compat

func (t *InterfaceType) Compat(o vm.Type, conv bool) bool

func (*InterfaceType) IsBoolean

func (t *InterfaceType) IsBoolean() bool

func (*InterfaceType) IsFloat

func (t *InterfaceType) IsFloat() bool

func (*InterfaceType) IsIdeal

func (t *InterfaceType) IsIdeal() bool

func (*InterfaceType) IsInteger

func (t *InterfaceType) IsInteger() bool

func (*InterfaceType) Lit

func (t *InterfaceType) Lit() vm.Type

func (*InterfaceType) String

func (t *InterfaceType) String() string

func (*InterfaceType) Zero

func (t *InterfaceType) Zero() vm.Value

type MapType

type MapType struct {
	Key  vm.Type
	Elem vm.Type
	// contains filtered or unexported fields
}

func NewMapType

func NewMapType(key vm.Type, elem vm.Type) *MapType

NewMapType creates a new map type of the specified type.

func (*MapType) Compat

func (t *MapType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*MapType) IsBoolean

func (t *MapType) IsBoolean() bool

func (*MapType) IsFloat

func (t *MapType) IsFloat() bool

func (*MapType) IsIdeal

func (t *MapType) IsIdeal() bool

func (*MapType) IsInteger

func (t *MapType) IsInteger() bool

func (*MapType) Lit

func (t *MapType) Lit() vm.Type

Lit returns this type's literal.

func (*MapType) String

func (t *MapType) String() string

String returns the string representation of this type.

func (*MapType) Zero

func (t *MapType) Zero() vm.Value

Zero returns a new zero value of this type.

type Method

type Method struct {
	// contains filtered or unexported fields
}

type MultiType

type MultiType struct {
	Elems []vm.Type
	// contains filtered or unexported fields
}

MultiType is a special type used for multi-valued expressions, akin to a tuple type. It's not generally accessible within the language.

func NewMultiType

func NewMultiType(elems []vm.Type) *MultiType

func (*MultiType) Compat

func (t *MultiType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*MultiType) IsBoolean

func (t *MultiType) IsBoolean() bool

func (*MultiType) IsFloat

func (t *MultiType) IsFloat() bool

func (*MultiType) IsIdeal

func (t *MultiType) IsIdeal() bool

func (*MultiType) IsInteger

func (t *MultiType) IsInteger() bool

func (*MultiType) Lit

func (t *MultiType) Lit() vm.Type

Lit returns this type's literal.

func (*MultiType) String

func (t *MultiType) String() string

String returns the string representation of this type.

func (*MultiType) Zero

func (t *MultiType) Zero() vm.Value

Zero returns a new zero value of this type.

type NamedType

type NamedType struct {
	NTPos      token.Pos
	Name       string
	Def        vm.Type           // Underlying type.
	Incomplete bool              // True while this type is being defined.
	Methods    map[string]Method //
}

NamedType represents a user defined type.

If Incomplete is true, Def will be nil. If Incomplete is false and Def is still nil, then this is a placeholder type representing an error.

func (*NamedType) Compat

func (t *NamedType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*NamedType) Complete

func (t *NamedType) Complete(def vm.Type)

Complete marks this named type as completed

func (*NamedType) IsBoolean

func (t *NamedType) IsBoolean() bool

IsBoolean returns true if this is a boolean type.

func (*NamedType) IsFloat

func (t *NamedType) IsFloat() bool

IsFloat returns true if this is a floating type.

func (*NamedType) IsIdeal

func (t *NamedType) IsIdeal() bool

IsIdeal returns true if this represents an ideal value.

func (*NamedType) IsInteger

func (t *NamedType) IsInteger() bool

IsInteger returns true if this is an integer type.

func (*NamedType) Lit

func (t *NamedType) Lit() vm.Type

Lit returns the underlying type's literal.

func (*NamedType) Pos

func (t *NamedType) Pos() token.Pos

Pos returns the position of the definition in the source code

func (*NamedType) String

func (t *NamedType) String() string

String returns the string representation of this type.

func (*NamedType) Zero

func (t *NamedType) Zero() vm.Value

Zero returns a new zero value of this type.

type PackageField

type PackageField struct {
	Name string
	Type vm.Type
}

type PackageType

type PackageType struct {
	Elems []PackageField
	// contains filtered or unexported fields
}

func NewPackageType

func NewPackageType(path string, fields []PackageField) *PackageType

NewPackageType creates a new package import type.

func (*PackageType) Compat

func (p *PackageType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*PackageType) IsBoolean

func (t *PackageType) IsBoolean() bool

func (*PackageType) IsFloat

func (t *PackageType) IsFloat() bool

func (*PackageType) IsIdeal

func (t *PackageType) IsIdeal() bool

func (*PackageType) IsInteger

func (t *PackageType) IsInteger() bool

func (*PackageType) Lit

func (p *PackageType) Lit() vm.Type

Lit returns this type's literal.

func (*PackageType) String

func (p *PackageType) String() string

String returns the string representation of this type.

func (*PackageType) Zero

func (p *PackageType) Zero() vm.Value

Zero returns a new zero value of this type.

type PtrType

type PtrType struct {
	Elem vm.Type
	// contains filtered or unexported fields
}

func NewPtrType

func NewPtrType(elem vm.Type) *PtrType

NewPtrType creates a new ptr type with the specified target type.

func (*PtrType) Compat

func (t *PtrType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*PtrType) IsBoolean

func (t *PtrType) IsBoolean() bool

func (*PtrType) IsFloat

func (t *PtrType) IsFloat() bool

func (*PtrType) IsIdeal

func (t *PtrType) IsIdeal() bool

func (*PtrType) IsInteger

func (t *PtrType) IsInteger() bool

func (*PtrType) Lit

func (t *PtrType) Lit() vm.Type

Lit returns this type's literal.

func (*PtrType) String

func (t *PtrType) String() string

String returns the string representation of this type.

func (*PtrType) Zero

func (t *PtrType) Zero() vm.Value

Zero returns a new zero value of this type.

type SliceType

type SliceType struct {
	Elem vm.Type
	// contains filtered or unexported fields
}

func NewSliceType

func NewSliceType(elem vm.Type) *SliceType

NewSliceType creates a new slice type with the specified element type.

func (*SliceType) Compat

func (t *SliceType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*SliceType) IsBoolean

func (t *SliceType) IsBoolean() bool

func (*SliceType) IsFloat

func (t *SliceType) IsFloat() bool

func (*SliceType) IsIdeal

func (t *SliceType) IsIdeal() bool

func (*SliceType) IsInteger

func (t *SliceType) IsInteger() bool

func (*SliceType) Lit

func (t *SliceType) Lit() vm.Type

Lit returns this type's literal.

func (*SliceType) String

func (t *SliceType) String() string

String returns the string representation of this type.

func (*SliceType) Zero

func (t *SliceType) Zero() vm.Value

Zero returns a new zero value of this type.

type StringType

type StringType struct {
	// contains filtered or unexported fields
}

func (*StringType) Compat

func (t *StringType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*StringType) IsBoolean

func (t *StringType) IsBoolean() bool

func (*StringType) IsFloat

func (t *StringType) IsFloat() bool

func (*StringType) IsIdeal

func (t *StringType) IsIdeal() bool

func (*StringType) IsInteger

func (t *StringType) IsInteger() bool

func (*StringType) Lit

func (t *StringType) Lit() vm.Type

Lit returns this type's literal.

func (*StringType) String

func (t *StringType) String() string

String returns the string representation of this type.

func (*StringType) Zero

func (t *StringType) Zero() vm.Value

Zero returns a new zero value of this type.

type StructField

type StructField struct {
	Name      string
	Type      vm.Type
	Anonymous bool
}

type StructType

type StructType struct {
	Elems []StructField
	// contains filtered or unexported fields
}

func NewStructType

func NewStructType(fields []StructField) *StructType

NewStructType creates a new struct type with the specified fields.

func (*StructType) Compat

func (t *StructType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*StructType) IsBoolean

func (t *StructType) IsBoolean() bool

func (*StructType) IsFloat

func (t *StructType) IsFloat() bool

func (*StructType) IsIdeal

func (t *StructType) IsIdeal() bool

func (*StructType) IsInteger

func (t *StructType) IsInteger() bool

func (*StructType) Lit

func (t *StructType) Lit() vm.Type

Lit returns this type's literal.

func (*StructType) String

func (t *StructType) String() string

String returns the string representation of this type.

func (*StructType) Zero

func (t *StructType) Zero() vm.Value

Zero returns a new zero value of this type.

type UintType

type UintType struct {
	Bits uint   // 0 for architecture-dependent types
	Ptr  bool   // true for uintptr, false for all others
	Name string // The name of the uint type
	// contains filtered or unexported fields
}

UintType is used to represent unsigned integer number types (https://golang.ir/ref/spec#Numeric_types).

func MakeUIntType

func MakeUIntType(bits uint, ptr bool, name string) *UintType

MakeUIntType creates a new unsigned integer type of the specified bit size.

func (*UintType) Compat

func (t *UintType) Compat(o vm.Type, conv bool) bool

Compat returns whether this type is compatible with another type.

func (*UintType) IsBoolean

func (t *UintType) IsBoolean() bool

func (*UintType) IsFloat

func (t *UintType) IsFloat() bool

func (*UintType) IsIdeal

func (t *UintType) IsIdeal() bool

func (*UintType) IsInteger

func (t *UintType) IsInteger() bool

IsInteger returns true if this is an integer type.

func (*UintType) Lit

func (t *UintType) Lit() vm.Type

Lit returns this type's literal.

func (*UintType) MaxVal

func (t *UintType) MaxVal() *big.Rat

MaxVal returns the largest value of this type.

func (*UintType) MinVal

func (t *UintType) MinVal() *big.Rat

MinVal returns the smallest value of this type.

func (*UintType) String

func (t *UintType) String() string

String returns the string representation of this type.

func (*UintType) Zero

func (t *UintType) Zero() vm.Value

Zero returns a new zero value of this type.

Jump to

Keyboard shortcuts

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