engine

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package engine compiles model AST programs into flat bytecode and executes them against a host-provided PHP semantics bridge.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(program *Program, host Host) (err error)

Run executes a previously validated flat instruction stream.

Types

type Entry

type Entry struct {
	Key   any
	Value any
}

Entry is one key/value pair produced for foreach.

type Host

type Host interface {
	Construct(string, []any) (any, error)
	CallMethod(any, string, []any) (any, error)
	Call(string, string, []any) (any, error)
	GetProperty(any, string) any
	Lookup(string) any
	Array([]model.ArrayItemValue) any
	Index(any, any) any
	SetIndex(any, any, any, bool, string) error
	Binary(string, any, any) (any, error)
	Unary(string, any) (any, error)
	Truthy(any) bool
	Entries(any) []Entry
	Echo(any) error
}

Host owns PHP value semantics and the Go API bridge. The engine itself owns only compilation, operand/local storage, jumps, and iteration state.

type Program

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

Program is immutable bytecode compiled from a complete model.Program.

func Compile

func Compile(ast *model.Program) (program *Program, err error)

Compile validates and lowers the entire AST before execution can cause side effects. Any unsupported nested node rejects the whole program.

Jump to

Keyboard shortcuts

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