cpevelements

package
v0.6.1 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: 19 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

func NewArray(typ ir.ArrayType) evaluator.NumericalElement

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

func NewFunc

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

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

func NewMacro

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

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

func NewRuntimeValue

func NewRuntimeValue(file *ir.File, newFunc interp.NewFunc, store ir.Storage) (ir.Element, error)

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

func NewVariable

func NewVariable(src elements.StorageAt) ir.Element

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

Types

type Element

type Element interface {
	evaluator.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 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 *interp.FileScope, call *ir.CallExpr, args []ir.Element) ([]ir.Element, error)

Call the macro to build the synthetic element.

func (*Macro) Func

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

Func returns the macro function.

func (*Macro) Recv

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

Recv returns the receiver of the macro function.

func (*Macro) Type added in v0.3.0

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

Type returns the type of the function.

type MacroImpl

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

MacroImpl is a builtin opaque function to produce an IR.

type SyntheticBuilder

type SyntheticBuilder interface {
	BuildType() (*ast.FuncDecl, error)
	BuildBody(ir.Fetcher) (*ast.BlockStmt, []*SyntheticFuncDecl, bool)
	BuildIR(fmterr.ErrAppender, *ast.FuncDecl, *ir.File, *ir.FuncType) (ir.PkgFunc, 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) Type added in v0.3.0

func (n *SyntheticFunc) Type() ir.Type

Type of the element.

type SyntheticFuncDecl added in v0.2.0

type SyntheticFuncDecl struct {
	*SyntheticFunc
	F *ast.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