evaluator

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Fset         *token.FileSet
	Scanner      *goscan.Scanner
	Registry     *object.SymbolRegistry
	SpecialForms map[string]*SpecialForm
	Packages     map[string]*object.Package
	Stdin        io.Reader
	Stdout       io.Writer
	Stderr       io.Writer
}

Config holds the configuration for creating a new Evaluator.

type Evaluator

type Evaluator struct {
	object.BuiltinContext
	// contains filtered or unexported fields
}

Evaluator is the main object that evaluates the AST.

func New

func New(cfg Config) *Evaluator

New creates a new Evaluator.

func (*Evaluator) ApplyFunction

func (e *Evaluator) ApplyFunction(call *ast.CallExpr, fn object.Object, args []object.Object, fscope *object.FileScope) object.Object

ApplyFunction is a public wrapper for the internal applyFunction, allowing it to be called from other packages.

func (*Evaluator) Eval

func (e *Evaluator) Eval(node ast.Node, env *object.Environment, fscope *object.FileScope) object.Object

func (*Evaluator) EvalToplevel

func (e *Evaluator) EvalToplevel(decls []object.DeclWithScope, env *object.Environment) object.Object

EvalToplevel orchestrates the two-pass evaluation for a set of declarations from one or more files.

func (*Evaluator) Scanner

func (e *Evaluator) Scanner() *goscan.Scanner

Scanner returns the underlying goscan.Scanner instance.

func (*Evaluator) WrapGoFunction

func (e *Evaluator) WrapGoFunction(pos token.Pos, funcVal reflect.Value) object.Object

WrapGoFunction is a public method to wrap a native Go function into a minigo object.

type SpecialForm

type SpecialForm struct {
	Fn SpecialFormFunction
}

SpecialForm represents a special form function.

func (*SpecialForm) Inspect

func (sf *SpecialForm) Inspect() string

Inspect returns a string representation of the special form function.

func (*SpecialForm) Type

func (sf *SpecialForm) Type() object.ObjectType

Type returns the type of the SpecialForm object.

type SpecialFormFunction

type SpecialFormFunction func(e *Evaluator, fscope *object.FileScope, pos token.Pos, args []ast.Expr) object.Object

SpecialFormFunction is the signature for special form functions.

Jump to

Keyboard shortcuts

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