vm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLimits = VMLimits{
	MaxInstructions: 100000,
	MaxMemoryBytes:  67108864,
	MaxCallDepth:    128,
}

Functions

func BcBinop

func BcBinop(op string, a, b any) any

func BcConvert

func BcConvert(target string, a any) any

func BcSliceToAny

func BcSliceToAny(strs []string) []any

func BcToBool

func BcToBool(v any) bool

func BcValuesEqual

func BcValuesEqual(a, b any) bool

func InterpErr

func InterpErr(reason string, node *ast.Node)

func Interpret

func Interpret(ast *ast.Node, args []string, in io.Reader, out io.Writer, errOut io.Writer) (exitCode int)

Interpret executes a cli_app AST directly and returns a process exit code. http_server/web_app roots are rejected with a clear error — Phase 1 is cli_app only, per docs/direct_execution_design.md.

func IsDefun

func IsDefun(node *ast.Node) bool

func NumericBinop

func NumericBinop(op string, a, b any, node *ast.Node) any

func RunBytecode

func RunBytecode(prog *bytecode.BCProgram, cliArgs []string, allowedCaps []capability.Capability, in io.Reader, out io.Writer, errOut io.Writer) (exitCode int)

func RunBytecodeWithPolicy

func RunBytecodeWithPolicy(prog *bytecode.BCProgram, cliArgs []string, policy ExecutionPolicy, allowedCaps []capability.Capability, in io.Reader, out io.Writer, errOut io.Writer) (exitCode int)

RunBytecodeWithPolicy executes bytecode under authority selected by the trusted runner. Capabilities remain an independent grant: increasing a resource limit does not authorize any external effect.

func SliceToAny

func SliceToAny(strs []string) []any

func ToBCFloat

func ToBCFloat(v any) float64

func ToBool

func ToBool(v any, node *ast.Node) bool

func ToFloat

func ToFloat(v any) (float64, bool)

func ToInt

func ToInt(v any) (int64, error)

func ValuesEqual

func ValuesEqual(a, b any) bool

Types

type BCVM

type BCVM struct {
	Limits      VMLimits
	AllowedCaps []capability.Capability
	In          io.Reader
	Out         io.Writer
	ErrOut      io.Writer
	// contains filtered or unexported fields
}

type BcEnv

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

func NewBcEnv

func NewBcEnv(parent *BcEnv) *BcEnv

type ExecutionPolicy

type ExecutionPolicy struct {
	Limits VMLimits
}

ExecutionPolicy is authority supplied by the trusted bytecode runner. It may constrain an application, but application code cannot inspect or widen it. The zero value is fail-closed and permits no instruction execution.

func DefaultExecutionPolicy

func DefaultExecutionPolicy() ExecutionPolicy

DefaultExecutionPolicy returns a copy of the standalone VM's safe defaults.

type InterpEnv

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

func NewInterpEnv

func NewInterpEnv(parent *InterpEnv) *InterpEnv

type InterpFunc

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

type Interpreter

type Interpreter struct {
	In     io.Reader
	Out    io.Writer
	ErrOut io.Writer
	// contains filtered or unexported fields
}

Interpreter holds the global function table for a single -run invocation. defun bodies have no closure over caller scope, matching the Go backend's model where defun compiles to an independent top-level function.

type VMError

type VMError struct {
	Phase       string `json:"phase"`
	Code        string `json:"code"`
	Function    string `json:"function"`
	Instruction int    `json:"instruction"`
	Opcode      string `json:"opcode,omitempty"`
	Message     string `json:"message"`
}

func NewRuntimeError

func NewRuntimeError(code string, fn string, ip int, op bytecode.Opcode, msg string, args ...any) *VMError

func (*VMError) Error

func (e *VMError) Error() string

type VMLimits

type VMLimits struct {
	MaxInstructions int
	MaxMemoryBytes  int
	MaxCallDepth    int
}

type VmExit

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

type VmReturn

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

Jump to

Keyboard shortcuts

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