interp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Overview

Package interp evaluates GX code given an evaluator.

All values in the interpreter are represented in elements. The GX Context evaluates GX code represented as an intermediate representation (IR) tree (see github.com/gx-org/gx/build/ir), evaluates a function given a receiver and arguments passed as interpreter elements.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvalExprInContext

func EvalExprInContext(ctx evaluator.Context, expr ir.Expr) (elements.Element, error)

EvalExprInContext uses an evaluator to evaluation an IR expression.

func EvalFunc

func EvalFunc(eval evaluator.Evaluator, fn *ir.FuncDecl, in *elements.InputElements, options []options.PackageOption) (outs []elements.Element, err error)

EvalFunc evaluates a function.

func NewRunFunc

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

NewRunFunc creates a function given an IR and a receiver. The function is run when being called.

func ToSingleElement

func ToSingleElement(ctx elements.FileContext, node ir.SourceNode, els []elements.Element) (elements.Element, error)

ToSingleElement packs multiple elements into a tuple. If the slice els contains only one element, this element is returned.

Types

type EvalContext

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

EvalContext returns the context for the interpreter.

func NewInterpContext

func NewInterpContext(eval evaluator.Evaluator, options []options.PackageOption) (*EvalContext, error)

NewInterpContext returns a new interpreter context.

func (*EvalContext) Evaluator

func (eval *EvalContext) Evaluator() evaluator.Evaluator

Evaluator returns the evaluator used by in evaluations.

func (*EvalContext) NewFileContext

func (eval *EvalContext) NewFileContext(file *ir.File) (evaluator.Context, error)

NewFileContext returns a context for a given file.

type FuncBuiltin

type FuncBuiltin func(ctx evaluator.Context, call elements.CallAt, fn elements.Func, irFunc *ir.FuncBuiltin, args []elements.Element) ([]elements.Element, error)

FuncBuiltin of a builtin function by a backend.

Directories

Path Synopsis
Package elements provides generic elements, independent of the evaluator, for the interpreter.
Package elements provides generic elements, independent of the evaluator, for the interpreter.
Package evaluator defines interfaces for the interpreter to use to evaluate GX code.
Package evaluator defines interfaces for the interpreter to use to evaluate GX code.
Package grapheval implements the evaluation of core GX functions.
Package grapheval implements the evaluation of core GX functions.
Package numbers implement elements representing numbers for the interpreter.
Package numbers implement elements representing numbers for the interpreter.
Package proxies provides proxy for all GX values.
Package proxies provides proxy for all GX values.

Jump to

Keyboard shortcuts

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