 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package ir is the GX Intermediate Representation (IR) tree. The tree is built by the GX builder google3/third_party/gxlang/gx/build/builder/builder from GX source code.
The structure and semantic is modeled after the go/ast package.
Index ¶
- Constants
- Variables
- func CanBeNumber(typ Type) bool
- func IsAxisLengthType(typ Type) bool
- func IsBoolOp(op token.Token) bool
- func IsDataType(typ Type) bool
- func IsExported(name string) bool
- func IsFloat(typ Type) bool
- func IsFloatKind(kind Kind) bool
- func IsIndexType(typ Type) bool
- func IsInteger(typ Type) bool
- func IsIntegerKind(kind Kind) bool
- func IsNumber(knd Kind) bool
- func IsRangeOk(k Kind) bool
- func IsSlicingOk(typ Type) bool
- func IsStatic(tp Type) bool
- func IsValid(tp Type) bool
- func Shape(tp Type) (ArrayRank, Type)
- func SupportOperators(typ Type) bool
- func TypeInclude(fetcher Fetcher, set Type, typ Type) (bool, error)
- func TypeString(typ Type) string
- func ValidIdent(ident *ast.Ident) bool
- func ValidName(n string) bool
- type AnonymousStorage
- type ArrayLitExpr
- type ArrayRank
- type ArrayType
- type AssignCallResult
- type AssignCallStmt
- type AssignExpr
- type AssignExprStmt
- type AssignableExpr
- type AtomicValue
- type AtomicValueT
- type AxLengthName
- type AxisExpr
- func (dm *AxisExpr) AssignableTo(fetcher Fetcher, dst AxisLengths) (bool, error)
- func (dm *AxisExpr) AxisValue() AssignableExpr
- func (dm *AxisExpr) Equal(fetcher Fetcher, other AxisLengths) (bool, error)
- func (dm *AxisExpr) NumAxes() int
- func (dm *AxisExpr) Source() ast.Node
- func (dm *AxisExpr) String() string
- func (dm *AxisExpr) Type() Type
- func (dm *AxisExpr) Value(Expr) AssignableExpr
 
- type AxisInfer
- func (dm *AxisInfer) AssignableTo(fetcher Fetcher, dst AxisLengths) (bool, error)
- func (dm *AxisInfer) AxisValue() AssignableExpr
- func (dm *AxisInfer) Equal(fetcher Fetcher, other AxisLengths) (bool, error)
- func (dm *AxisInfer) Expr() ast.Expr
- func (dm *AxisInfer) Source() ast.Node
- func (dm *AxisInfer) String() string
- func (dm *AxisInfer) Type() Type
- func (dm *AxisInfer) Value(Expr) AssignableExpr
 
- type AxisLengths
- type BaseType
- type BinaryExpr
- type BlockStmt
- type BuiltinType
- func (s *BuiltinType) AssignableTo(fetcher Fetcher, target Type) (bool, error)
- func (s *BuiltinType) ConvertibleTo(fetcher Fetcher, target Type) (bool, error)
- func (s *BuiltinType) Equal(_ Fetcher, other Type) (bool, error)
- func (s *BuiltinType) Kind() Kind
- func (s *BuiltinType) String() string
- func (s *BuiltinType) Value(x Expr) AssignableExpr
 
- type CallExpr
- type CallResultExpr
- type Canonical
- type CastExpr
- type ConstExpr
- type ConstSpec
- type Declarations
- type EinsumExpr
- type Element
- type Evaluator
- type Expr
- type ExprStmt
- type Fetcher
- type Field
- type FieldGroup
- type FieldList
- type FieldLit
- type FieldStorage
- type File
- type Func
- type FuncBuiltin
- func (s *FuncBuiltin) Doc() *ast.CommentGroup
- func (s *FuncBuiltin) File() *File
- func (s *FuncBuiltin) FuncType() *FuncType
- func (s *FuncBuiltin) Name() string
- func (s *FuncBuiltin) NameDef() *ast.Ident
- func (s *FuncBuiltin) Same(o Storage) bool
- func (s *FuncBuiltin) Source() ast.Node
- func (f *FuncBuiltin) String() string
- func (s *FuncBuiltin) Type() Type
- func (s *FuncBuiltin) Value(x Expr) AssignableExpr
 
- type FuncDecl
- func (s *FuncDecl) Doc() *ast.CommentGroup
- func (s *FuncDecl) File() *File
- func (s *FuncDecl) FullyQualifiedName() string
- func (s *FuncDecl) FuncType() *FuncType
- func (s *FuncDecl) Name() string
- func (s *FuncDecl) NameDef() *ast.Ident
- func (s *FuncDecl) Same(o Storage) bool
- func (s *FuncDecl) Source() ast.Node
- func (f *FuncDecl) String() string
- func (s *FuncDecl) Type() Type
- func (s *FuncDecl) Value(x Expr) AssignableExpr
 
- type FuncImpl
- type FuncLit
- func (s *FuncLit) Doc() *ast.CommentGroup
- func (s *FuncLit) Expr() ast.Expr
- func (s *FuncLit) File() *File
- func (s *FuncLit) FuncType() *FuncType
- func (s *FuncLit) Name() string
- func (s *FuncLit) NameDef() *ast.Ident
- func (s *FuncLit) Same(o Storage) bool
- func (s *FuncLit) Source() ast.Node
- func (s *FuncLit) Store() Storage
- func (s *FuncLit) String() string
- func (s *FuncLit) Type() Type
- func (s *FuncLit) Value(x Expr) AssignableExpr
 
- type FuncType
- func (s *FuncType) AssignableTo(fetcher Fetcher, other Type) (bool, error)
- func (s *FuncType) ConvertibleTo(fetcher Fetcher, target Type) (bool, error)
- func (s *FuncType) Equal(fetcher Fetcher, other Type) (bool, error)
- func (s *FuncType) Kind() Kind
- func (s *FuncType) NameString(name string) string
- func (s *FuncType) ReceiverField() *Field
- func (s *FuncType) Source() ast.Node
- func (s *FuncType) String() string
- func (s *FuncType) Value(x Expr) AssignableExpr
 
- type FuncValExpr
- type IfStmt
- type ImportDecl
- type Importer
- type IndexExpr
- type IndexListExpr
- type Int
- type InterfaceType
- func (s *InterfaceType) AssignableTo(Fetcher, Type) (bool, error)
- func (s *InterfaceType) ConvertibleTo(Fetcher, Type) (bool, error)
- func (s *InterfaceType) Equal(Fetcher, Type) (bool, error)
- func (s *InterfaceType) Kind() Kind
- func (s *InterfaceType) String() string
- func (s *InterfaceType) Value(x Expr) AssignableExpr
 
- type Kind
- type LocalVarStorage
- type Macro
- func (s *Macro) Doc() *ast.CommentGroup
- func (s *Macro) File() *File
- func (s *Macro) FuncType() *FuncType
- func (s *Macro) Name() string
- func (s *Macro) NameDef() *ast.Ident
- func (s *Macro) Same(o Storage) bool
- func (s *Macro) Source() ast.Node
- func (s *Macro) String() string
- func (s *Macro) Type() Type
- func (s *Macro) Value(x Expr) AssignableExpr
 
- type NamedType
- func (s *NamedType) AssignableTo(fetcher Fetcher, target Type) (bool, error)
- func (s *NamedType) ConvertibleTo(fetcher Fetcher, target Type) (bool, error)
- func (s *NamedType) Equal(fetcher Fetcher, other Type) (bool, error)
- func (s *NamedType) FullName() string
- func (s *NamedType) Kind() Kind
- func (s *NamedType) MethodByName(name string) PkgFunc
- func (s *NamedType) Name() string
- func (s *NamedType) NameDef() *ast.Ident
- func (s *NamedType) Package() *Package
- func (s *NamedType) Same(o Storage) bool
- func (s *NamedType) Source() ast.Node
- func (s *NamedType) String() string
- func (s *NamedType) Type() Type
- func (s *NamedType) Value(x Expr) AssignableExpr
 
- type Node
- type Number
- type NumberCastExpr
- type NumberFloat
- type NumberInt
- type Package
- func (pkg *Package) ExportedConsts() []*ConstExpr
- func (pkg *Package) ExportedFuncs() iter.Seq[PkgFunc]
- func (pkg *Package) ExportedTypes() []*NamedType
- func (pkg *Package) File(name string) *File
- func (pkg *Package) FindFunc(name string) PkgFunc
- func (pkg *Package) FullName() string
- func (pkg *Package) String() string
 
- type PackageRef
- type ParenExpr
- type PkgFunc
- type RangeStmt
- type Rank
- func (r *Rank) AssignableTo(fetcher Fetcher, dst ArrayRank) (bool, error)
- func (r *Rank) Axes() []AxisLengths
- func (r *Rank) AxisLengths() []AxisLengths
- func (r *Rank) ConvertibleTo(fetcher Fetcher, dst ArrayRank) (bool, error)
- func (r *Rank) Equal(fetcher Fetcher, other ArrayRank) (bool, error)
- func (r *Rank) IsAtomic() bool
- func (r *Rank) Source() ast.Node
- func (r *Rank) String() string
- func (r *Rank) SubRank() (ArrayRank, bool)
- func (r *Rank) Type() Type
 
- type RankInfer
- func (r *RankInfer) AssignableTo(fetcher Fetcher, dst ArrayRank) (bool, error)
- func (r *RankInfer) Axes() []AxisLengths
- func (r *RankInfer) ConvertibleTo(fetcher Fetcher, dst ArrayRank) (bool, error)
- func (r *RankInfer) Equal(fetcher Fetcher, other ArrayRank) (bool, error)
- func (r *RankInfer) IsAtomic() bool
- func (r *RankInfer) Source() ast.Node
- func (r *RankInfer) String() string
- func (r *RankInfer) SubRank() (ArrayRank, bool)
- func (r *RankInfer) Type() Type
 
- type ReturnStmt
- type RuntimeValue
- type RuntimeValueExpr
- type RuntimeValueExprT
- type SelectorExpr
- type SliceLitExpr
- type SliceType
- func (s *SliceType) AssignableTo(fetcher Fetcher, target Type) (bool, error)
- func (s *SliceType) ConvertibleTo(fetcher Fetcher, target Type) (bool, error)
- func (s *SliceType) ElementType() (Type, bool)
- func (s *SliceType) Equal(fetcher Fetcher, other Type) (bool, error)
- func (s *SliceType) Kind() Kind
- func (s *SliceType) Source() ast.Node
- func (s *SliceType) String() string
- func (s *SliceType) Value(x Expr) AssignableExpr
 
- type SlicerType
- type SourceNode
- type SpecialisedFunc
- type Stmt
- type Storage
- type StorageWithValue
- type StringLiteral
- type StructFieldStorage
- type StructLitExpr
- type StructType
- func (s *StructType) AssignableTo(fetcher Fetcher, target Type) (bool, error)
- func (s *StructType) ConvertibleTo(fetcher Fetcher, target Type) (bool, error)
- func (s *StructType) Equal(_ Fetcher, other Type) (bool, error)
- func (s *StructType) Kind() Kind
- func (s *StructType) NumFields() int
- func (s *StructType) Source() ast.Node
- func (s *StructType) String() string
- func (s *StructType) Value(x Expr) AssignableExpr
 
- type Tuple
- type TupleType
- func (s *TupleType) AssignableTo(fetcher Fetcher, target Type) (bool, error)
- func (s *TupleType) ConvertibleTo(fetcher Fetcher, target Type) (bool, error)
- func (s *TupleType) Equal(fetcher Fetcher, target Type) (bool, error)
- func (s *TupleType) Kind() Kind
- func (s *TupleType) String() string
- func (s *TupleType) Value(x Expr) AssignableExpr
 
- type Type
- func AnyType() Type
- func AtomicFromString(ident string) Type
- func Bfloat16Type() Type
- func BoolType() Type
- func DefaultNumberType(kind Kind) Type
- func Float32Type() Type
- func Float64Type() Type
- func Int32Type() Type
- func Int64Type() Type
- func IntIndexType() Type
- func IntLenType() Type
- func InvalidType() Type
- func MetaType() Type
- func NumberFloatType() Type
- func NumberIntType() Type
- func PackageType() Type
- func RankType() Type
- func StringType() Type
- func TypeFromKind(kind Kind) Type
- func Uint32Type() Type
- func Underlying(typ Type) Type
- func UnknownType() Type
- func VoidType() Type
 
- type TypeAssertExpr
- type TypeCastExpr
- type TypeParam
- func (s *TypeParam) AssignableTo(fetcher Fetcher, typ Type) (bool, error)
- func (s *TypeParam) ConvertibleTo(fetcher Fetcher, typ Type) (bool, error)
- func (s *TypeParam) Equal(fetcher Fetcher, typ Type) (bool, error)
- func (s *TypeParam) Kind() Kind
- func (s *TypeParam) Same(o Storage) bool
- func (s *TypeParam) Source() ast.Node
- func (s *TypeParam) String() string
- func (s *TypeParam) Type() Type
- func (s *TypeParam) Value(x Expr) AssignableExpr
 
- type TypeParamValue
- type TypeSet
- func (s *TypeSet) ArrayType() ast.Expr
- func (s *TypeSet) AssignableTo(fetcher Fetcher, target Type) (bool, error)
- func (s *TypeSet) ConvertibleTo(fetcher Fetcher, target Type) (bool, error)
- func (s *TypeSet) DataType() Type
- func (s *TypeSet) ElementType() (Type, bool)
- func (s *TypeSet) Equal(fetcher Fetcher, target Type) (bool, error)
- func (s *TypeSet) Kind() Kind
- func (*TypeSet) Rank() ArrayRank
- func (s *TypeSet) Source() ast.Node
- func (s *TypeSet) String() string
- func (s *TypeSet) Value(x Expr) AssignableExpr
- func (s *TypeSet) Zero() AssignableExpr
 
- type TypeValExpr
- type UnaryExpr
- type Value
- type ValueRef
- type VarExpr
- type VarSpec
- type WithStore
- type Zeroer
Constants ¶
const ( // DefineAxisGroup is the prefix used in parameters to define an axis group. DefineAxisGroup = "___" // DefineAxisLength is the prefix used in parameters to define an axis length. DefineAxisLength = "_" )
const ( InvalidKind = Kind(dtype.Invalid) BoolKind = Kind(dtype.Bool) Int32Kind = Kind(dtype.Int32) Int64Kind = Kind(dtype.Int64) Uint32Kind = Kind(dtype.Uint32) Uint64Kind = Kind(dtype.Uint64) Bfloat16Kind = Kind(dtype.Bfloat16) Float32Kind = Kind(dtype.Float32) Float64Kind = Kind(dtype.Float64) IntIdxKind = Kind(iota + dtype.MaxDataType) IntLenKind // UnknownKind is a proxy type used while a type is being inferred by the compiler. UnknownKind // VoidKind is a type for expression returning nothing. VoidKind // InterfaceKind is an interface. InterfaceKind // NumberFloatKind is a float number with no concrete type. NumberFloatKind // NumberIntKind is an integer number with no concrete type. NumberIntKind ArrayKind BuiltinKind FuncKind RankKind SliceKind StringKind StructKind TupleKind IRKind PackageKind MetaTypeKind // Maximum value for a Kind constant. MaxKind )
Kind of data supported by GX.
const Blank = "_"
    Blank characters when an identifier is not needed.
Variables ¶
var ( // DefaultIntKind is the default kind for integer. DefaultIntKind = Int64Kind // DefaultIntType is the default type used for an integer. DefaultIntType = TypeFromKind(Int64Kind) )
var DefaultFloatType = Float32Type()
    DefaultFloatType is the default type used for a scalar.
Functions ¶
func CanBeNumber ¶
CanBeNumber returns true if the value of a kind can be a number.
func IsAxisLengthType ¶ added in v0.3.0
IsAxisLengthType returns true if a type is the type for an array axis length.
func IsDataType ¶
IsDataType returns true if the type can be stored in an array.
func IsExported ¶
IsExported returns true if a name is exported (the first letter is capitalized).
func IsIndexType ¶
IsIndexType returns true if the kind is a supported array index type.
func IsIntegerKind ¶
IsIntegerKind return true if kind is an integer.
func IsRangeOk ¶
IsRangeOk returns true if the kind can be used to iterate in a for loop with a range statement.
func IsSlicingOk ¶
IsSlicingOk returns true if the type supports slicing, (that is value_of_type[i]).
func IsStatic ¶
IsStatic return true if the type is static, that is if the instance of the type can be evaluated when the graph is being constructed.
func Shape ¶
Shape returns the data type and axes of an array. An invalid data type is returned if the type is not a container. A slice returns a nil rank.
func SupportOperators ¶
SupportOperators returns true if the type supports unary or binary operators.
func TypeInclude ¶
TypeInclude returns if a typ is included in a type or not.
func TypeString ¶ added in v0.4.0
TypeString returns a string representation of a type for users.
func ValidIdent ¶
ValidIdent returns true if the ident points to a valid identifier.
Types ¶
type AnonymousStorage ¶
AnonymousStorage stores values that have not been labelled (for example, the axis length in [_]float32).
func (*AnonymousStorage) Expr ¶
func (s *AnonymousStorage) Expr() ast.Expr
Expr returns the expression in the AST tree.
func (*AnonymousStorage) NameDef ¶
func (s *AnonymousStorage) NameDef() *ast.Ident
NameDef returns the identifier identifying the storage.
func (*AnonymousStorage) Same ¶ added in v0.3.0
func (s *AnonymousStorage) Same(o Storage) bool
Same returns true if the other storage is this storage.
func (*AnonymousStorage) Source ¶
func (s *AnonymousStorage) Source() ast.Node
Source returns the node in the AST tree.
func (*AnonymousStorage) Type ¶
func (s *AnonymousStorage) Type() Type
Type of the destination of the assignment.
type ArrayLitExpr ¶
type ArrayLitExpr struct {
	Src  *ast.CompositeLit
	Typ  ArrayType
	Elts []AssignableExpr
}
    ArrayLitExpr is an array literal.
func (*ArrayLitExpr) NewFromValues ¶
func (s *ArrayLitExpr) NewFromValues(elts []AssignableExpr) *ArrayLitExpr
NewFromValues returns a new literal of the same type from a slice of values.
func (*ArrayLitExpr) Type ¶
func (s *ArrayLitExpr) Type() Type
Type returns the type returned by the function call.
func (*ArrayLitExpr) Values ¶
func (s *ArrayLitExpr) Values() []AssignableExpr
Values returns the expressions defining the values of the array.
type ArrayRank ¶
type ArrayRank interface {
	Expr
	// IsAtomic returns true if the rank has no axes.
	IsAtomic() bool
	// Axes returns all axis in the rank.
	Axes() []AxisLengths
	// Equal returns true if two ranks are equal.
	Equal(Fetcher, ArrayRank) (bool, error)
	// AssignableTo returns true if this rank can be assigned to the destination rank.
	AssignableTo(Fetcher, ArrayRank) (bool, error)
	// ConvertibleTo returns true if this rank can be converted to the destination rank.
	ConvertibleTo(Fetcher, ArrayRank) (bool, error)
	// SubRank returns the rank with the top-axis removed.
	SubRank() (ArrayRank, bool)
	// String representation of the rank.
	String() string
	// contains filtered or unexported methods
}
    ArrayRank of an array.
type ArrayType ¶
type ArrayType interface {
	Zeroer
	SourceNode
	SlicerType
	// ArrayType returns the source code defining the array type.
	// May be nil.
	ArrayType() ast.Expr
	// Rank returns the rank of the array,
	// that is, a list of the array's axes.
	Rank() ArrayRank
	// DataType returns the element type of the array.
	DataType() Type
	// contains filtered or unexported methods
}
    ArrayType is a type with a rank.
func NewArrayType ¶
NewArrayType returns a new array from a data type and a rank.
func ToArrayType ¶
ToArrayType converts a type into an array type. Returns nil if the conversion is not possible
func ToArrayTypeGivenShape ¶
ToArrayTypeGivenShape converts a type to the underlying array type. Returns an error with the array type does not match the shape.
type AssignCallResult ¶
AssignCallResult assigns the result of a function call.
func (*AssignCallResult) Value ¶
func (a *AssignCallResult) Value(Expr) AssignableExpr
Value returns the expression stored in the storage.
type AssignCallStmt ¶
type AssignCallStmt struct {
	Src  *ast.AssignStmt
	Call *CallExpr
	List []*AssignCallResult
}
    AssignCallStmt assigns the results of a function call returning more than one value to variables.
func (*AssignCallStmt) Source ¶
func (s *AssignCallStmt) Source() ast.Node
Source returns the node in the AST tree.
func (*AssignCallStmt) String ¶
func (s *AssignCallStmt) String() string
type AssignExpr ¶
type AssignExpr struct {
	Storage
	X AssignableExpr
}
    AssignExpr assigns an expression to a Assignable node.
func (*AssignExpr) Value ¶
func (a *AssignExpr) Value(Expr) AssignableExpr
Value returns the expression stored in the storage.
type AssignExprStmt ¶
type AssignExprStmt struct {
	Src  *ast.AssignStmt
	List []*AssignExpr
}
    AssignExprStmt assigns the results of expressions (possibly functions returning one value) to variables.
func (*AssignExprStmt) Source ¶
func (s *AssignExprStmt) Source() ast.Node
Source returns the node in the AST tree.
func (*AssignExprStmt) String ¶
func (s *AssignExprStmt) String() string
type AssignableExpr ¶
type AssignableExpr interface {
	Expr
	// contains filtered or unexported methods
}
    AssignableExpr is an expression which can be assigned to variable. This excludes package or types.
type AtomicValue ¶
type AtomicValue interface {
	AssignableExpr
	// contains filtered or unexported methods
}
    AtomicValue is implemented by all atomic values.
type AtomicValueT ¶
type AtomicValueT[T dtype.GoDataType] struct { Src ast.Expr Val T Typ Type }
AtomicValueT is a builtin constant.
func (*AtomicValueT[T]) Expr ¶
func (s *AtomicValueT[T]) Expr() ast.Expr
Expr returns the AST expression.
func (*AtomicValueT[T]) Source ¶
func (s *AtomicValueT[T]) Source() ast.Node
Source returns the node in the AST tree.
func (*AtomicValueT[T]) Type ¶
func (s *AtomicValueT[T]) Type() Type
Type returns the type returned by the function call.
type AxLengthName ¶ added in v0.3.0
AxLengthName defines a name for the length of an axis or a group of axes.
func (*AxLengthName) NameDef ¶ added in v0.3.0
func (s *AxLengthName) NameDef() *ast.Ident
NameDef returns the identifier identifying the storage.
func (*AxLengthName) Same ¶ added in v0.3.0
func (s *AxLengthName) Same(o Storage) bool
Same returns true if the other storage is this storage.
func (*AxLengthName) Source ¶ added in v0.3.0
func (s *AxLengthName) Source() ast.Node
Source returns the node in the AST tree.
func (*AxLengthName) String ¶ added in v0.3.0
func (dm *AxLengthName) String() string
String representation of the dimension.
func (*AxLengthName) Type ¶ added in v0.3.0
func (s *AxLengthName) Type() Type
Type of the destination of the assignment.
type AxisExpr ¶
type AxisExpr struct {
	// Source of the axis expression.
	// May be different from the source of the expression, for example
	// the expression is formed from a function call.
	Src ast.Expr
	// X computes the size of the axis.
	X AssignableExpr
}
    AxisExpr is an array axis specified using an expression.
func (*AxisExpr) AssignableTo ¶
func (dm *AxisExpr) AssignableTo(fetcher Fetcher, dst AxisLengths) (bool, error)
AssignableTo returns true if a dimension can be assigned to another.
func (*AxisExpr) AxisValue ¶
func (dm *AxisExpr) AxisValue() AssignableExpr
AxisValue returns the value assigned to the axis.
func (*AxisExpr) Equal ¶
func (dm *AxisExpr) Equal(fetcher Fetcher, other AxisLengths) (bool, error)
Equal returns true if other has the axis length.
type AxisInfer ¶
type AxisInfer struct {
	Src *ast.Ident
	X   AxisLengths
}
    AxisInfer is an array axis specified as "_" and inferred by the compiler.
func (*AxisInfer) AssignableTo ¶
func (dm *AxisInfer) AssignableTo(fetcher Fetcher, dst AxisLengths) (bool, error)
AssignableTo returns true if a dimension can be assigned to another.
func (*AxisInfer) AxisValue ¶
func (dm *AxisInfer) AxisValue() AssignableExpr
AxisValue returns the value assigned to the axis.
func (*AxisInfer) Equal ¶
func (dm *AxisInfer) Equal(fetcher Fetcher, other AxisLengths) (bool, error)
Equal returns true if other has the axis length.
type AxisLengths ¶
type AxisLengths interface {
	Expr
	// AxisValue returns the value associated with the axis.
	// Can return nil if the axis has not been resolved.
	AxisValue() AssignableExpr
	// Equal returns true if two axis lengths have been resolved and are equal.
	// Returns an error if one of the axis has not been resolved.
	Equal(Fetcher, AxisLengths) (bool, error)
	// AssignableTo returns true if this axis length can be assigned to another.
	AssignableTo(Fetcher, AxisLengths) (bool, error)
	// String representation of the axis length.
	String() string
	// contains filtered or unexported methods
}
    AxisLengths specification of an array.
type BaseType ¶
BaseType is the base of all types.
type BinaryExpr ¶
type BinaryExpr struct {
	Src  *ast.BinaryExpr
	X, Y AssignableExpr
	Typ  Type
}
    BinaryExpr is an operator with two arguments.
type BlockStmt ¶
BlockStmt is a braced statement list.
type BuiltinType ¶
BuiltinType is an opaque type maintained by the backend. These are the only atomic types that can have a state.
func (*BuiltinType) AssignableTo ¶
func (s *BuiltinType) AssignableTo(fetcher Fetcher, target Type) (bool, error)
AssignableTo reports if the type can be assigned to other.
func (*BuiltinType) ConvertibleTo ¶
func (s *BuiltinType) ConvertibleTo(fetcher Fetcher, target Type) (bool, error)
ConvertibleTo reports whether a value of the type can be converted to another (using static type casting).
func (*BuiltinType) Equal ¶
func (s *BuiltinType) Equal(_ Fetcher, other Type) (bool, error)
Equal returns true if other is the same type.
func (*BuiltinType) String ¶
func (s *BuiltinType) String() string
String representation of the type.
func (*BuiltinType) Value ¶
func (s *BuiltinType) Value(x Expr) AssignableExpr
Value returns a value pointing to the receiver.
type CallExpr ¶
type CallExpr struct {
	Src    *ast.CallExpr
	Args   []AssignableExpr
	Callee *FuncValExpr
}
    CallExpr is an expression calling a function.
func (*CallExpr) ExprFromResult ¶
func (s *CallExpr) ExprFromResult(i int) *CallResultExpr
ExprFromResult returns an expression pointing to the ith result of a function call.
type CallResultExpr ¶
CallResultExpr represents the ith result of a function call as an expression.
type Canonical ¶
type Canonical interface {
	Expr() (AssignableExpr, error)
}
    Canonical is a canonical value with a IR representation.
type CastExpr ¶
CastExpr casts a type to another.
type ConstExpr ¶
type ConstExpr struct {
	Decl *ConstSpec
	VName *ast.Ident
	Val   AssignableExpr
}
    ConstExpr is a name,expr constant pair.
func (*ConstExpr) Value ¶
func (cst *ConstExpr) Value(Expr) AssignableExpr
Value assigned to the constant.
type Declarations ¶
type Declarations struct {
	Package *Package
	Consts []*ConstSpec
	Funcs  []PkgFunc
	Types  []*NamedType
	Vars   []*VarSpec
}
    Declarations in a package.
func (*Declarations) ConstExprs ¶
func (decls *Declarations) ConstExprs() ([]*ConstExpr, error)
ConstExprs returns all constant expressions with respect to their dependency. That is expressions are ordered such that an expression is always after its dependencies. If a cycle exists, then the ordering between the expressions in that cycle is not defined.
func (*Declarations) TypeByName ¶
func (decls *Declarations) TypeByName(name string) *NamedType
TypeByName returns a type defined in the package given its name. Returns nil if the type could not be found.
type EinsumExpr ¶
EinsumExpr represents an einsum expression.
type Element ¶ added in v0.3.0
type Element interface {
	Type() Type
}
    Element is a value returned by the evaluator.
type Expr ¶
type Expr interface {
	SourceNode
	Type() Type
	String() string
}
    Expr is an expression that returns a (typed) result.
type ExprStmt ¶
ExprStmt is a statement evaluating an expression with no return result.
type Fetcher ¶
type Fetcher interface {
	Evaluator
	Err() *fmterr.Appender
	BuildExpr(ast.Expr) (Expr, bool)
	IsDefined(string) bool
}
    Fetcher represents a scope in the compiler.
type Field ¶
type Field struct {
	Group *FieldGroup
	Name *ast.Ident
}
    Field is a field belonging to a field group.
func (*Field) Storage ¶
func (s *Field) Storage() *FieldStorage
Storage returns a storage pointing to the field.
type FieldGroup ¶
FieldGroup is a list of field matched to a type.
func (*FieldGroup) NumFields ¶
func (s *FieldGroup) NumFields() int
NumFields returns the number of field in the group.
func (*FieldGroup) Source ¶
func (s *FieldGroup) Source() ast.Node
Source returns the node in the AST tree.
func (*FieldGroup) String ¶
func (g *FieldGroup) String() string
type FieldList ¶
type FieldList struct {
	Src  *ast.FieldList
	List []*FieldGroup
}
    FieldList is a list of fields, enclosed by parentheses, curly braces, or square brackets.
func (*FieldList) Fields ¶
Fields returns a list of all the fields in the structure in a consistent order which can be used as a reference.
func (*FieldList) FindField ¶
FindField returns the field matching the given name or nil if not found.
type FieldLit ¶
type FieldLit struct {
	*FieldStorage
	X AssignableExpr
}
    FieldLit assigns a value to a field in a structure literal.
func (*FieldLit) Value ¶
func (lit *FieldLit) Value(Expr) AssignableExpr
Value returns the value stored in the field.
type FieldStorage ¶
type FieldStorage struct {
	Field *Field
}
    FieldStorage is a field to which values can be assigned to.
func (*FieldStorage) NameDef ¶
func (s *FieldStorage) NameDef() *ast.Ident
NameDef returns the identifier identifying the storage.
func (*FieldStorage) Same ¶ added in v0.3.0
func (s *FieldStorage) Same(o Storage) bool
Same returns true if the other storage is this storage.
func (*FieldStorage) Source ¶
func (s *FieldStorage) Source() ast.Node
Source returns the node in the AST tree.
func (*FieldStorage) Type ¶
func (s *FieldStorage) Type() Type
Type of the destination of the assignment.
type File ¶
type File struct {
	Package *Package
	Src     *ast.File
	Imports []*ImportDecl
}
    File represents a GX source file.
func (*File) FindImport ¶
func (f *File) FindImport(path string) *ImportDecl
FindImport returns an import declaration given a package full path. Returns nil if the path cannot be found.
type Func ¶
type Func interface {
	Expr
	// Name of the function (without the package name).
	Name() string
	// Doc returns associated documentation or nil.
	Doc() *ast.CommentGroup
	// File owning the function.
	File() *File
	// Type of the function.
	// If the function is generic, then the type will have been inferred by the compiler from the
	// types passed as args. Note that both FuncType() and Type() must return the same underlying
	// value, though FuncType returns the concrete type.
	FuncType() *FuncType
}
    Func is a callable GX function.
type FuncBuiltin ¶
FuncBuiltin is a function provided by a backend. The implementation is opaque to GX.
func (*FuncBuiltin) Doc ¶
func (s *FuncBuiltin) Doc() *ast.CommentGroup
Doc returns associated documentation or nil.
func (*FuncBuiltin) FuncType ¶
func (s *FuncBuiltin) FuncType() *FuncType
FuncType returns the concrete type of the function.
func (*FuncBuiltin) Name ¶
func (s *FuncBuiltin) Name() string
Name of the function. Returns an empty string if the function is anonymous.
func (*FuncBuiltin) NameDef ¶
func (s *FuncBuiltin) NameDef() *ast.Ident
NameDef is the name definition of the function.
func (*FuncBuiltin) Same ¶ added in v0.3.0
func (s *FuncBuiltin) Same(o Storage) bool
Same returns true if the other storage is this storage.
func (*FuncBuiltin) Source ¶
func (s *FuncBuiltin) Source() ast.Node
Source returns the node in the AST tree.
func (*FuncBuiltin) String ¶
func (f *FuncBuiltin) String() string
String returns a string representation of the builtin function.
func (*FuncBuiltin) Value ¶
func (s *FuncBuiltin) Value(x Expr) AssignableExpr
Value returns a reference to the function.
type FuncDecl ¶
FuncDecl is a GX function declared at the package level.
func (*FuncDecl) Doc ¶
func (s *FuncDecl) Doc() *ast.CommentGroup
Doc returns associated documentation or nil.
func (*FuncDecl) FullyQualifiedName ¶
FullyQualifiedName returns a fully qualified function name, that is the full package path and the name of the function.
func (*FuncDecl) Value ¶
func (s *FuncDecl) Value(x Expr) AssignableExpr
Value returns a reference to the function.
type FuncImpl ¶
type FuncImpl interface {
	// BuildFuncType builds the type of a function given how it is called.
	BuildFuncType(fetcher Fetcher, call *CallExpr) (*FuncType, error)
	// Implementation of the function, provided by the backend.
	Implementation() any
}
    FuncImpl is a builtin opaque function implementation provided by a backend or a host language.
For example, the function num.Concat is not implemented in GX and directly provided by the backend.
type FuncLit ¶
FuncLit is a function literal.
func (*FuncLit) Doc ¶
func (s *FuncLit) Doc() *ast.CommentGroup
Doc returns associated documentation or nil.
func (*FuncLit) Name ¶
Name of the function. Returns an empty string since literals are always anonymous.
func (*FuncLit) Value ¶
func (s *FuncLit) Value(x Expr) AssignableExpr
Value returns the function literal as an assignable expression.
type FuncType ¶
type FuncType struct {
	BaseType[*ast.FuncType]
	Receiver   *FieldList
	TypeParams *FieldList
	Params     *FieldList
	Results    *FieldList
	TypeParamsValues []TypeParamValue
	// CompEval is set to true if the function can be called at compilation time.
	CompEval bool
}
    FuncType defines a function signature.
func (*FuncType) AssignableTo ¶
AssignableTo reports if the type can be assigned to other.
func (*FuncType) ConvertibleTo ¶
ConvertibleTo reports whether a value of the type can be converted to another (using static type casting).
func (*FuncType) NameString ¶ added in v0.4.0
NameString returns a string representation of a signature given a name. The name can be empty.
func (*FuncType) ReceiverField ¶
ReceiverField returns a field representing the receiver of the function, or nil if the function has no receiver.
func (*FuncType) Value ¶
func (s *FuncType) Value(x Expr) AssignableExpr
Value returns a value pointing to the receiver.
type FuncValExpr ¶
type FuncValExpr struct {
	X Expr
	F Storage
	// T is the function type if the function has been specialised by the call
	// (in the context of generic functions).
	T *FuncType
}
    FuncValExpr is an expression pointing to a function.
type ImportDecl ¶
type ImportDecl struct {
	Src  *ast.ImportSpec
	Path string
}
    ImportDecl imports a package.
func (*ImportDecl) NameDef ¶
func (s *ImportDecl) NameDef() *ast.Ident
NameDef is the name definition of the function.
func (*ImportDecl) Same ¶ added in v0.3.0
func (s *ImportDecl) Same(o Storage) bool
Same returns true if the other storage is this storage.
func (*ImportDecl) Source ¶
func (s *ImportDecl) Source() ast.Node
Source returns the node in the AST tree.
func (*ImportDecl) String ¶
func (s *ImportDecl) String() string
func (*ImportDecl) Value ¶
func (s *ImportDecl) Value(x Expr) AssignableExpr
Value returns a reference to the function.
type Importer ¶ added in v0.3.0
type Importer interface {
	// Import a package given its path.
	Import(pkgPath string) (*Package, error)
}
    Importer imports packages given their path.
type IndexExpr ¶
IndexExpr selects an index on a indexable type.
type IndexListExpr ¶
type IndexListExpr struct {
	Src     *ast.IndexListExpr
	X       Expr
	Indices Expr
	Typ     Type
}
    IndexListExpr selects an index on a indexable type.
type Int ¶
type Int = int64
Int is the default integer for indices, for loops, etc. It needs to match DefaultIntKind above
type InterfaceType ¶
InterfaceType defines the type of an interface.
func (*InterfaceType) AssignableTo ¶
func (s *InterfaceType) AssignableTo(Fetcher, Type) (bool, error)
AssignableTo reports whether a value of the type can be assigned to another. Always returns false.
func (*InterfaceType) ConvertibleTo ¶
func (s *InterfaceType) ConvertibleTo(Fetcher, Type) (bool, error)
ConvertibleTo reports whether a value of the type can be converted to another (using static type casting). Always returns false.
func (*InterfaceType) Equal ¶
func (s *InterfaceType) Equal(Fetcher, Type) (bool, error)
Equal returns true if other is the same type.
func (*InterfaceType) String ¶
func (s *InterfaceType) String() string
String representation of the type.
func (*InterfaceType) Value ¶
func (s *InterfaceType) Value(x Expr) AssignableExpr
Value returns a value pointing to the receiver.
type Kind ¶
type Kind uint
Kind of a type.
func KindFromString ¶
KindFromString returns a kind given an identifier. It only works for the basic types that don't take other parameters -- so it doesn't work for tensors, tuples or functions.
The "unknown" string returns an invalid kind because it is invalid to write:
var name unknown
func KindGeneric ¶
func KindGeneric[T dtype.GoDataType]() Kind
KindGeneric returns the kind of a variable from its generic type. If the type is not supported, an invalid type is returned.
type LocalVarStorage ¶
LocalVarStorage is a local variable to which values can be assigned to.
func (*LocalVarStorage) Expr ¶
func (s *LocalVarStorage) Expr() ast.Expr
Expr returns the expression in the AST tree.
func (*LocalVarStorage) NameDef ¶
func (s *LocalVarStorage) NameDef() *ast.Ident
NameDef returns the identifier identifying the storage.
func (*LocalVarStorage) Same ¶ added in v0.3.0
func (s *LocalVarStorage) Same(o Storage) bool
Same returns true if the other storage is this storage.
func (*LocalVarStorage) Source ¶
func (s *LocalVarStorage) Source() ast.Node
Source returns the node in the AST tree.
func (*LocalVarStorage) Type ¶
func (s *LocalVarStorage) Type() Type
Type of the destination of the assignment.
type Macro ¶
Macro is a function that takes a set of IR nodes as an input and returns a new set of IR nodes (or a compiler error). An example of such function is math/graph.Grad. The implementation is opaque to GX.
func (*Macro) Doc ¶
func (s *Macro) Doc() *ast.CommentGroup
Doc returns associated documentation or nil.
func (*Macro) Value ¶
func (s *Macro) Value(x Expr) AssignableExpr
Value returns a reference to the function.
type NamedType ¶
type NamedType struct {
	BaseType[ast.Expr]
	Src        *ast.TypeSpec
	File       *File
	Underlying *TypeValExpr
	Methods []PkgFunc
}
    NamedType defines a new type from an existing type.
func (*NamedType) AssignableTo ¶
AssignableTo reports if the type can be assigned to other.
func (*NamedType) ConvertibleTo ¶
ConvertibleTo reports whether a value of the type can be converted to another (using static type casting).
func (*NamedType) FullName ¶
FullName returns the full name of the type, that is the full package path and the type name.
func (*NamedType) MethodByName ¶
MethodByName returns a method given its name, or nil if not method has that name.
func (*NamedType) Value ¶
func (s *NamedType) Value(x Expr) AssignableExpr
Value assigned to the constant.
type Number ¶
type Number interface {
	Expr
	// contains filtered or unexported methods
}
    Number is a constant defined in the source code to which no concrete type has been assigned.
type NumberCastExpr ¶
NumberCastExpr casts a number to a given type.
func (*NumberCastExpr) Source ¶
func (s *NumberCastExpr) Source() ast.Node
Source returns the node in the AST tree.
func (*NumberCastExpr) String ¶
func (s *NumberCastExpr) String() string
String representation of the number.
func (*NumberCastExpr) Type ¶
func (s *NumberCastExpr) Type() Type
Type returns the type returned by the function call.
type NumberFloat ¶
NumberFloat is a float number for which the type has not been inferred yet.
func (NumberFloat) DefaultType ¶
func (s NumberFloat) DefaultType() Type
DefaultType returns the default type of the number.
func (*NumberFloat) Source ¶
func (s *NumberFloat) Source() ast.Node
Source returns the node in the AST tree.
func (*NumberFloat) String ¶
func (e *NumberFloat) String() string
func (*NumberFloat) Type ¶
func (s *NumberFloat) Type() Type
Type returns the type returned by the function call.
func (*NumberFloat) Zero ¶
func (s *NumberFloat) Zero() AssignableExpr
Zero returns a zero float number.
type NumberInt ¶
NumberInt is an integer number for which the type has not been inferred yet.
func (NumberInt) DefaultType ¶
DefaultType returns the default type of the number.
func (*NumberInt) Zero ¶
func (s *NumberInt) Zero() AssignableExpr
Zero returns a zero float number.
type Package ¶
type Package struct {
	FSet  *token.FileSet
	Files map[string]*File
	Name *ast.Ident
	Path string
	Decls *Declarations
}
    Package is a GX package.
func (*Package) ExportedConsts ¶
ExportedConsts returns the list of exported constants.
func (*Package) ExportedFuncs ¶
ExportedFuncs returns the list of exported functions of a package.
func (*Package) ExportedTypes ¶
ExportedTypes returns the list of exported types of a package.
func (*Package) File ¶
File returns the AST tree given a file name. Return nil if the name does not match any file. If the name is empty, returns the first file (in alphabetical order).
type PackageRef ¶
type PackageRef struct {
	X    *ValueRef
	Decl *ImportDecl
}
    PackageRef is a reference to a package.
type ParenExpr ¶
ParenExpr is a parenthesized expression.
type PkgFunc ¶
type PkgFunc interface {
	StorageWithValue
	Func
	// contains filtered or unexported methods
}
    PkgFunc is a function declared at the package level.
type RangeStmt ¶
type RangeStmt struct {
	Src        *ast.RangeStmt
	Key, Value Storage
	X          AssignableExpr
	Body       *BlockStmt
}
    RangeStmt is a range statement in for loops.
type Rank ¶
type Rank struct {
	Src *ast.ArrayType
	Ax  []AxisLengths
}
    Rank with a known number of axes. The length of some axes may still be unknown.
func (*Rank) AssignableTo ¶
AssignableTo returns true if this rank can be assigned to the destination rank.
func (*Rank) ConvertibleTo ¶
ConvertibleTo returns true if this rank can be converted to the destination rank.
func (*Rank) Equal ¶
Equal returns true if other has the same number of axes and each axis has the same length.
func (*Rank) IsAtomic ¶
IsAtomic returns true if the rank is equals to zero (that is it has no axes).
type RankInfer ¶
RankInfer is a rank determined at compile time (specified using ___ or ...).
func (*RankInfer) AssignableTo ¶
AssignableTo returns true if this rank can be assigned to the destination rank.
func (*RankInfer) Axes ¶
func (r *RankInfer) Axes() []AxisLengths
Axes returns all axis in the rank.
func (*RankInfer) ConvertibleTo ¶
ConvertibleTo returns true if this rank can be converted to the destination rank.
type ReturnStmt ¶
type ReturnStmt struct {
	Src     *ast.ReturnStmt
	Results []Expr
}
    ReturnStmt is a return statement in a function.
func (*ReturnStmt) Source ¶
func (s *ReturnStmt) Source() ast.Node
Source returns the node in the AST tree.
func (*ReturnStmt) String ¶
func (s *ReturnStmt) String() string
type RuntimeValue ¶
type RuntimeValue interface {
	Type() Type
}
    RuntimeValue is a value that only exists at runtime, that is when GX code is being interpreted.
type RuntimeValueExpr ¶
type RuntimeValueExpr interface {
	Expr
	Value(Expr) RuntimeValue
}
    RuntimeValueExpr is an expression representing a runtime value. Such expression will never be present in a compiled package. This type is used by the interpreter to represent a GX value as an expression.
type RuntimeValueExprT ¶
type RuntimeValueExprT[T RuntimeValue] struct { Src ast.Expr Typ Type Val T }
RuntimeValueExprT is a runtime expression specialised for a value type. The Src field can be nil if the value was not computed from an expression in the source code (e.g. a value given as a static value programmatically).
func (*RuntimeValueExprT[T]) String ¶
func (s *RuntimeValueExprT[T]) String() string
String representation of the type.
type SelectorExpr ¶
type SelectorExpr struct {
	Src  *ast.SelectorExpr
	X    Expr
	Stor Storage
}
    SelectorExpr selects a field on a structure.
type SliceLitExpr ¶
type SliceLitExpr struct {
	Src  ast.Expr
	Typ  Type
	Elts []AssignableExpr
}
    SliceLitExpr is a slice literal.
type SliceType ¶
SliceType defines the type for a slice.
func IntIndexSliceType ¶
func IntIndexSliceType() *SliceType
IntIndexSliceType returns a slice of axis lengths type.
func IntLenSliceType ¶
func IntLenSliceType() *SliceType
IntLenSliceType returns a slice of axis lengths type.
func (*SliceType) AssignableTo ¶
AssignableTo reports if the type can be assigned to other.
func (*SliceType) ConvertibleTo ¶
ConvertibleTo reports whether a value of the type can be converted to another (using static type casting).
func (*SliceType) ElementType ¶
ElementType returns the type of an element in that slice.
func (*SliceType) Value ¶
func (s *SliceType) Value(x Expr) AssignableExpr
Value returns a value pointing to the receiver.
type SlicerType ¶
type SlicerType interface {
	Type
	// ElementType returns the type of an element, that is the type
	// returned by a slice at the top level. For example:
	// float32[2][3][4] returns float32[3][4]
	// If the number of axis is 0, nil is returned.
	ElementType() (Type, bool)
}
    SlicerType is a type supporting slice operations: (e.g. slicerType[i])
type SourceNode ¶
SourceNode is a node with a position in GX source code.
type SpecialisedFunc ¶
SpecialisedFunc is a storage for a function that has been specialised
func (*SpecialisedFunc) NameDef ¶
func (s *SpecialisedFunc) NameDef() *ast.Ident
NameDef returns the identifier identifying the storage.
func (*SpecialisedFunc) Same ¶ added in v0.3.0
func (s *SpecialisedFunc) Same(o Storage) bool
Same returns true if the other storage is this storage.
func (*SpecialisedFunc) Source ¶
func (s *SpecialisedFunc) Source() ast.Node
Source returns the node in the AST tree.
func (*SpecialisedFunc) Type ¶
func (s *SpecialisedFunc) Type() Type
Type of the destination of the assignment.
func (*SpecialisedFunc) Value ¶
func (s *SpecialisedFunc) Value(x Expr) AssignableExpr
Value returns the function as a value.
type Stmt ¶
type Stmt interface {
	SourceNode
	String() string
	// contains filtered or unexported methods
}
    Stmt is a statement that performs an action. No value is being returned.
type Storage ¶
type Storage interface {
	SourceNode
	NameDef() *ast.Ident
	Same(Storage) bool
	Type() Type
	// contains filtered or unexported methods
}
    Storage is a node that can store a value. (e.g. a field in a function)
type StorageWithValue ¶
type StorageWithValue interface {
	Storage
	// Value returns the value stored given the expression pointing to the storage.
	Value(Expr) AssignableExpr
	// contains filtered or unexported methods
}
    StorageWithValue is a storage to which a value has been assigned to. (e.g. a variable that has been defined)
func BuiltinStorage ¶
func BuiltinStorage(name string, val AssignableExpr) StorageWithValue
BuiltinStorage stores a value in a builtin storage.
func FalseStorage ¶
func FalseStorage() StorageWithValue
FalseStorage returns the storage for the value of true.
func TrueStorage ¶
func TrueStorage() StorageWithValue
TrueStorage returns the storage for the value of true.
type StringLiteral ¶
StringLiteral is a string defined by a literal.
func (*StringLiteral) Expr ¶
func (s *StringLiteral) Expr() ast.Expr
Expr returns the AST expression.
func (*StringLiteral) Source ¶
func (s *StringLiteral) Source() ast.Node
Source returns the node in the AST tree.
func (*StringLiteral) String ¶
func (s *StringLiteral) String() string
String representation of the number.
func (*StringLiteral) Type ¶
func (s *StringLiteral) Type() Type
Type returns the type returned by the function call.
type StructFieldStorage ¶
type StructFieldStorage struct {
	Sel *SelectorExpr
}
    StructFieldStorage is a field in a structure.
func (*StructFieldStorage) Expr ¶
func (s *StructFieldStorage) Expr() ast.Expr
Expr returns the expression in the AST tree.
func (*StructFieldStorage) NameDef ¶
func (s *StructFieldStorage) NameDef() *ast.Ident
NameDef returns the identifier identifying the storage.
func (*StructFieldStorage) Same ¶ added in v0.3.0
func (s *StructFieldStorage) Same(o Storage) bool
Same returns true if the other storage is this storage.
func (*StructFieldStorage) Source ¶
func (s *StructFieldStorage) Source() ast.Node
Source returns the node in the AST tree.
func (*StructFieldStorage) Type ¶
func (s *StructFieldStorage) Type() Type
Type of the destination of the assignment.
type StructLitExpr ¶
type StructLitExpr struct {
	Src  *ast.CompositeLit
	Elts []*FieldLit
	Typ  Type
}
    StructLitExpr is a structure literal.
type StructType ¶
type StructType struct {
	BaseType[*ast.StructType]
	Fields *FieldList
}
    StructType defines the type of a structure.
func (*StructType) AssignableTo ¶
func (s *StructType) AssignableTo(fetcher Fetcher, target Type) (bool, error)
AssignableTo reports if the type can be assigned to other.
func (*StructType) ConvertibleTo ¶
func (s *StructType) ConvertibleTo(fetcher Fetcher, target Type) (bool, error)
ConvertibleTo reports whether a value of the type can be converted to another (using static type casting).
func (*StructType) Equal ¶
func (s *StructType) Equal(_ Fetcher, other Type) (bool, error)
Equal returns true if other is the same type.
func (*StructType) NumFields ¶
func (s *StructType) NumFields() int
NumFields returns the number of fields in a structure.
func (*StructType) Source ¶
func (s *StructType) Source() ast.Node
Source returns the node in the AST tree.
func (*StructType) Value ¶
func (s *StructType) Value(x Expr) AssignableExpr
Value returns a value pointing to the receiver.
type TupleType ¶
TupleType is the type of the result of a function that returns more than one value.
func (*TupleType) AssignableTo ¶
AssignableTo reports whether a value of the type can be assigned to another.
func (*TupleType) ConvertibleTo ¶
ConvertibleTo reports whether a value of the type can be converted to another (using static type casting). Always returns false.
func (*TupleType) Value ¶
func (s *TupleType) Value(x Expr) AssignableExpr
Value returns a value pointing to the receiver.
type Type ¶
type Type interface {
	StorageWithValue
	// Kind of the type.
	Kind() Kind
	// Equal returns true if other is the same type.
	Equal(Fetcher, Type) (bool, error)
	// AssignableTo reports whether a value of the type can be assigned to another.
	AssignableTo(Fetcher, Type) (bool, error)
	// ConvertibleTo reports whether a value of the type can be converted to another
	// (using static type casting).
	ConvertibleTo(Fetcher, Type) (bool, error)
	// String representation of the type.
	String() string
}
    Type of a value.
func AtomicFromString ¶
AtomicFromString returns a scalar type singleton from a string.
func DefaultNumberType ¶
DefaultNumberType returns the default GX type for a number.
func IntIndexType ¶
func IntIndexType() Type
IntIndexType returns the type for intidx, that is the length of an axis.
func IntLenType ¶
func IntLenType() Type
IntLenType returns the type for intlen, that is the length of an axis.
func InvalidType ¶
func InvalidType() Type
InvalidType returns an invalid type. Often used as a placeholder when an error occurred.
func NumberFloatType ¶
func NumberFloatType() Type
NumberFloatType returns the type for a float number.
func NumberIntType ¶
func NumberIntType() Type
NumberIntType returns the type for an integer number.
type TypeAssertExpr ¶
type TypeAssertExpr struct {
	Src *ast.TypeAssertExpr
	Typ Type
	X Expr
}
    TypeAssertExpr casts a type to another while disabling compiler checks on array dimensions. Dimension checks are postponed from compilation time to run time.
func (*TypeAssertExpr) Orig ¶
func (s *TypeAssertExpr) Orig() Expr
Orig returns the expression being casted.
type TypeCastExpr ¶
type TypeCastExpr interface {
	AssignableExpr
	Orig() Expr
}
    TypeCastExpr is an abstract type conversion.
type TypeParam ¶
TypeParam is a type mapping to a field name in a function type parameters.
func (*TypeParam) AssignableTo ¶
AssignableTo reports whether a value of the type can be assigned to another.
func (*TypeParam) ConvertibleTo ¶
ConvertibleTo reports whether a value of the type can be converted to another (using static type casting).
func (*TypeParam) Value ¶
func (s *TypeParam) Value(x Expr) AssignableExpr
Value returns a value pointing to the receiver.
type TypeParamValue ¶
TypeParamValue assigns a type to a field of a more generic type.
type TypeSet ¶
type TypeSet struct {
	BaseType[*ast.InterfaceType]
	Typs []Type
}
    TypeSet represents a set of types.
func (*TypeSet) ArrayType ¶
ArrayType returns the source code defining the type. Always returns nil.
func (*TypeSet) AssignableTo ¶
AssignableTo reports whether a value of the type can be assigned to another.
func (*TypeSet) ConvertibleTo ¶
ConvertibleTo reports whether a value of the type can be converted to another (using static type casting).
func (*TypeSet) ElementType ¶
ElementType returns the type of an element.
func (*TypeSet) Value ¶
func (s *TypeSet) Value(x Expr) AssignableExpr
Value returns a value pointing to the receiver.
func (*TypeSet) Zero ¶
func (s *TypeSet) Zero() AssignableExpr
Zero returns a zero expression of the same type.
type TypeValExpr ¶
TypeValExpr is an expression pointing to a type.
func AtomTypeExpr ¶
func AtomTypeExpr(typ Type) *TypeValExpr
AtomTypeExpr returns a type expression for an atomic type.
type UnaryExpr ¶
type UnaryExpr struct {
	Src *ast.UnaryExpr
	X   AssignableExpr
}
    UnaryExpr is an operator with a single argument.
type Value ¶
type Value interface {
	SourceNode
	Type() Type
}
    Value is a value used by the compiler. It can be any thing with a type (package, constant, ...). This is a superset of AssignableExpr.
type ValueRef ¶
ValueRef is a reference to a value.
type VarExpr ¶
VarExpr is a name,expr static variable pair.
type Zeroer ¶
type Zeroer interface {
	Type
	Zero() AssignableExpr
}
    Zeroer is a type able to create a zero value of the type as an expression.
       Source Files
      ¶
      Source Files
      ¶
    
  
       Directories
      ¶
      Directories
      ¶
    
    | Path | Synopsis | 
|---|---|
| Package generics provides functions to handle generics with the GX IR. | Package generics provides functions to handle generics with the GX IR. | 
| Package irhelper provides helper functions to build IR programmatically. | Package irhelper provides helper functions to build IR programmatically. | 
| Package irstring builds a string representation of an IR tree. | Package irstring builds a string representation of an IR tree. |