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 ¶
- func EvalExprInContext(ctx evaluator.Context, expr ir.Expr) (elements.Element, error)
- func EvalFunc(eval evaluator.Evaluator, fn *ir.FuncDecl, in *elements.InputElements, ...) (outs []elements.Element, err error)
- func NewRunFunc(fn ir.Func, recv *elements.Receiver) elements.Func
- func ToSingleElement(ctx elements.FileContext, node ir.SourceNode, els []elements.Element) (elements.Element, error)
- type EvalContext
- type FuncBuiltin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvalExprInContext ¶
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 ¶
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 ¶
NewFileContext returns a context for a given file.
Source Files
¶
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. |