#include <VirtualMachine.h>

Collaboration diagram for rBPF::VirtualMachine:

Public Types

using Container = FSTR::Array< uint8_t >
 

Public Member Functions

 VirtualMachine ()
 Create an uninitialised VM. More...
 
int getLastError () const
 Get error code from last call to execute() More...
 
Create a VM and load a container
Parameters
containerContainer code blob
 VirtualMachine (const Container &container, size_t stackSize=defaultStackSize)
 
 ~VirtualMachine ()
 
bool load (const Container &container, size_t stackSize=defaultStackSize)
 Load container and initialise it. More...
 
void unload ()
 Unload container and free any allocated resources. More...
 
Run the container
Parameters
ctxIN/OUT Passed to container. Must be persistent.
Return values
int64_tResult returned from container
template<typename Context >
int64_t execute (Context &ctx)
 
int64_t execute (void *ctx, size_t ctxLength)
 
int64_t execute ()
 

Public Attributes

LocalStore locals
 

Static Public Attributes

static constexpr size_t defaultStackSize {512}
 
static GlobalStore globals
 

Friends

class LocalStore
 

Member Typedef Documentation

◆ Container

Constructor & Destructor Documentation

◆ VirtualMachine() [1/2]

rBPF::VirtualMachine::VirtualMachine ( )

Create an uninitialised VM.

◆ VirtualMachine() [2/2]

rBPF::VirtualMachine::VirtualMachine ( const Container container,
size_t  stackSize = defaultStackSize 
)
inline

◆ ~VirtualMachine()

rBPF::VirtualMachine::~VirtualMachine ( )

Member Function Documentation

◆ execute() [1/3]

int64_t rBPF::VirtualMachine::execute ( )
inline

◆ execute() [2/3]

template<typename Context >
int64_t rBPF::VirtualMachine::execute ( Context &  ctx)
inline

◆ execute() [3/3]

int64_t rBPF::VirtualMachine::execute ( void *  ctx,
size_t  ctxLength 
)

◆ getLastError()

int rBPF::VirtualMachine::getLastError ( ) const
inline

Get error code from last call to execute()

Return values
int0 on success. Retrieve text for error code using getErrorString()

◆ load()

bool rBPF::VirtualMachine::load ( const Container container,
size_t  stackSize = defaultStackSize 
)

Load container and initialise it.

Return values
booltrue on success

◆ unload()

void rBPF::VirtualMachine::unload ( )

Unload container and free any allocated resources.

Friends And Related Function Documentation

◆ LocalStore

friend class LocalStore
friend

Member Data Documentation

◆ defaultStackSize

constexpr size_t rBPF::VirtualMachine::defaultStackSize {512}
staticconstexpr

◆ globals

GlobalStore rBPF::VirtualMachine::globals
static

◆ locals

LocalStore rBPF::VirtualMachine::locals

The documentation for this class was generated from the following file: