asm

package
v0.0.0-...-7a622f3 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package asm contains high-level instructions to control the replay virtual machine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Add

type Add struct {
	Count uint32
}

Add is an Instruction that pops and sums the top N stack values, pushing the result to the top of the stack. Each summed value must have the same type.

func (Add) Encode

func (a Add) Encode(r value.PointerResolver, w binary.Writer) error

type Call

type Call struct {
	PushReturn bool   // If true, the return value is pushed to the VM stack.
	ApiIndex   uint8  // The index of the API this call belongs to
	FunctionID uint16 // The function id registered with the VM to invoke.
}

Call is an Instruction to call a VM registered function. This instruction will pop the parameters from the VM stack starting with the first parameter. If PushReturn is true, then the return value of the function call will be pushed to the top of the VM stack.

func (Call) Encode

func (a Call) Encode(r value.PointerResolver, w binary.Writer) error

type Clone

type Clone struct {
	Index int
}

Clone is an Instruction that makes a copy of the the n-th element from the top of the VM stack and pushes the copy to the top of the VM stack.

func (Clone) Encode

func (a Clone) Encode(r value.PointerResolver, w binary.Writer) error

type Copy

type Copy struct {
	Count uint64 // Number of bytes to copy.
}

Copy is an Instruction that pops the target address and then the source address from the top of the VM stack, and then copies Count bytes from source to target.

func (Copy) Encode

func (a Copy) Encode(r value.PointerResolver, w binary.Writer) error

type InlineResource

type InlineResource struct {
	Data            []byte
	Destination     value.Pointer
	ValuePatchUps   []InlineResourceValuePatchUp
	PointerPatchUps []InlineResourcePointerPatchUp
	Ctx             context.Context
}

func (InlineResource) Encode

type InlineResourcePointerPatchUp

type InlineResourcePointerPatchUp struct {
	Destination value.Pointer
	Source      value.Pointer
}

type InlineResourceValuePatchUp

type InlineResourceValuePatchUp struct {
	Destination value.Pointer
	Value       value.Value
}

type Instruction

type Instruction interface {
	Encode(r value.PointerResolver, w binary.Writer) error
}

Instruction is the interface of all instruction types.

Encode writes the instruction's opcodes to the binary writer w, translating all pointers to their final, resolved addresses using the PointerResolver r. An instruction can produce zero, one or many opcodes.

type JumpLabel

type JumpLabel struct {
	Label uint32
}

func (JumpLabel) Encode

type JumpNZ

type JumpNZ struct {
	Label uint32
}

func (JumpNZ) Encode

func (a JumpNZ) Encode(r value.PointerResolver, w binary.Writer) error

type JumpZ

type JumpZ struct {
	Label uint32
}

func (JumpZ) Encode

func (a JumpZ) Encode(r value.PointerResolver, w binary.Writer) error

type Label

type Label struct {
	Value uint32
}

Label is an Instruction that holds a marker value, used for debugging.

func (Label) Encode

func (a Label) Encode(r value.PointerResolver, w binary.Writer) error

type Load

type Load struct {
	DataType protocol.Type
	Source   value.Pointer
}

Load is an Instruction that loads the value of type DataType from pointer Source and pushes the loaded value to the top of the VM stack.

func (Load) Encode

func (a Load) Encode(r value.PointerResolver, w binary.Writer) error

type Nop

type Nop struct{}

Nop is a no-operation Instruction. Instructions of this type do nothing.

func (Nop) Encode

func (Nop) Encode(r value.PointerResolver, w binary.Writer) error

type Notification

type Notification struct {
	ID     uint64
	Source value.Pointer
	Size   uint64
}

Notification is an Instruction that sends Size bytes from Source to the server, with the ID returned as well.

func (Notification) Encode

type Pop

type Pop struct {
	Count uint32 // Number of values to discard from the top of the VM stack.
}

Pop is an Instruction that discards Count values from the top of the VM stack.

func (Pop) Encode

func (a Pop) Encode(r value.PointerResolver, w binary.Writer) error

type Post

type Post struct {
	Source value.Pointer
	Size   uint64
}

Post is an Instruction that posts Size bytes from Source to the server.

func (Post) Encode

func (a Post) Encode(r value.PointerResolver, w binary.Writer) error

type Push

type Push struct {
	Value value.Value // The value to push on to the VM stack.
}

Push is an Instruction to push Value to the top of the VM stack.

func (Push) Encode

func (a Push) Encode(r value.PointerResolver, w binary.Writer) error

type Resource

type Resource struct {
	Index       uint32
	Destination value.Pointer
}

Resource is an Instruction that loads the resource with index Index of Size bytes and writes the resource to Destination.

func (Resource) Encode

type Store

type Store struct {
	Destination value.Pointer
}

Store is an Instruction that pops the value from the top of the VM stack and writes the value to Destination.

func (Store) Encode

func (a Store) Encode(r value.PointerResolver, w binary.Writer) error

type Strcpy

type Strcpy struct {
	MaxCount uint64
}

Strcpy is an Instruction that pops the target address then the source address from the top of the VM stack, and then copies at most MaxCount-1 bytes from source to target. If the MaxCount is greater than the source string length, then the target will be padded with 0s. The destination buffer will always be 0-terminated.

func (Strcpy) Encode

func (a Strcpy) Encode(r value.PointerResolver, w binary.Writer) error

type SwitchThread

type SwitchThread struct {
	Index uint32
}

SwitchThread is an Instruction that changes execution to a different thread.

func (SwitchThread) Encode

type Wait

type Wait struct {
	ID uint32
}

func (Wait) Encode

func (a Wait) Encode(r value.PointerResolver, w binary.Writer) error

Jump to

Keyboard shortcuts

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