mvmhost

package
v0.0.0-...-820128f Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package mvmhost provides a narrow adapter around the MVM interpreter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bindings

type Bindings map[string]map[string]any

Bindings maps an import path to the Go values available to interpreted code.

type ErrorKind

type ErrorKind string

ErrorKind classifies an evaluation failure.

const (
	ErrorKindCompile     ErrorKind = "compile"
	ErrorKindRuntime     ErrorKind = "runtime"
	ErrorKindPanic       ErrorKind = "panic"
	ErrorKindExit        ErrorKind = "exit"
	ErrorKindCanceled    ErrorKind = "canceled"
	ErrorKindSourceLimit ErrorKind = "source_limit"
	ErrorKindOutputLimit ErrorKind = "output_limit"
)

Evaluation error kinds exposed by the host boundary.

type EvalError

type EvalError struct {
	Err      error
	Kind     ErrorKind
	ExitCode int
}

EvalError is a normalized MVM evaluation error.

func (*EvalError) Error

func (e *EvalError) Error() string

func (*EvalError) Unwrap

func (e *EvalError) Unwrap() error

type Evaluator

type Evaluator struct{}

Evaluator executes source using a fresh interpreter for every call.

func New

func New() *Evaluator

New creates an MVM evaluator.

func (*Evaluator) Eval

func (e *Evaluator) Eval(ctx context.Context, request Request) (Result, error)

Eval evaluates source synchronously. MVM v0.5.0 cannot interrupt arbitrary bytecode, so the context is checked before evaluation and by host bindings; untrusted source must invoke this adapter in a killable helper process.

type Request

type Request struct {
	Bindings Bindings
	Name     string
	Source   string
}

Request describes one isolated MVM evaluation.

type Result

type Result struct {
	Value     any
	ValueKind string
	Stdout    string
	Stderr    string
}

Result contains the evaluated value and separately captured diagnostics.

Jump to

Keyboard shortcuts

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