JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace > Struct Template Reference

Loads a program, and lets the user execute its functions. More...

#include <juce_LittleFootRunner.h>

Collaboration diagram for littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >:

Classes

struct  FunctionExecutionContext
 

Public Types

enum  ErrorCode : uint8 {
  ErrorCode::ok = 0,
  ErrorCode::executionTimedOut,
  ErrorCode::unknownInstruction,
  ErrorCode::stackOverflow,
  ErrorCode::stackUnderflow,
  ErrorCode::illegalAddress,
  ErrorCode::divisionByZero,
  ErrorCode::unknownFunction
}
 Return codes from a function call. More...
 

Public Member Functions

 Runner () noexcept
 
ErrorCode callFunction (const char *functionSignature) noexcept
 Calls one of the functions in the program, by its textual signature. More...
 
ErrorCode callFunction (FunctionID function) noexcept
 Calls one of the functions in the program, by its function ID. More...
 
void clearHeapAndGlobals () noexcept
 Clears all the non-program data. More...
 
uint32 getHeapBits (uint32 startBit, uint32 numBits) const noexcept
 
uint8 getHeapByte (uint32 index) const noexcept
 
int32 getHeapInt (uint32 byteOffset) const noexcept
 
const NativeFunctiongetNativeFunction (int index) const noexcept
 Returns one of the native functions available. More...
 
int getNumNativeFunctions () const noexcept
 Returns the number of native functions available. More...
 
uint8getProgramAndDataEnd () const noexcept
 
uint32 getProgramAndDataSize () const noexcept
 
uint8getProgramAndDataStart () const noexcept
 
uint8getProgramHeapEnd () const noexcept
 
uint16 getProgramHeapSize () const noexcept
 
uint8getProgramHeapStart () const noexcept
 
bool isProgramValid () const noexcept
 
void reset () noexcept
 Clears the memory state. More...
 
void setDataByte (uint32 index, uint8 value) noexcept
 Sets a byte of data. More...
 
void setHeapByte (uint32 index, uint8 value) noexcept
 
int32 setHeapInt (uint32 byteOffset, uint32 value) noexcept
 
void setNativeFunctions (const NativeFunction *functions, int numFunctions, void *userDataForCallback) noexcept
 Installs an array of native functions that the code can use. More...
 

Static Public Member Functions

static const char * getErrorDescription (ErrorCode e) noexcept
 Returns a text description for an error code. More...
 
static uint32 getMaximumProgramSize () noexcept
 

Public Attributes

uint8 allMemory [((programAndHeapSpace+stackAndGlobalsSpace)+3) &~3]
 
Program program
 

Static Public Attributes

static constexpr uint32 totalProgramAndHeapSpace = programAndHeapSpace
 
static constexpr uint32 totalStackAndGlobalsSpace = stackAndGlobalsSpace
 

Private Member Functions

RunnerreinitialiseProgramLayoutIfProgramHasChanged () noexcept
 

Private Attributes

int32globals = nullptr
 
uint16 heapSize = 0
 
uint8heapStart = nullptr
 
void * nativeFunctionCallbackContext = nullptr
 
const NativeFunctionnativeFunctions
 
int numNativeFunctions = 0
 
int32stackEnd = nullptr
 
int32stackStart = nullptr
 

Detailed Description

template<int programAndHeapSpace, int stackAndGlobalsSpace>
struct littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >

Loads a program, and lets the user execute its functions.

The programAndHeapSpace is the number of bytes allocated for program + heap. stackAndGlobalsSpace is the size of the globals + stack area.

Memory layout:

Program code goes at address 0, followed by any shared data the program needs globals are at the top end of the buffer stack space stretches downwards from the start of the globals

{Blocks}

Member Enumeration Documentation

◆ ErrorCode

template<int programAndHeapSpace, int stackAndGlobalsSpace>
enum littlefoot::Runner::ErrorCode : uint8
strong

Return codes from a function call.

Enumerator
ok 
executionTimedOut 
unknownInstruction 
stackOverflow 
stackUnderflow 
illegalAddress 
divisionByZero 
unknownFunction 

Constructor & Destructor Documentation

◆ Runner()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::Runner ( )
inlinenoexcept

Member Function Documentation

◆ callFunction() [1/2]

template<int programAndHeapSpace, int stackAndGlobalsSpace>
ErrorCode littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::callFunction ( const char *  functionSignature)
inlinenoexcept

Calls one of the functions in the program, by its textual signature.

References littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::FunctionExecutionContext::run().

◆ callFunction() [2/2]

template<int programAndHeapSpace, int stackAndGlobalsSpace>
ErrorCode littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::callFunction ( FunctionID  function)
inlinenoexcept

Calls one of the functions in the program, by its function ID.

References littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::FunctionExecutionContext::run().

◆ clearHeapAndGlobals()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
void littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::clearHeapAndGlobals ( )
inlinenoexcept

Clears all the non-program data.

◆ getErrorDescription()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
static const char* littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::getErrorDescription ( ErrorCode  e)
inlinestaticnoexcept

Returns a text description for an error code.

◆ getHeapBits()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
uint32 littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::getHeapBits ( uint32  startBit,
uint32  numBits 
) const
inlinenoexcept

◆ getHeapByte()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
uint8 littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::getHeapByte ( uint32  index) const
inlinenoexcept

◆ getHeapInt()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
int32 littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::getHeapInt ( uint32  byteOffset) const
inlinenoexcept

◆ getMaximumProgramSize()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
static uint32 littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::getMaximumProgramSize ( )
inlinestaticnoexcept

◆ getNativeFunction()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
const NativeFunction& littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::getNativeFunction ( int  index) const
inlinenoexcept

Returns one of the native functions available.

The index must not be out of range.

References jassert.

◆ getNumNativeFunctions()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
int littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::getNumNativeFunctions ( ) const
inlinenoexcept

Returns the number of native functions available.

◆ getProgramAndDataEnd()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
uint8* littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::getProgramAndDataEnd ( ) const
inlinenoexcept

◆ getProgramAndDataSize()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
uint32 littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::getProgramAndDataSize ( ) const
inlinenoexcept

◆ getProgramAndDataStart()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
uint8* littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::getProgramAndDataStart ( ) const
inlinenoexcept

◆ getProgramHeapEnd()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
uint8* littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::getProgramHeapEnd ( ) const
inlinenoexcept

◆ getProgramHeapSize()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
uint16 littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::getProgramHeapSize ( ) const
inlinenoexcept

◆ getProgramHeapStart()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
uint8* littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::getProgramHeapStart ( ) const
inlinenoexcept

◆ isProgramValid()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
bool littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::isProgramValid ( ) const
inlinenoexcept

◆ reinitialiseProgramLayoutIfProgramHasChanged()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
Runner& littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::reinitialiseProgramLayoutIfProgramHasChanged ( )
inlineprivatenoexcept

◆ reset()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
void littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::reset ( )
inlinenoexcept

Clears the memory state.

◆ setDataByte()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
void littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::setDataByte ( uint32  index,
uint8  value 
)
inlinenoexcept

Sets a byte of data.

◆ setHeapByte()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
void littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::setHeapByte ( uint32  index,
uint8  value 
)
inlinenoexcept

◆ setHeapInt()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
int32 littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::setHeapInt ( uint32  byteOffset,
uint32  value 
)
inlinenoexcept

◆ setNativeFunctions()

template<int programAndHeapSpace, int stackAndGlobalsSpace>
void littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::setNativeFunctions ( const NativeFunction functions,
int  numFunctions,
void *  userDataForCallback 
)
inlinenoexcept

Installs an array of native functions that the code can use.

Note that this doesn't take ownership of any memory involved, so the caller mustn't pass any dangling pointers

Member Data Documentation

◆ allMemory

template<int programAndHeapSpace, int stackAndGlobalsSpace>
uint8 littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::allMemory[((programAndHeapSpace+stackAndGlobalsSpace)+3) &~3]

◆ globals

template<int programAndHeapSpace, int stackAndGlobalsSpace>
int32* littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::globals = nullptr
private

◆ heapSize

template<int programAndHeapSpace, int stackAndGlobalsSpace>
uint16 littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::heapSize = 0
private

◆ heapStart

template<int programAndHeapSpace, int stackAndGlobalsSpace>
uint8* littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::heapStart = nullptr
private

◆ nativeFunctionCallbackContext

template<int programAndHeapSpace, int stackAndGlobalsSpace>
void* littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::nativeFunctionCallbackContext = nullptr
private

◆ nativeFunctions

template<int programAndHeapSpace, int stackAndGlobalsSpace>
const NativeFunction* littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::nativeFunctions
private

◆ numNativeFunctions

template<int programAndHeapSpace, int stackAndGlobalsSpace>
int littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::numNativeFunctions = 0
private

◆ program

template<int programAndHeapSpace, int stackAndGlobalsSpace>
Program littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::program

◆ stackEnd

template<int programAndHeapSpace, int stackAndGlobalsSpace>
int32* littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::stackEnd = nullptr
private

◆ stackStart

template<int programAndHeapSpace, int stackAndGlobalsSpace>
int32* littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::stackStart = nullptr
private

◆ totalProgramAndHeapSpace

template<int programAndHeapSpace, int stackAndGlobalsSpace>
constexpr uint32 littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::totalProgramAndHeapSpace = programAndHeapSpace
static

◆ totalStackAndGlobalsSpace

template<int programAndHeapSpace, int stackAndGlobalsSpace>
constexpr uint32 littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::totalStackAndGlobalsSpace = stackAndGlobalsSpace
static

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