Documentation ¶
Overview ¶
The GADGT VM implementation and instruction set
Index ¶
- Constants
- func Eval(r io.Reader, program *Program, target types.Field) (err error)
- func WriteBool(r bool, w io.Writer) error
- func WriteBytes(r []byte, w io.Writer) error
- func WriteDouble(r float64, w io.Writer) error
- func WriteFloat(r float32, w io.Writer) error
- func WriteInt(r int32, w io.Writer) error
- func WriteLong(r int64, w io.Writer) error
- func WriteNull(_ interface{}, _ io.Writer) error
- func WriteString(r string, w io.Writer) error
- type ByteReader
- type ByteWriter
- type Instruction
- type Op
- type Program
- type StringWriter
Constants ¶
View Source
const ( Unused int = iota Null Boolean Int Long Float Double Bytes String UnionElem UnusedLong )
Constants for the data types supported by the Read and Set operations. If the value is > 9 it's assumed to be the length of a Fixed type.
View Source
const NoopField = 65535
The value of NoopField as the pperand signifies the operand is unused.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ByteReader ¶
type ByteWriter ¶
type Instruction ¶
Represents a single VM instruction consisting of an opcode and 0 or 1 operands.
func (Instruction) String ¶
func (i Instruction) String() string
type Op ¶
type Op int
OP represents an opcode for the VM. Operations take 0 or 1 operands.
const ( // Read a value of the operand type from the wire and put itin the frame Read Op = iota // Set the current target to the value of the operand type from the frame Set // Allocate a new frame and make the target the field with the operand index Enter // Move to the previous frame Exit // Append a value to the current target and enter the new value AppendArray // Append a new key-value pair (where the key is the String value in the current frame) to the current target and enter the new value AppendMap // Set the value of the field at the operand index to it's default value SetDefault // Push the current address onto the call stack and move the PC to the operand address Call // Pop the top value frmm the call stack and set the PC to that address Return // Stop the VM. If the operand is greater than zero, look up the corresponding error message and return it Halt // Move the PC to the operand Jump // Evaluate whether the Long register is equal to the operand, and set the condition register to the result EvalEqual // Evaluate whether the Long register is greater than the operand, and set the condition register to the result EvalGreater // If the condition register is true, jump to the operand instruction CondJump // Set the Long register to the operand value SetLong // Add the operand value to the Long register AddLong // Multiply the operand value by the Long register MultLong // Push the current Long register value onto the loop stack PushLoop // Pop the top of the loop stack and store the value in the Long register PopLoop )
type Program ¶
type Program struct { // The list of instructions that make up the deserializer program Instructions []Instruction // A list of errors that can be triggered by halt(x), where x is the index in this array + 1 Errors []string }
type StringWriter ¶
Click to show internal directories.
Click to hide internal directories.