Documentation
¶
Overview ¶
Package builtins provides helper functions for builtins functions.
Index ¶
- Variables
- func BuildFuncParams(fetcher ir.Fetcher, call *ir.CallExpr, name string, sig []ir.Type) ([]ir.Type, error)
- func Fields(expr ir.Expr, types ...ir.Type) *ir.FieldList
- func InferFromNumericalType(fetcher ir.Fetcher, call *ir.CallExpr, argNum int, numberTarget ir.Type) (ir.Type, ir.Type, error)
- func NarrowType[T ir.Type](fetcher ir.Fetcher, call *ir.CallExpr, arg ir.Type) (t T, err error)
- func NarrowTypes[T ir.Type](fetcher ir.Fetcher, call *ir.CallExpr, args []ir.Type) ([]T, error)
- func ToBinaryExpr(op token.Token, x, y ir.AssignableExpr) *ir.BinaryExpr
- func UniqueAxesFromExpr(fetcher ir.Fetcher, expr ir.Expr) (map[int]struct{}, error)
Constants ¶
This section is empty.
Variables ¶
var ( // GenericArrayType returns a generic array type. GenericArrayType = ir.NewArrayType(&ast.ArrayType{}, ir.TypeFromKind(ir.UnknownKind), &ir.RankInfer{}) // GenericSliceType returns a generic slice type. GenericSliceType = &ir.SliceType{} // PositionsType returns a type for a slice of indices. PositionsType = ir.NewArrayType( &ast.ArrayType{}, ir.DefaultIntType, &ir.RankInfer{}, ) )
Functions ¶
func BuildFuncParams ¶
func BuildFuncParams(fetcher ir.Fetcher, call *ir.CallExpr, name string, sig []ir.Type) ([]ir.Type, error)
BuildFuncParams takes a function call and list of required argument types and returns a list of parameters for the function. Arguments with NumberKind are replaced by the target type. It returns an error if a call's arguments don't match the given signature.
func InferFromNumericalType ¶
func InferFromNumericalType(fetcher ir.Fetcher, call *ir.CallExpr, argNum int, numberTarget ir.Type) (ir.Type, ir.Type, error)
InferFromNumericalType returns an argument type if that argument is numerical.
func NarrowType ¶
NarrowType converts an abstract type into more concrete type, typically *github.com/gx-org/gx/build/ir.ArrayType.
func NarrowTypes ¶
NarrowTypes converts abstract types into more concrete types, typically *ir.ArrayType.
func ToBinaryExpr ¶
func ToBinaryExpr(op token.Token, x, y ir.AssignableExpr) *ir.BinaryExpr
ToBinaryExpr returns a binary expression from two expressions.
Types ¶
This section is empty.