Documentation
¶
Overview ¶
Package vm handles the line-by-line execution of vise bytecode.
Index ¶
- Constants
- Variables
- func CheckTarget(target []byte, st *state.State) (bool, error)
- func NewInvalidInputError(input string) error
- func NewLine(instructionList []byte, instruction uint16, strargs []string, byteargs []byte, ...) []byte
- func ParseAll(b []byte, w io.Writer) (int, error)
- func ParseCatch(b []byte) (string, uint32, bool, []byte, error)
- func ParseCroak(b []byte) (uint32, bool, []byte, error)
- func ParseHalt(b []byte) ([]byte, error)
- func ParseInCmp(b []byte) (string, string, []byte, error)
- func ParseLoad(b []byte) (string, uint32, []byte, error)
- func ParseMNext(b []byte) (string, string, []byte, error)
- func ParseMOut(b []byte) (string, string, []byte, error)
- func ParseMPrev(b []byte) (string, string, []byte, error)
- func ParseMSink(b []byte) ([]byte, error)
- func ParseMap(b []byte) (string, []byte, error)
- func ParseMove(b []byte) (string, []byte, error)
- func ParseReload(b []byte) (string, []byte, error)
- func ToString(b []byte) (string, error)
- func ValidInput(input []byte) error
- func ValidSym(input []byte) error
- type ExternalCodeError
- type InvalidInputError
- type Opcode
- type Vm
Constants ¶
const ( NOOP = 0 CATCH = 1 CROAK = 2 LOAD = 3 RELOAD = 4 MAP = 5 MOVE = 6 HALT = 7 INCMP = 8 MSINK = 9 MOUT = 10 MNEXT = 11 MPREV = 12 )
VM Opcodes
const VERSION = 0
Variables ¶
var ( OpcodeString = map[Opcode]string{ NOOP: "NOOP", CATCH: "CATCH", CROAK: "CROAK", LOAD: "LOAD", RELOAD: "RELOAD", MAP: "MAP", MOVE: "MOVE", HALT: "HALT", INCMP: "INCMP", MSINK: "MSINK", MOUT: "MOUT", MNEXT: "MNEXT", MPREV: "MPREV", } OpcodeIndex = map[string]Opcode{ "NOOP": NOOP, "CATCH": CATCH, "CROAK": CROAK, "LOAD": LOAD, "RELOAD": RELOAD, "MAP": MAP, "MOVE": MOVE, "HALT": HALT, "INCMP": INCMP, "MSINK": MSINK, "MOUT": MOUT, "MNEXT": MNEXT, "MPREV": MPREV, } )
Functions ¶
func CheckTarget ¶
CheckTarget tests whether the navigation state transition is available in the current state.
Fails if target is formally invalid, or if navigation is unavailable.
func NewInvalidInputError ¶
NewInvalidInputError creates a new InvalidInputError
func NewLine ¶
func NewLine(instructionList []byte, instruction uint16, strargs []string, byteargs []byte, numargs []uint8) []byte
NewLine creates a new instruction line for the VM.
func ParseAll ¶
ParseAll parses and verifies all instructions from bytecode.
If writer is not nil, the parsed instruction as assembly code line string is written to it.
Bytecode is consumed (and written) one instruction at a time.
It fails on any parse error encountered before the bytecode EOF is reached.
func ParseCatch ¶
ParseCatch parses and extracts the expected argument portion of a CATCH instruction
func ParseCroak ¶
ParseCroak parses and extracts the expected argument portion of a CROAK instruction
func ParseHalt ¶
ParseHalt parses and extracts the expected argument portion of a HALT instruction
func ParseInCmp ¶
ParseInCmp parses and extracts the expected argument portion of a INCMP instruction
func ParseLoad ¶
ParseLoad parses and extracts the expected argument portion of a LOAD instruction
func ParseMNext ¶
ParseMNext parses and extracts the expected argument portion of a MNEXT instruction
func ParseMOut ¶
ParseMOut parses and extracts the expected argument portion of a MOUT instruction
func ParseMPrev ¶
ParseMPrev parses and extracts the expected argument portion of a MPREV instruction
func ParseMSink ¶
ParseMSink parses and extracts the expected argument portion of a MSINK instruction
func ParseMap ¶
ParseMap parses and extracts the expected argument portion of a MAP instruction
func ParseMove ¶
ParseMove parses and extracts the expected argument portion of a MOVE instruction
func ParseReload ¶
ParseReload parses and extracts the expected argument portion of a RELOAD instruction
func ToString ¶
ToString verifies all instructions in bytecode and returns an assmebly code instruction for it.
func ValidInput ¶
CheckInput validates the given byte string as client input.
Types ¶
type ExternalCodeError ¶
type ExternalCodeError struct {
// contains filtered or unexported fields
}
ExternalCodeError indicates an error that occurred when resolving an external code symbol (LOAD, RELOAD).
func NewExternalCodeError ¶
func NewExternalCodeError(sym string, err error) *ExternalCodeError
NewExternalCodeError creates a new ExternalCodeError.
func (ExternalCodeError) Error ¶
func (e ExternalCodeError) Error() string
Error implements the Error interface.
func (*ExternalCodeError) WithCode ¶
func (e *ExternalCodeError) WithCode(code int) *ExternalCodeError
type InvalidInputError ¶
type InvalidInputError struct {
// contains filtered or unexported fields
}
InvalidInputError indicates client input that was unhandled by the bytecode (INCMP fallthrough)
func (InvalidInputError) Error ¶
func (e InvalidInputError) Error() string
Error implements the Error interface.
type Vm ¶
type Vm struct {
// contains filtered or unexported fields
}
Vm holds sub-components mutated by the vm execution. TODO: Renderer should be passed to avoid proxy methods not strictly related to vm operation
func NewVm ¶
NewVm creates a new Vm.
func (*Vm) Render ¶
Render wraps output rendering, and handles error when attempting to browse beyond the rendered page count.
Source Files
¶
- debug.go
- doc.go
- input.go
- log.go
- opcodes.go
- runner.go
- vm.go