builtins

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package builtins provides helper functions for builtins functions.

Index

Constants

This section is empty.

Variables

View Source
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 Fields

func Fields(expr ir.Expr, types ...ir.Type) *ir.FieldList

Fields returns a list of fields to specify parameters or results.

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

func NarrowType[T ir.Type](fetcher ir.Fetcher, call *ir.CallExpr, arg ir.Type) (t T, err error)

NarrowType converts an abstract type into more concrete type, typically *github.com/gx-org/gx/build/ir.ArrayType.

func NarrowTypes

func NarrowTypes[T ir.Type](fetcher ir.Fetcher, call *ir.CallExpr, args []ir.Type) ([]T, error)

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.

func UniqueAxesFromExpr

func UniqueAxesFromExpr(fetcher ir.Fetcher, expr ir.Expr) (map[int]struct{}, error)

UniqueAxesFromExpr returns the set of unique axis indices found in a slice literal.

Types

This section is empty.

Jump to

Keyboard shortcuts

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