Documentation
¶
Overview ¶
Package elements provides generic elements, independent of the evaluator, for the interpreter.
Index ¶
- func AxesFromElement(el ir.Element) ([]int, error)
- func ConstantFromElement(el ir.Element) *values.HostArray
- func ConstantIntFromElement(el ir.Element) (val int, err error)
- func ConstantScalarFromElement[T dtype.GoDataType](el ir.Element) (val T, err error)
- func StringFromElement(el ir.Element) (string, error)
- type CallAt
- type ElementWithArrayFromContext
- type ElementWithConstant
- type ExprAt
- type FieldAt
- type InputElements
- type NodeAt
- type NodeFile
- func (ea NodeFile[T]) ExprSrc() ast.Expr
- func (ea NodeFile[T]) FSet() *token.FileSet
- func (ea NodeFile[T]) File() *ir.File
- func (ea NodeFile[T]) Node() T
- func (ea NodeFile[T]) NodeFile() NodeFile[ir.Node]
- func (ea NodeFile[T]) String() string
- func (ea NodeFile[T]) ToExprAt() ExprAt
- func (ea NodeFile[T]) ToNodeAt() NodeAt
- func (ea NodeFile[T]) ToValueAt() ValueAt
- type PackageVarSetElement
- type SelectAt
- type StorageAt
- type String
- type ValueAt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AxesFromElement ¶
AxesFromElement returns a shape from a state element. An error is returned if a concrete shape cannot be returned.
func ConstantFromElement ¶
ConstantFromElement returns the host value represented by an element. The function returns (nil, nil) if the element does not host a numerical value.
func ConstantIntFromElement ¶
ConstantIntFromElement returns a scalar on a host given an element.
func ConstantScalarFromElement ¶
func ConstantScalarFromElement[T dtype.GoDataType](el ir.Element) (val T, err error)
ConstantScalarFromElement returns a scalar on a host given an element.
Types ¶
type ElementWithArrayFromContext ¶
type ElementWithArrayFromContext interface {
evaluator.NumericalElement
// ArrayFromContext fetches an array from the argument.
ArrayFromContext(*values.FuncInputs) (values.Array, error)
}
ElementWithArrayFromContext is an element able to return a concrete value from the current context. For example, a value passed as an argument to the function.
type ElementWithConstant ¶
type ElementWithConstant interface {
evaluator.NumericalElement
// NumericalConstant returns the value of a constant represented by a node.
NumericalConstant() *values.HostArray
}
ElementWithConstant is an element with a concrete value that is already known.
type InputElements ¶
type InputElements struct {
// Values are the initial input GX values passed to the function call
// before they were encapsulated in elements for the interpreter.
Values values.FuncInputs
// Receiver on which the function call was done.
// Can be nil.
Receiver ir.Element
// Args returns list of arguments passed to the interpreter at call time.
Args []ir.Element
}
InputElements is the receiver and arguments with which the function was called.
type NodeFile ¶
NodeFile is an expression with the file in which it is declared.
func (NodeFile[T]) ToExprAt ¶
func (ea NodeFile[T]) ToExprAt() ExprAt
ToExprAt converts a type position into a generic node position.
type PackageVarSetElement ¶
type PackageVarSetElement struct {
// Pck is the package owning the variable.
Pkg string
// Index of the variable in the package definition.
Var string
// Value of the static variable for the compiler.
Value ir.Element
}
PackageVarSetElement is an option to set a package variable to an element.
func (PackageVarSetElement) Package ¶
func (p PackageVarSetElement) Package() string
Package for which the option has been built.
type SelectAt ¶
type SelectAt = NodeFile[*ir.SelectorExpr]
SelectAt is a typed field at a given position.
type String ¶
type String struct {
// contains filtered or unexported fields
}
String is a GX string.
func NewString ¶
func NewString(str *ir.StringLiteral) (*String, error)
NewString returns a state element storing a string GX value.
func (*String) StringValue ¶
StringValue returns the string value as a GX value.