sim

package module
v0.0.0-...-0fc4dc5 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: BSD-2-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const GlobalNamespace = "--globalnamespace"
View Source
const MAX_EXPORT_RECURSION = 200
View Source
const VERSION = "3.5"

Variables

View Source
var (
	UndefinedValue = Value{Type: Undefined}
	NullValue      = Value{Type: Null}
	TrueValue      = Value{Type: Bool, Internal: true}
	FalseValue     = Value{Type: Bool, Internal: false}
)
View Source
var ErrFunctionNotExist = errors.New("function not found")

Functions

func AddBreakpoint

func AddBreakpoint(file string, line int)

func AddBuiltinField

func AddBuiltinField(name string)

func AddBuiltinFunc

func AddBuiltinFunc(name string)

func AddDebuggerInstance

func AddDebuggerInstance(vm *VM) uint

func AddNativeFunc

func AddNativeFunc(f NativeFunction)

func Continue

func Continue()

func DebugLog

func DebugLog(format string, args ...interface{})

func Eval

func Eval(vm *VM, code string) error

func Fprint

func Fprint(w io.Writer, p *Program)

func FprintConstants

func FprintConstants(w io.Writer, p *Program)

func FprintFunction

func FprintFunction(w io.Writer, prefix string, f *Function, p *Program)

func FprintNames

func FprintNames(w io.Writer, p *Program, registers bool)

func GetDebugServerPort

func GetDebugServerPort() string

func GetDebuggerStats

func GetDebuggerStats() map[string]interface{}

func HandleDebugger

func HandleDebugger(vm *VM)

Lógica principal del debugger mejorada

func HasBreakpoint

func HasBreakpoint(line TraceLine) bool

func IsDebugServerRunning

func IsDebugServerRunning() bool

Funciones de utilidad

func IsDebuggerEnabled

func IsDebuggerEnabled() bool

Funciones de utilidad mejoradas

func ListBreakpoints

func ListBreakpoints() map[string]map[int]struct{}

func NewCompiler

func NewCompiler() *compiler

func Parse

func Parse(fs filesystem.FS, path string) (*ast.Program, error)

func ParseExpr

func ParseExpr(code string) (ast.Expr, error)

func ParseStr

func ParseStr(code string) (*ast.Program, error)

func Pause

func Pause()

Funciones de control mejoradas

func PauseDebuggerAtStart

func PauseDebuggerAtStart(vm *VM)

func Print

func Print(p *Program)

func PrintFunction

func PrintFunction(f *Function, p *Program)

func PrintNames

func PrintNames(p *Program, registers bool)

func RegisterLib

func RegisterLib(funcs []NativeFunction, dts string)

func RemoveBreakpoint

func RemoveBreakpoint(file string, line int)

func RemoveBreakpoints

func RemoveBreakpoints()

func ShutdownDebugger

func ShutdownDebugger()

func Sprint

func Sprint(p *Program) (string, error)

func SprintNames

func SprintNames(p *Program, registers bool) (string, error)

func Stacktrace

func Stacktrace() string

func StartDebugger

func StartDebugger(vm *VM, addr string) error

func SwitchActiveInstance

func SwitchActiveInstance(newInstance *VM)

func TypeDefs

func TypeDefs() string

func UnhandledException

func UnhandledException(vm *VM, err error, exceptionType string)

func UnhandledPanic

func UnhandledPanic(vm *VM, err error)

UnhandledPanic para panics del sistema

func UnhandledRuntimeError

func UnhandledRuntimeError(vm *VM, err error)

UnhandledRuntimeError para errores en tiempo de ejecución

func WaitIfPaused

func WaitIfPaused(vm *VM)

func Wrap

func Wrap(code int, msg string, err error) error

Types

type Address

type Address struct {
	Kind  AddressKind
	Value int32
}

func NewAddress

func NewAddress(kind AddressKind, value int) *Address

func (*Address) Copy

func (a *Address) Copy() *Address

func (*Address) Equal

func (r *Address) Equal(b *Address) bool

func (*Address) String

func (r *Address) String() string

type AddressKind

type AddressKind byte
const (
	AddrVoid AddressKind = iota
	AddrLocal
	AddrGlobal
	AddrConstant
	AddrClosure
	AddrEnum
	AddrFunc
	AddrNativeFunc
	AddrClass
	AddrData
	AddrUnresolved
)

func (AddressKind) String

func (i AddressKind) String() string

type Allocator

type Allocator interface {
	Size() int
}

type ArrayObject

type ArrayObject struct {
	Frozen bool
	Array  []Value
}

func (*ArrayObject) Freeze

func (t *ArrayObject) Freeze()

func (*ArrayObject) IsFrozen

func (t *ArrayObject) IsFrozen() bool

type BreakpointInfo

type BreakpointInfo struct {
	File string `json:"file"`
	Line int    `json:"line"`
}

type Callable

type Callable interface {
	GetMethod(name string) NativeMethod
}

type Class

type Class struct {
	Name       string
	Module     string
	Attributes []string
	Fields     []*Field
	Getters    []int
	Setters    []int
	Functions  []int
	Exported   bool
}

func (*Class) Copy

func (c *Class) Copy() *Class

type ClientConnection

type ClientConnection struct {
	ID         string
	Conn       net.Conn
	Encoder    *json.Encoder
	LastActive time.Time
	// contains filtered or unexported fields
}

ClientConnection representa una conexión de cliente

func NewClientConnection

func NewClientConnection(id string, conn net.Conn) *ClientConnection

func (*ClientConnection) Close

func (cc *ClientConnection) Close() error

func (*ClientConnection) IsActive

func (cc *ClientConnection) IsActive() bool

func (*ClientConnection) Send

func (cc *ClientConnection) Send(data interface{}) error

type Closure

type Closure struct {
	FuncIndex int
	// contains filtered or unexported fields
}

func (*Closure) Export

func (c *Closure) Export(recursionLevel int) interface{}

func (*Closure) Type

func (c *Closure) Type() string

type Comparable

type Comparable interface {
	Compare(Value) int
}

Comparable returns:

-2 if both values are imcompatible for comparisson between each other.
-1 is lesser
 0 is equal
 1 is greater

type CompilerError

type CompilerError struct {
	Pos ast.Position
	// contains filtered or unexported fields
}

func (CompilerError) Error

func (e CompilerError) Error() string

func (CompilerError) ErrorMessage

func (e CompilerError) ErrorMessage() string

func (CompilerError) Position

func (e CompilerError) Position() ast.Position

type DebugServer

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

func NewDebugServer

func NewDebugServer() *DebugServer

type DebugState

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

DebugState centraliza el estado del debugger

func NewDebugState

func NewDebugState() *DebugState

type DebuggerState

type DebuggerState struct {
	TotalVMs     int      `json:"totalVMs"`
	ActiveVM     uint     `json:"activeVM"`
	Paused       bool     `json:"paused"`
	CurrentFile  string   `json:"currentFile"`
	CurrentLine  int      `json:"currentLine"`
	StackDepth   int      `json:"stackDepth"`
	Breakpoints  int      `json:"breakpoints"`
	AvailableVMs []VMInfo `json:"availableVMs"`
	Clients      int      `json:"clients"`
}

type EnumList

type EnumList struct {
	Name     string
	Module   string
	Values   []*EnumValue
	Exported bool
}

func (*EnumList) ValueByName

func (e *EnumList) ValueByName(name string) (*EnumValue, int)

type EnumValue

type EnumValue struct {
	Name   string
	KIndex int
}

type Enumerable

type Enumerable interface {
	Values() ([]Value, error)
}

type Equatable

type Equatable interface {
	Equals(interface{}) bool
}

type ErrorMessenger

type ErrorMessenger interface {
	ErrorMessage() string
}

type ExceptionInfo

type ExceptionInfo struct {
	VM         uint         `json:"vm"`
	Message    string       `json:"message"`
	File       string       `json:"file"`
	Line       int          `json:"line"`
	Function   string       `json:"function"`
	StackTrace []StackFrame `json:"stackTrace"`
	Timestamp  int64        `json:"timestamp"`
	Type       string       `json:"type"` // "runtime_error", "panic", "assertion_failed", etc.
}

type Exporter

type Exporter interface {
	Export(recursionLevel int) interface{}
}

type Field

type Field struct {
	Name     string
	Exported bool
}

type FieldGetter

type FieldGetter interface {
	GetField(string, *VM) (Value, error)
}

type FieldSetter

type FieldSetter interface {
	SetField(string, Value, *VM) error
}

type Finalizable

type Finalizable interface {
	Close() error
}

type Frame

type Frame uintptr

Frame represents a program counter inside a stack frame.

type Freezable

type Freezable interface {
	Freeze()        // Congela el objeto y sus componentes.
	IsFrozen() bool // Devuelve true si el objeto está congelado.
}

Freezable define el comportamiento para objetos que pueden ser congelados.

type Function

type Function struct {
	Name         string
	Module       string
	Attributes   []string
	Positions    []Position
	Instructions []*Instruction
	Closures     []*Register
	Registers    []*Register

	Arguments         int
	OptionalArguments int
	Index             int
	WrapClass         int
	MaxRegIndex       int
	Class             int
	Lambda            bool
	IsGlobal          bool
	IsClass           bool
	Exported          bool
	Variadic          bool
	Kind              FunctionKind
	// contains filtered or unexported fields
}

func (*Function) Copy

func (c *Function) Copy() *Function

func (*Function) HasPermission

func (f *Function) HasPermission(name string) bool

func (*Function) Permissions

func (f *Function) Permissions() []string

type FunctionKind

type FunctionKind byte
const (
	User FunctionKind = iota
	Main
	Global
)

type FunctionStat

type FunctionStat struct {
	Function  string
	TotalTime time.Duration
}

type IndexIterator

type IndexIterator interface {
	IndexerGetter
	Len() int
}

type IndexerGetter

type IndexerGetter interface {
	GetIndex(int) (Value, error)
}

type IndexerSetter

type IndexerSetter interface {
	SetIndex(int, Value) error
}

type Instance

type Instance struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewInstance

func NewInstance(name string, args []Value, vm *VM) (*Instance, error)

func (*Instance) Function

func (i *Instance) Function(name string, p *Program) (*Function, bool)

func (*Instance) GetField

func (i *Instance) GetField(name string, vm *VM) (Value, error)

func (*Instance) PropertyGetter

func (i *Instance) PropertyGetter(name string, p *Program) (*Function, bool)

func (*Instance) PropertySetter

func (i *Instance) PropertySetter(name string, p *Program) (*Function, bool)

func (*Instance) SetField

func (i *Instance) SetField(name string, v Value, vm *VM) error

func (*Instance) String

func (i *Instance) String() string

type Instruction

type Instruction struct {
	A      *Address
	B      *Address
	C      *Address
	Opcode Opcode
}

func NewInstruction

func NewInstruction(op Opcode, a, b, c *Address) *Instruction

func (*Instruction) Copy

func (r *Instruction) Copy() *Instruction

func (*Instruction) Format

func (i *Instruction) Format(padd bool) string

func (*Instruction) String

func (i *Instruction) String() string

type KeyGetter

type KeyGetter interface {
	GetKey(string) (Value, error)
}

type KeyIterator

type KeyIterator interface {
	KeyGetter
	Keys() []string
}

type LineStat

type LineStat struct {
	File      string
	Line      int
	Function  string
	Count     int
	TotalTime time.Duration
}

type LocalVariablesRequest

type LocalVariablesRequest struct {
	FrameId *int `json:"frameId,omitempty"` // Opcional, si no se especifica usa frame actual (0)
}

Nueva estructura para getLocalVariables con frameId

type Localizer

type Localizer interface {
	Format(language, format string, v interface{}, translations *TranslationStore) string
	ParseNumber(v string) (float64, error)
	ParseDate(value, format string, loc *time.Location) (time.Time, error)
}

type LogLevel

type LogLevel int

LogLevel define los niveles de logging

const (
	LogLevelNone LogLevel = iota - 1
	LogLevelError
	LogLevelWarn
	LogLevelInfo
	LogLevelDebug
)

type MapValue

type MapValue struct {
	Frozen bool
	Map    map[Value]Value
	sync.RWMutex
}

func (*MapValue) Freeze

func (t *MapValue) Freeze()

func (*MapValue) IsFrozen

func (t *MapValue) IsFrozen() bool

type Method

type Method struct {
	ThisObject Value
	FuncIndex  int
}

func (*Method) Export

func (*Method) Export(recursionLevel int) interface{}

func (*Method) Type

func (*Method) Type() string

type NamedType

type NamedType interface {
	Type() string
}

type NativeFunction

type NativeFunction struct {
	Function    func(this Value, args []Value, vm *VM) (Value, error)
	Name        string
	Permissions []string
	Arguments   int
	Index       int
}

NativeFunction is a function written in Go as opposed to an interpreted function

func AllNativeFuncs

func AllNativeFuncs() []NativeFunction

func NativeFuncFromIndex

func NativeFuncFromIndex(i int) NativeFunction

func NativeFuncFromName

func NativeFuncFromName(name string) (NativeFunction, bool)

type NativeMethod

type NativeMethod func(args []Value, vm *VM) (Value, error)

func (NativeMethod) Type

func (NativeMethod) Type() string

type NativeObject

type NativeObject interface {
	GetMethod(name string) NativeMethod
	GetField(name string, vm *VM) (Value, error)
	SetField(name string, v Value, vm *VM) error
}

type Notification

type Notification struct {
	Type string      `json:"type"`
	Data interface{} `json:"data"`
}

type Opcode

type Opcode byte

func (Opcode) String

func (i Opcode) String() string

type Position

type Position struct {
	File   int
	Line   int
	Column int
}

func (Position) Copy

func (p Position) Copy() Position

type ProfileEntry

type ProfileEntry struct {
	Count     int
	TotalTime time.Duration
}

type Profiler

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

func NewProfiler

func NewProfiler() *Profiler

func (*Profiler) Enabled

func (p *Profiler) Enabled() bool

func (*Profiler) PrintFunctions

func (p *Profiler) PrintFunctions(n int)

func (*Profiler) PrintLines

func (p *Profiler) PrintLines(n int)

func (*Profiler) ReportFunctions

func (p *Profiler) ReportFunctions(n int) []FunctionStat

func (*Profiler) ReportStats

func (p *Profiler) ReportStats(n int) []LineStat

func (*Profiler) Reset

func (p *Profiler) Reset()

func (*Profiler) Start

func (p *Profiler) Start()

func (*Profiler) Stop

func (p *Profiler) Stop()

func (*Profiler) Trace

func (p *Profiler) Trace(vm *VM, start time.Time)

type Program

type Program struct {
	sync.Mutex
	Resources map[string][]byte

	Attributes []string
	Enums      []*EnumList
	Classes    []*Class
	Files      []string

	Functions []*Function
	Constants []Value
	Name      string
	BasePath  string
	// contains filtered or unexported fields
}

func Compile

func Compile(fs filesystem.FS, path string) (*Program, error)

func CompileStr

func CompileStr(code string) (*Program, error)

func (*Program) AddPermission

func (p *Program) AddPermission(name string)

func (*Program) Attribute

func (p *Program) Attribute(name string) string

func (*Program) AvailableBreakpoints

func (p *Program) AvailableBreakpoints() []string

func (*Program) Copy

func (p *Program) Copy() *Program

func (*Program) FileIndex

func (p *Program) FileIndex(file string) int

func (*Program) Function

func (p *Program) Function(name string) (*Function, bool)

func (*Program) HasPermission

func (p *Program) HasPermission(name string) bool

func (*Program) Permissions

func (p *Program) Permissions() []string

func (*Program) SetAttribute

func (p *Program) SetAttribute(key, value string)

func (*Program) Strip

func (p *Program) Strip()

func (*Program) ToTraceLine

func (p *Program) ToTraceLine(f *Function, pc int) TraceLine

type Register

type Register struct {
	KAddress *Address
	Module   string
	Name     string
	Index    int
	StartPC  int
	EndPC    int
	Exported bool
}

func (*Register) Copy

func (r *Register) Copy() *Register

func (*Register) Equals

func (r *Register) Equals(b *Register) bool

type Request

type Request struct {
	ID      string      `json:"id"`
	Command string      `json:"command"`
	Args    interface{} `json:"args,omitempty"`
}

Estructuras JSON para comunicación

type Response

type Response struct {
	ID      string      `json:"id"`
	Success bool        `json:"success"`
	Data    interface{} `json:"data,omitempty"`
	Error   string      `json:"error,omitempty"`
}

type SafeChannel

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

SafeChannel - Canal que se puede cerrar múltiples veces sin panic

func NewSafeChannel

func NewSafeChannel() *SafeChannel

func (*SafeChannel) Close

func (sc *SafeChannel) Close()

func (*SafeChannel) IsClosed

func (sc *SafeChannel) IsClosed() bool

func (*SafeChannel) Wait

func (sc *SafeChannel) Wait() <-chan struct{}

type StackFrame

type StackFrame struct {
	Index    int    `json:"index"`
	Function string `json:"function"`
	File     string `json:"file"`
	Line     int    `json:"line"`
	VMID     uint   `json:"vmId"`    // NUEVO: ID de la VM que contiene este frame
	VMDepth  int    `json:"vmDepth"` // NUEVO: Profundidad dentro de esa VM específica
}

type StackTrace

type StackTrace []Frame

StackTrace is stack of Frames from innermost (newest) to outermost (oldest).

type StepState

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

StepState maneja el estado del stepping de forma thread-safe

type TraceLine

type TraceLine struct {
	Function string
	File     string
	Line     int
}

func (TraceLine) SameLine

func (p TraceLine) SameLine(o TraceLine) bool

func (TraceLine) SameLineAbs

func (p TraceLine) SameLineAbs(o TraceLine) bool

SameLineAbs convierte ambas rutas a absolutas y compara

func (TraceLine) String

func (p TraceLine) String() string

type TranslationStore

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

TranslationStore manages translations using a parent-child approach for efficient memory usage. Each store has its own translations and an optional parent store for fallback lookups. Parents are read-only to prevent circular references and ensure data integrity.

func NewTranslationStore

func NewTranslationStore() *TranslationStore

NewTranslationStore creates a new empty translation store

func (*TranslationStore) Clear

func (t *TranslationStore) Clear()

Clear removes all local translations (parent remains unchanged)

func (*TranslationStore) Extend

func (t *TranslationStore) Extend() *TranslationStore

Extend creates a new TranslationStore with this store as its parent. The new store inherits all translations from this store but can add/override locally. Changes to the parent store are automatically visible to the child.

func (*TranslationStore) Get

func (t *TranslationStore) Get(lang, key string) string

Get retrieves a translation for a given language and key. First searches in local data, then falls back to parent if not found. Returns empty string if not found in any store.

func (*TranslationStore) GetLanguageData

func (t *TranslationStore) GetLanguageData(lang string) map[string]string

GetLanguageData returns all translations for a language by merging local data with parent chain. Local translations override parent translations. Returns nil if language doesn't exist in any store.

func (*TranslationStore) GetParent

func (t *TranslationStore) GetParent() *TranslationStore

GetParent returns the parent store (for property access)

func (*TranslationStore) HasLanguage

func (t *TranslationStore) HasLanguage(lang string) bool

HasLanguage checks if a language exists in this store or its parent chain

func (*TranslationStore) HasLanguageLayer

func (t *TranslationStore) HasLanguageLayer(lang string) bool

HasLanguage checks if a language exists in this store or its parent chain

func (*TranslationStore) Languages

func (t *TranslationStore) Languages() []string

Languages returns a list of all available languages from this store and its parent chain

func (*TranslationStore) Set

func (t *TranslationStore) Set(lang, key, value string)

Set adds a single translation to the local store

func (*TranslationStore) SetBatch

func (t *TranslationStore) SetBatch(lang string, translations map[string]string)

SetBatch adds multiple translations to the local store

func (*TranslationStore) Translate

func (t *TranslationStore) Translate(lang, text string) string

Translate translates text using the specified language with context stripping support. This is the same logic used by the built-in T() function. Returns the original text if no translation is found.

func (*TranslationStore) TranslateTo

func (t *TranslationStore) TranslateTo(lang, text string) string

TranslateTo translates text to a specific language with context stripping support. This is a convenience method that explicitly specifies the target language.

type Type

type Type int8
const (
	Null Type = iota
	Undefined
	Int
	Float
	Bool
	Bytes
	String
	Array
	Map
	Func
	Enum
	NativeFunc
	Rune
	Object
)

func (Type) String

func (t Type) String() string

type VM

type VM struct {
	ID           uint
	Parent       *VM  // The VM that launched this one. For gorutines and other spawn operations
	Async        bool // if the parent VM launched it in a gorutine
	Context      Value
	Now          time.Time
	RetValue     Value
	Localizer    Localizer
	Translations *TranslationStore // Shared translation store
	Stderr       io.Writer
	Error        error
	FileSystem   filesystem.FS
	Stdout       io.Writer
	Stdin        io.Reader

	Location *time.Location

	Program  *Program
	Language string

	MaxFrames      int
	MaxAllocations int64
	MaxSteps       int64
	StatsEnabled   bool
	Profiler       *Profiler

	// debugger
	PauseAtStart bool
	// contains filtered or unexported fields
}

func NewInitializedVM

func NewInitializedVM(p *Program, globals []Value) *VM

func NewVM

func NewVM(p *Program) *VM

func (*VM) AddAllocations

func (vm *VM) AddAllocations(n int) error

func (*VM) AddSteps

func (vm *VM) AddSteps(n int64) error

func (*VM) Allocations

func (vm *VM) Allocations() int64

func (*VM) Clock

func (vm *VM) Clock() *clock.Clock

func (*VM) Clone

func (vm *VM) Clone(p *Program) *VM

func (*VM) CloneInitialized

func (vm *VM) CloneInitialized(p *Program, globals []Value) *VM

func (*VM) CopySettings

func (vm *VM) CopySettings(target *VM)

func (*VM) CurrentFunc

func (vm *VM) CurrentFunc() *Function

func (*VM) CurrentInstruction

func (vm *VM) CurrentInstruction() *Instruction

func (*VM) CurrentLine

func (vm *VM) CurrentLine() TraceLine

func (*VM) CurrentPC

func (vm *VM) CurrentPC() int

func (*VM) FinalizeGlobals

func (vm *VM) FinalizeGlobals()

func (*VM) Frames

func (vm *VM) Frames() int

func (*VM) GetLocation

func (vm *VM) GetLocation() *time.Location

func (*VM) GetStderr

func (vm *VM) GetStderr() io.Writer

func (*VM) GetStdin

func (vm *VM) GetStdin() io.Reader

func (*VM) GetStdout

func (vm *VM) GetStdout() io.Writer

func (*VM) Globals

func (vm *VM) Globals() []Value

func (*VM) HasPermission

func (vm *VM) HasPermission(name string) bool

func (*VM) Initialize

func (vm *VM) Initialize() error

func (*VM) Initialized

func (vm *VM) Initialized() bool

func (*VM) NewCodeError

func (vm *VM) NewCodeError(code int, format string, a ...interface{}) *VMError

func (*VM) NewError

func (vm *VM) NewError(format string, a ...interface{}) *VMError

func (*VM) RegisterValue

func (vm *VM) RegisterValue(name string) (Value, bool)

return a value from the current scope

func (*VM) RegisterValues

func (vm *VM) RegisterValues(includeGlobals bool) map[string]Value

func (*VM) RegisterValuesFrame

func (vm *VM) RegisterValuesFrame(frameIndex int, includeGlobals bool) map[string]Value

func (*VM) ResetSteps

func (vm *VM) ResetSteps()

func (*VM) Run

func (vm *VM) Run(args ...Value) (Value, error)

func (*VM) RunClosure

func (vm *VM) RunClosure(c *Closure, args ...Value) (Value, error)

RunClosure executes a program closure

func (*VM) RunFunc

func (vm *VM) RunFunc(name string, args ...Value) (Value, error)

RunFunc executes a function by name

func (*VM) RunFuncIndex

func (vm *VM) RunFuncIndex(index int, args ...Value) (Value, error)

RunFuncIndex executes a program function by index

func (*VM) RunMethod

func (vm *VM) RunMethod(c *Method, args ...Value) (Value, error)

RunMethod executes a class method

func (*VM) SetFinalizer

func (vm *VM) SetFinalizer(v Finalizable)

func (*VM) SetGlobalFinalizer

func (vm *VM) SetGlobalFinalizer(v Finalizable)

func (*VM) SetGlobalRegister

func (vm *VM) SetGlobalRegister(name string, v Value) error

func (*VM) Stacktrace

func (vm *VM) Stacktrace() []string

func (*VM) StacktraceLine

func (vm *VM) StacktraceLine() string

func (*VM) Steps

func (vm *VM) Steps() int64

func (*VM) WrapError

func (vm *VM) WrapError(err error) *VMError

type VMError

type VMError struct {
	Wrapped        *VMError
	Message        string
	Details        string
	Kind           string
	Code           int
	IsRethrow      bool
	TraceLines     []TraceLine
	CurrentLine    TraceLine
	CurrentFuction *Function
	// contains filtered or unexported fields
}

func NewCodeError

func NewCodeError(code int, msg string, args ...interface{}) *VMError

func (*VMError) Error

func (e *VMError) Error() string

func (*VMError) ErrorMessage

func (e *VMError) ErrorMessage() string

func (*VMError) GetField

func (e *VMError) GetField(name string, vm *VM) (Value, error)

func (*VMError) GetMethod

func (e *VMError) GetMethod(name string) NativeMethod

func (*VMError) Is

func (e *VMError) Is(msg string) bool

func (*VMError) MarshalJSON

func (e *VMError) MarshalJSON() ([]byte, error)

func (*VMError) SetField

func (e *VMError) SetField(key string, v Value, vm *VM) error

func (*VMError) Stack

func (e *VMError) Stack() string

func (*VMError) String

func (e *VMError) String() string

func (*VMError) Type

func (e *VMError) Type() string

type VMInfo

type VMInfo struct {
	ID       uint   `json:"index"`
	Active   bool   `json:"active"`
	File     string `json:"file"`
	Line     int    `json:"line"`
	Function string `json:"function"`
	Status   string `json:"status"`
}

Estructuras de datos específicas

type Value

type Value struct {
	Internal interface{}
	Type     Type
}

func NewArray

func NewArray(size int) Value

func NewArrayValues

func NewArrayValues(v []Value) Value

func NewBool

func NewBool(v bool) Value

func NewBytes

func NewBytes(v []byte) Value

func NewEnum

func NewEnum(v int) Value

func NewFloat

func NewFloat(v float64) Value

func NewFunction

func NewFunction(v int) Value

func NewInt

func NewInt(v int) Value

func NewInt64

func NewInt64(v int64) Value

func NewMap

func NewMap(size int) Value

func NewMapValues

func NewMapValues(m map[Value]Value, readonly bool) Value

func NewNativeFunction

func NewNativeFunction(v int) Value

func NewObject

func NewObject(v interface{}) Value

func NewRune

func NewRune(v rune) Value

func NewString

func NewString(v string) Value

func NewValue

func NewValue(v interface{}) Value

func Run

func Run(fs filesystem.FS, path string) (Value, error)

func RunStr

func RunStr(code string) (Value, error)

func (Value) Equals

func (v Value) Equals(other Value) bool

func (Value) Export

func (v Value) Export(recursionLevel int) interface{}

func (Value) ExportLimit

func (v Value) ExportLimit(recursionLevel, maxRecursion int) interface{}

func (Value) ExportMarshal

func (v Value) ExportMarshal(recursionLevel int) interface{}

func (Value) ExportMarshalLimit

func (v Value) ExportMarshalLimit(recursionLevel, maxRecursion int) interface{}

func (Value) IsNil

func (v Value) IsNil() bool

func (Value) IsNilOrEmpty

func (v Value) IsNilOrEmpty() bool

func (Value) MarshalJSON

func (v Value) MarshalJSON() ([]byte, error)

func (Value) MarshalJSONLimit

func (v Value) MarshalJSONLimit(limit int) ([]byte, error)

func (Value) Size

func (v Value) Size() int

func (Value) StrictEquals

func (v Value) StrictEquals(other Value) bool

func (Value) String

func (v Value) String() string

String representation for the formatter.

func (Value) ToArray

func (v Value) ToArray() []Value

func (Value) ToArrayObject

func (v Value) ToArrayObject() *ArrayObject

func (Value) ToArrayObjectOrNil

func (v Value) ToArrayObjectOrNil() (*ArrayObject, bool)

func (Value) ToBool

func (v Value) ToBool() bool

func (Value) ToBytes

func (v Value) ToBytes() []byte

func (Value) ToEnum

func (v Value) ToEnum() int

func (Value) ToFloat

func (v Value) ToFloat() float64

func (Value) ToFunction

func (v Value) ToFunction() int

func (Value) ToInt

func (v Value) ToInt() int64

func (Value) ToMap

func (v Value) ToMap() *MapValue

func (Value) ToNativeFunction

func (v Value) ToNativeFunction() int

func (Value) ToObject

func (v Value) ToObject() interface{}

func (Value) ToObjectOrNil

func (v Value) ToObjectOrNil() interface{}

func (Value) ToRune

func (v Value) ToRune() rune

func (Value) ToString

func (v Value) ToString() string

func (Value) TypeName

func (v Value) TypeName() string

type VariableInfo

type VariableInfo struct {
	Name               string `json:"name"`
	Value              string `json:"value"`
	Type               string `json:"type"`
	Scope              string `json:"scope"`
	VariablesReference int    `json:"variablesReference"`
	IndexedVariables   int    `json:"indexedVariables,omitempty"`
	NamedVariables     int    `json:"namedVariables,omitempty"`
}

type VariableReference

type VariableReference struct {
	Value     Value
	Path      string // Ruta para debugging: "locals.myArray[0]"
	ParentRef int    // Referencia al padre, 0 si es raíz
}

VariableReference - Estructura para manejar referencias de variables

type VariablesRequest

type VariablesRequest struct {
	VariablesReference int `json:"variablesReference"`
	Start              int `json:"start,omitempty"`
	Count              int `json:"count,omitempty"`
}

Directories

Path Synopsis
cmd
sim command
lib
dbx
jsregex
Package jsregex provides JavaScript-compatible regular expression functionality for Go.
Package jsregex provides JavaScript-compatible regular expression functionality for Go.
pdf
sqx
templates
Package templates generates source code for templates.
Package templates generates source code for templates.
xmlLib
Package etree provides XML services through an Element Tree abstraction.
Package etree provides XML services through an Element Tree abstraction.

Jump to

Keyboard shortcuts

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