cpevelements

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package cpevelements provides elements for the interpreter for compeval.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewArray

NewArray returns a new array from a code position and a type.

func NewFunc

func NewFunc(fn ir.Func, recv *elements.Receiver) elements.Func

NewFunc creates a new function given its definition and a receiver.

func NewMacro

func NewMacro(fn *ir.Macro, recv *elements.Receiver) elements.Func

NewMacro creates a new macro given its definition and a receiver.

func NewRuntimeValue

func NewRuntimeValue(ctx evaluator.Context, src ir.AssignableExpr) (elements.Element, error)

NewRuntimeValue creates a new runtime value given an expression in a file.

func NewVariable

func NewVariable(src elements.StorageAt) elements.Element

NewVariable returns a new variable element given a GX variable name.

Types

type Element

type Element interface {
	elements.NumericalElement
	canonical.Comparable
	fmt.Stringer

	// CanonicalExpr returns the canonical expression used for comparison.
	CanonicalExpr() canonical.Canonical
}

Element returned after an evaluation at compeval.

func NewAtom

func NewAtom(src elements.ExprAt, val *values.HostArray) (Element, error)

NewAtom returns a new atom element given a GX atom value.

type IRArrayElement

type IRArrayElement interface {
	Axes(ir.Fetcher) (*elements.Slice, error)
}

IRArrayElement is an array with a IR representation of its axes.

type Macro

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

Macro is a macro function to build synthetic functions.

func (*Macro) Call

func (f *Macro) Call(fctx elements.FileContext, call *ir.CallExpr, args []elements.Element) ([]elements.Element, error)

Call the macro to build the synthetic element.

func (*Macro) Flatten

func (f *Macro) Flatten() ([]elements.Element, error)

Flatten the macro.

func (*Macro) Func

func (f *Macro) Func() ir.Func

Func returns the macro function.

func (*Macro) Kind

func (f *Macro) Kind() ir.Kind

Kind returns the function kind.

func (*Macro) Recv

func (f *Macro) Recv() *elements.Receiver

Recv returns the receiver of the macro function.

func (*Macro) Unflatten

func (f *Macro) Unflatten(handles *elements.Unflattener) (values.Value, error)

Unflatten the macro.

type MacroImpl

type MacroImpl func(call elements.CallAt, fn *Macro, args []elements.Element) (*SyntheticFunc, error)

MacroImpl is a builtin opaque function to produce an IR.

type SyntheticBuilder

type SyntheticBuilder interface {
	BuildType() (*ir.FuncType, error)
	BuildBody(ir.Fetcher) (*ir.BlockStmt, []*SyntheticFuncDecl, bool)
}

SyntheticBuilder builds a synthetic function.

type SyntheticFunc

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

SyntheticFunc is a GX string.

func NewSyntheticFunc

func NewSyntheticFunc(builder SyntheticBuilder) *SyntheticFunc

NewSyntheticFunc returns a state element storing a string GX value.

func (*SyntheticFunc) Builder

func (n *SyntheticFunc) Builder() SyntheticBuilder

Builder returns the builder responsible for building the synthetic function.

func (*SyntheticFunc) Flatten

func (n *SyntheticFunc) Flatten() ([]elements.Element, error)

Flatten returns the element in a slice of elements.

func (*SyntheticFunc) Kind

func (*SyntheticFunc) Kind() ir.Kind

Kind of the element.

func (*SyntheticFunc) Unflatten

func (n *SyntheticFunc) Unflatten(handles *elements.Unflattener) (values.Value, error)

Unflatten consumes the next handles to return a GX value.

type SyntheticFuncDecl added in v0.2.0

type SyntheticFuncDecl struct {
	*SyntheticFunc
	F *ir.FuncDecl
}

SyntheticFuncDecl is a synthetic package function declaration.

Jump to

Keyboard shortcuts

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