Class VirtualMachine
Represents a virtual machine that executes bytecode instructions.
Inherited Members
Namespace: VM.Core
Assembly: VM.dll
Syntax
public class VirtualMachine
Constructors
VirtualMachine()
Initializes a new instance of the VirtualMachine class.
Declaration
public VirtualMachine()
Methods
DumpState()
Dumps the current state of the virtual machine to the console.
Declaration
public void DumpState()
Remarks
Output includes:
- General VM state (stack sizes, instruction pointer)
- Current execution frames
- Full bytecode dump with memory addresses
LoadProgram(byte[])
Loads a bytecode program into the virtual machine and initializes the execution frame.
Declaration
public void LoadProgram(byte[] bytecode)
Parameters
Type | Name | Description |
---|---|---|
byte[] | bytecode | The bytecode program to execute. |
Reset()
Resets the virtual machine to its initial state.
Declaration
public void Reset()
Remarks
Clears all stacks, resets the instruction pointer, and removes all execution frames.
Run()
Executes the loaded bytecode program.
Declaration
public void Run()
Remarks
The execution continues until either a HALT instruction is encountered, or an error occurs during execution.
Exceptions
Type | Condition |
---|---|
VmException | Thrown when an invalid opcode is encountered or other VM error occurs. |
VmHaltException | Thrown when the VM executes a HALT instruction. |