Documentation
¶
Index ¶
- Constants
- type BreakpointFunc
- type Coordinator
- func (c *Coordinator) GetVariable(name string) (*Variable, bool)
- func (c *Coordinator) GetVariables() map[string]Variable
- func (c *Coordinator) IsRunning() bool
- func (c *Coordinator) Run()
- func (c *Coordinator) SetVariable(name string, value *Variable) error
- func (c *Coordinator) Stop()
- func (c *Coordinator) Terminate()
- func (c *Coordinator) WaitForTermination()
- type ErrorHandlerFunc
- type FinishHandlerFunc
- type RuntimeError
- type Variable
- type YololVM
- func (v *YololVM) AddBreakpoint(line int)
- func (v *YololVM) CurrentAstLine() int
- func (v *YololVM) CurrentSourceLine() int
- func (v *YololVM) GetVariable(name string) (*Variable, bool)
- func (v *YololVM) GetVariables() map[string]Variable
- func (v *YololVM) ListBreakpoints() []int
- func (v *YololVM) Pause()
- func (v *YololVM) PrintVariables() string
- func (v *YololVM) RemoveBreakpoint(line int)
- func (v *YololVM) Resume() error
- func (v *YololVM) Run(prog *ast.Program)
- func (v *YololVM) RunSource(prog string)
- func (v *YololVM) Running() bool
- func (v *YololVM) SetBreakpointHandler(f BreakpointFunc)
- func (v *YololVM) SetErrorHandler(f ErrorHandlerFunc)
- func (v *YololVM) SetFinishHandler(f FinishHandlerFunc)
- func (v *YololVM) SetIterations(reps int)
- func (v *YololVM) SetMaxExecutedLines(lines int)
- func (v *YololVM) SetVariable(name string, value interface{}) error
- func (v *YololVM) State() int
- func (v *YololVM) Step() error
- func (v *YololVM) Terminate()
- func (v *YololVM) WaitForTermination()
Constants ¶
const ( StateIdle = iota StateRunning = iota StatePaused = iota StateStep = iota StateKill = iota StateDone = 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) IsRunning ¶
func (c *Coordinator) IsRunning() bool
IsRunning returns true if the sub-vms are allowed to run
func (*Coordinator) Run ¶
func (c *Coordinator) Run()
Run starts the coordinated exection Run() on the VMs must have been called before
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) 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 *YololVM)
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 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 RunFunction ¶
RunFunction executes the given yolol-function with the given argument and returns the result
func RunUnaryOperation ¶
RunUnaryOperation executes the given operation with the given argument and returns the result
type YololVM ¶
type YololVM struct {
// contains filtered or unexported fields
}
YololVM is a virtual machine to execute YOLOL-Code
func NewYololVMCoordinated ¶
func NewYololVMCoordinated(coordinator *Coordinator) *YololVM
NewYololVMCoordinated creates a new VM that is coordinated with other VMs using the given coordinator
func (*YololVM) AddBreakpoint ¶
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 (*YololVM) CurrentAstLine ¶
CurrentAstLine returns the current (=next to be executed) ast line of the program
func (*YololVM) CurrentSourceLine ¶
CurrentSourceLine returns the current (=next to be executed) source line of the program
func (*YololVM) GetVariable ¶
GetVariable gets the current state of a variable
func (*YololVM) GetVariables ¶
GetVariables gets the current state of all variables
func (*YololVM) ListBreakpoints ¶
ListBreakpoints returns the list of active breakpoints
func (*YololVM) PrintVariables ¶
PrintVariables gets an overview over the current variable state
func (*YololVM) RemoveBreakpoint ¶
RemoveBreakpoint removes the breakpoint at the line
func (*YololVM) SetBreakpointHandler ¶
func (v *YololVM) SetBreakpointHandler(f BreakpointFunc)
SetBreakpointHandler sets the function to be called when hitting a breakpoint
func (*YololVM) SetErrorHandler ¶
func (v *YololVM) SetErrorHandler(f ErrorHandlerFunc)
SetErrorHandler sets the function to be called when encountering an error
func (*YololVM) SetFinishHandler ¶
func (v *YololVM) SetFinishHandler(f FinishHandlerFunc)
SetFinishHandler sets the function to be called when execution finishes
func (*YololVM) SetIterations ¶
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 (*YololVM) SetMaxExecutedLines ¶
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 (*YololVM) SetVariable ¶
SetVariable sets the current state of a variable
func (*YololVM) WaitForTermination ¶
func (v *YololVM) WaitForTermination()
WaitForTermination blocks until the vm finished running