The CpuVirtualMachine Class

This class is built for running BEAST byte code programs on the CPU of the host system. Instructions are processed in a linear fashion, and the current execution state is held in an instance of The VmSession Class.

class CpuVirtualMachine : public beast::VirtualMachine

Public Functions

~CpuVirtualMachine()

Virtual destructor performing no operation to ensure vtable consistency.

bool step(VmSession &session, bool dry_run)

Executes the next step a program in its current state as denoted by a VM session.

This function must be implemented by subclasses of the VirtualMachine class. A VmSession is passed in that contains a program to execute, and a state at which the program currently is (including instruction pointer, variable memory, and string table).

When the dry_run parameter is passed, the VM is supposed to only step through the operations in a program and not actually execute them. This can be used to count the effective amount and individual types of operators in a program, as well as analyze its structure.

Return
A boolean flag denoting whether the session can further execute instructions.
Parameters
  • session: The VmSession instance that holds the program and state to step through.
  • dry_run: Determines whether operators are executed or just read.