Loads a program, and lets the user execute its functions. More...
#include <juce_blocks_basics.h>
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 NativeFunction & | getNativeFunction (int index) const noexcept |
Returns one of the native functions available. More... | |
int | getNumNativeFunctions () const noexcept |
Returns the number of native functions available. More... | |
uint8 * | getProgramAndDataEnd () const noexcept |
uint32 | getProgramAndDataSize () const noexcept |
uint8 * | getProgramAndDataStart () const noexcept |
uint8 * | getProgramHeapEnd () const noexcept |
uint16 | getProgramHeapSize () const noexcept |
uint8 * | getProgramHeapStart () 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 | |
Runner & | reinitialiseProgramLayoutIfProgramHasChanged () noexcept |
Private Attributes | |
int32 * | globals = nullptr |
uint16 | heapSize = 0 |
uint8 * | heapStart = nullptr |
void * | nativeFunctionCallbackContext = nullptr |
const NativeFunction * | nativeFunctions |
int | numNativeFunctions = 0 |
int32 * | stackEnd = nullptr |
int32 * | stackStart = nullptr |
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
|
strong |
|
inlinenoexcept |
|
inlinenoexcept |
Calls one of the functions in the program, by its textual signature.
|
inlinenoexcept |
Calls one of the functions in the program, by its function ID.
|
inlinenoexcept |
Clears all the non-program data.
|
inlinestaticnoexcept |
Returns a text description for an error code.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinestaticnoexcept |
|
inlinenoexcept |
Returns one of the native functions available.
The index must not be out of range.
|
inlinenoexcept |
Returns the number of native functions available.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineprivatenoexcept |
|
inlinenoexcept |
Clears the memory state.
|
inlinenoexcept |
Sets a byte of data.
|
inlinenoexcept |
|
inlinenoexcept |
|
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
uint8 juce::littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::allMemory[((programAndHeapSpace+stackAndGlobalsSpace)+3) &~3] |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Program juce::littlefoot::Runner< programAndHeapSpace, stackAndGlobalsSpace >::program |
|
private |
|
private |
|
static |
|
static |