Documentation
¶
Index ¶
- Constants
- type BreakpointFunc
- type Coordinator
- type ErrorHandlerFunc
- type FinishHandlerFunc
- type RuntimeError
- type VM
- func (v *VM) AddBreakpoint(line int)
- func (v *VM) CurrentAstLine() int
- func (v *VM) CurrentSourceColoumn() int
- func (v *VM) CurrentSourceLine() int
- func (v *VM) GetVariable(name string) (*Variable, bool)
- func (v *VM) GetVariables() map[string]Variable
- func (v *VM) ListBreakpoints() []int
- func (v *VM) Pause()
- func (v *VM) PrintVariables() string
- func (v *VM) RemoveBreakpoint(line int)
- func (v *VM) Resume()
- func (v *VM) SetBreakpointHandler(f BreakpointFunc)
- func (v *VM) SetCoordinator(c *Coordinator)
- func (v *VM) SetErrorHandler(f ErrorHandlerFunc)
- func (v *VM) SetFinishHandler(f FinishHandlerFunc)
- func (v *VM) SetIterations(reps int)
- func (v *VM) SetMaxExecutedLines(lines int)
- func (v *VM) SetStepHandler(f FinishHandlerFunc)
- func (v *VM) SetVariable(name string, value interface{}) error
- func (v *VM) State() int
- func (v *VM) Step()
- func (v *VM) Terminate()
- func (v *VM) WaitForTermination()
- type Variable
Constants ¶
const ( StatePaused = iota StateRunning = iota StateStepping = iota StateTerminated = iota )
The current state of the VM
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BreakpointFunc ¶
BreakpointFunc is a function that is called when a breakpoint is encountered. If true is returned the execution is resumed. Otherwise the vm remains paused
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator is responsible for coordinating the execution of multiple VMs It coordinates the line-by-line execution of the scripts and provides shared global variables
func (*Coordinator) GetVariable ¶
func (c *Coordinator) GetVariable(name string) (*Variable, bool)
GetVariable gets the current state of a global variable getting variables is case-insensitive
func (*Coordinator) GetVariables ¶
func (c *Coordinator) GetVariables() map[string]Variable
GetVariables gets the current state of all global variables All returned variables have normalized (lowercased) names
func (*Coordinator) Run ¶
func (c *Coordinator) Run()
Run starts the coordinated exection Once run has been called, no new VMs MUSt be added!!!
func (*Coordinator) SetVariable ¶
func (c *Coordinator) SetVariable(name string, value *Variable) error
SetVariable sets the current state of a global variable setting variables is case-insensitive
func (*Coordinator) Terminate ¶
func (c *Coordinator) Terminate()
Terminate all coordinated vms Once all VMs terminate the coordinator-goroutine will also shut-down
func (*Coordinator) WaitForTermination ¶
func (c *Coordinator) WaitForTermination()
WaitForTermination blocks until all coordinated vms terminate
type ErrorHandlerFunc ¶
ErrorHandlerFunc is a function that is called when a runtime-error is encountered. If true is returned the execution is resumed. Otherwise the vm remains paused
type FinishHandlerFunc ¶
type FinishHandlerFunc func(vm *VM)
FinishHandlerFunc is a function that is called when the programm finished execution (looping is disabled)
type RuntimeError ¶
RuntimeError represents an error encountered during execution
func (RuntimeError) Error ¶
func (e RuntimeError) Error() string
type VM ¶ added in v0.0.15
type VM struct {
// contains filtered or unexported fields
}
VM is a virtual machine to execute YOLOL-Code
func Create ¶ added in v0.0.15
Create creates a new VM to run the given program in a seperate goroutine. The returned VM is paused. Configure it using the setters and then call Resume()
func CreateFromSource ¶ added in v0.0.15
CreateFromSource creates a new VM to run the given program in a seperate goroutine. The returned VM is paused. Configure it using the setters and then call Resume()
func (*VM) AddBreakpoint ¶ added in v0.0.15
AddBreakpoint adds a breakpoint at the line. Breakpoint-lines always refer to the position recorded in the ast nodes, not the position of the Line in the Line-Slice of ast.Program.
func (*VM) CurrentAstLine ¶ added in v0.0.15
CurrentAstLine returns the current (=next to be executed) ast line of the program
func (*VM) CurrentSourceColoumn ¶ added in v0.0.15
CurrentSourceColoumn returns the current (=next to be executed) source column of the program
func (*VM) CurrentSourceLine ¶ added in v0.0.15
CurrentSourceLine returns the current (=next to be executed) source line of the program
func (*VM) GetVariable ¶ added in v0.0.15
GetVariable gets the current state of a variable
func (*VM) GetVariables ¶ added in v0.0.15
GetVariables gets the current state of all variables
func (*VM) ListBreakpoints ¶ added in v0.0.15
ListBreakpoints returns the list of active breakpoints
func (*VM) Pause ¶ added in v0.0.15
func (v *VM) Pause()
Pause pauses the execution Blocks until the VM reacts on the request
func (*VM) PrintVariables ¶ added in v0.0.15
PrintVariables gets an overview over the current variable state
func (*VM) RemoveBreakpoint ¶ added in v0.0.15
RemoveBreakpoint removes the breakpoint at the line
func (*VM) Resume ¶ added in v0.0.15
func (v *VM) Resume()
Resume resumes execution after a breakpoint or pause() or the initial stopped state Blocks until the VM reacts on the request
func (*VM) SetBreakpointHandler ¶ added in v0.0.15
func (v *VM) SetBreakpointHandler(f BreakpointFunc)
SetBreakpointHandler sets the function to be called when hitting a breakpoint
func (*VM) SetCoordinator ¶ added in v0.0.15
func (v *VM) SetCoordinator(c *Coordinator)
SetCoordinator sets the coordinator that is used to coordinate execution with other vms
func (*VM) SetErrorHandler ¶ added in v0.0.15
func (v *VM) SetErrorHandler(f ErrorHandlerFunc)
SetErrorHandler sets the function to be called when encountering an error
func (*VM) SetFinishHandler ¶ added in v0.0.15
func (v *VM) SetFinishHandler(f FinishHandlerFunc)
SetFinishHandler sets the function to be called when execution finishes
func (*VM) SetIterations ¶ added in v0.0.15
SetIterations sets the number of iterations to perform for the script 1 = run only once, <=0 run forever, >0 repeat x times default is 1
func (*VM) SetMaxExecutedLines ¶ added in v0.0.15
SetMaxExecutedLines sets the maximum number of lines to run if the amount is reached the VM terminates Can be used to prevent blocking by endless loops <= 0 disables this. Default is 0
func (*VM) SetStepHandler ¶ added in v0.0.15
func (v *VM) SetStepHandler(f FinishHandlerFunc)
SetStepHandler sets the function to be called when a step completes
func (*VM) SetVariable ¶ added in v0.0.15
SetVariable sets the current state of a variable
func (*VM) Step ¶ added in v0.0.15
func (v *VM) Step()
Step executes the next line and paused the execution Blocks until the VM reacts on the request
func (*VM) Terminate ¶ added in v0.0.15
func (v *VM) Terminate()
Terminate the vm goroutine (if running)
func (*VM) WaitForTermination ¶ added in v0.0.15
func (v *VM) WaitForTermination()
WaitForTermination blocks until the VM terminates
type Variable ¶
type Variable struct {
Value interface{}
}
Variable represents a yolol-variable during the execution
func RunBinaryOperation ¶
RunBinaryOperation executes the given operation with the given arguments and returns the result
func RunUnaryOperation ¶
RunUnaryOperation executes the given operation with the given argument and returns the result