luau

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package luau provides debug functionality for Lua scripts.

Package luau provides filter definitions in TOML format.

Package luau provides a stub implementation when Lua is not available. Set build tag 'lua' to enable full Lua support with gopher-lua.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDebugOutput

func FormatDebugOutput(info *DebugInfo) string

FormatDebugOutput formats debug info for display.

Types

type DebugError

type DebugError struct {
	Line    int
	Column  int
	Message string
}

DebugError represents a debug error.

type DebugInfo

type DebugInfo struct {
	Script        string
	Input         string
	Output        string
	ExecutionTime time.Duration
	MemoryUsed    int
	Instructions  int
	Errors        []DebugError
	LineNumbers   map[int]int // line -> execution count
}

DebugInfo contains debugging information.

type Debugger

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

Debugger provides debugging capabilities.

func NewDebugger

func NewDebugger() *Debugger

NewDebugger creates a new debugger.

func (*Debugger) ClearBreakpoint

func (d *Debugger) ClearBreakpoint(line int)

ClearBreakpoint clears a breakpoint.

func (*Debugger) Disable

func (d *Debugger) Disable()

Disable disables debugging.

func (*Debugger) Enable

func (d *Debugger) Enable()

Enable enables debugging.

func (*Debugger) SetBreakpoint

func (d *Debugger) SetBreakpoint(line int)

SetBreakpoint sets a breakpoint at a line.

func (*Debugger) SetTrace

func (d *Debugger) SetTrace(enabled bool)

SetTrace enables/disables tracing.

func (*Debugger) TraceExecution

func (d *Debugger) TraceExecution(vm *VM, script string, input string) (*DebugInfo, error)

TraceExecution traces script execution.

type FilterAPI

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

FilterAPI provides functions callable from filters.

type FilterDef

type FilterDef struct {
	Name        string                 `toml:"name"`
	Description string                 `toml:"description"`
	Version     string                 `toml:"version"`
	Author      string                 `toml:"author"`
	Script      string                 `toml:"script"`
	ScriptFile  string                 `toml:"script_file"`
	EntryPoint  string                 `toml:"entry_point"`
	Config      map[string]interface{} `toml:"config"`
	Enabled     bool                   `toml:"enabled"`
	Priority    int                    `toml:"priority"`
	Tags        []string               `toml:"tags"`
}

FilterDef represents a filter definition from TOML.

type FilterRegistry

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

FilterRegistry manages loaded filters.

func NewFilterRegistry

func NewFilterRegistry(vmPool *Pool) *FilterRegistry

NewFilterRegistry creates a new filter registry.

func (*FilterRegistry) Apply

func (r *FilterRegistry) Apply(name string, content string) (string, error)

Apply applies a filter to content.

func (*FilterRegistry) ApplyAll

func (r *FilterRegistry) ApplyAll(content string) (string, error)

ApplyAll applies all enabled filters in priority order.

func (*FilterRegistry) Get

func (r *FilterRegistry) Get(name string) (*FilterDef, bool)

Get gets a filter by name.

func (*FilterRegistry) List

func (r *FilterRegistry) List() []string

List returns all filter names.

func (*FilterRegistry) LoadFromDir

func (r *FilterRegistry) LoadFromDir(dir string) ([]*FilterDef, error)

LoadFromDir loads all filters from a directory.

func (*FilterRegistry) LoadFromFile

func (r *FilterRegistry) LoadFromFile(path string) (*FilterDef, error)

LoadFromFile loads a filter from a TOML file.

type Hotspot

type Hotspot struct {
	Line  int
	Code  string
	Time  time.Duration
	Calls int
}

Hotspot represents a performance hotspot.

type Pool

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

Pool provides a pool of reusable VMs.

func NewPool

func NewPool(size int) *Pool

NewPool creates a new VM pool.

func (*Pool) Close

func (p *Pool) Close()

Close closes all VMs in the pool.

func (*Pool) Get

func (p *Pool) Get() *VM

Get gets a VM from the pool.

func (*Pool) Put

func (p *Pool) Put(vm *VM)

Put returns a VM to the pool.

type ProfileResult

type ProfileResult struct {
	TotalTime  time.Duration
	AvgTime    time.Duration
	Calls      int
	MemoryPeak int
	Hotspots   []Hotspot
}

ProfileResult contains profiling results.

func Profile

func Profile(vm *VM, script string, iterations int) (*ProfileResult, error)

Profile profiles script execution.

type Sandbox

type Sandbox struct {
	MaxMemory       int
	MaxInstructions int
}

Sandbox provides security restrictions.

type VM

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

VM provides a Lua-like virtual machine (stub implementation).

func NewVM

func NewVM() *VM

NewVM creates a new VM (stub).

func (*VM) Close

func (vm *VM) Close()

Close closes the VM.

func (*VM) ExecuteFilter

func (vm *VM) ExecuteFilter(script string, content string) (string, error)

ExecuteFilter runs a filter script on content (stub - uses Go regex).

func (*VM) LoadFilter

func (vm *VM) LoadFilter(name, script string) error

LoadFilter loads a filter from a string.

func (*VM) RunFilter

func (vm *VM) RunFilter(name string, content string) (string, error)

RunFilter runs a loaded filter.

type ValidationIssue

type ValidationIssue struct {
	Line     int
	Severity string // error, warning, info
	Message  string
}

ValidationIssue represents a validation issue.

func ValidateScript

func ValidateScript(script string) []ValidationIssue

ValidateScript checks a script for common issues.

Jump to

Keyboard shortcuts

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