The activation record of a function invoked by a VM.
More...
#include <bond/vm/vm.h>
The activation record of a function invoked by a VM.
A StackFrame gives access to the arguments and return value of a function call. Native functions receive the StackFrame of their own invocation, through which they read their arguments with GetArg() and set their return value with SetReturnValue(). StackFrames are created and destroyed by the VM and by InvocationStackFrame; they are not constructed directly by applications.
- See also
- InvocationStackFrame, NativeFunction, VM
◆ StackFrame() [1/3]
| Bond::StackFrame::StackFrame |
( |
VM & | vm | ) |
|
|
inlineexplicit |
Constructs a StackFrame object that is not associated with any function.
- Parameters
-
| vm | The VM that owns the stack frame. |
◆ StackFrame() [2/3]
| Bond::StackFrame::StackFrame |
( |
VM & | vm, |
|
|
const Function & | function, |
|
|
uint8_t * | framePointer, |
|
|
uint8_t * | stackPointer, |
|
|
uint8_t * | returnPointer ) |
|
inline |
Constructs a StackFrame object for an invocation of the given function.
- Parameters
-
| vm | The VM that owns the stack frame. |
| function | The function being invoked. |
| framePointer | Pointer to the base of the function's frame on the VM stack, relative to which its arguments and local variables are addressed. |
| stackPointer | Pointer to the top of the function's frame on the VM stack. |
| returnPointer | Pointer to where the function's return value is written, or null if the function returns void. |
◆ StackFrame() [3/3]
| Bond::StackFrame::StackFrame |
( |
const StackFrame & | other | ) |
|
|
delete |
◆ GetArg()
template<typename ArgType>
| const ArgType & Bond::StackFrame::GetArg |
( |
size_t | index | ) |
const |
Returns a reference to an argument of the invoked function.
When BOND_RUNTIME_CHECKS_ENABLED is non-zero, a Bond::Exception is thrown if the index is out of range or if ArgType does not match the type of the parameter. Integer types match any Bond integer type of the same size, regardless of signedness.
- Template Parameters
-
| ArgType | The native type of the argument. |
- Parameters
-
| index | The zero-based index of the argument. |
◆ GetCollector() [1/2]
| Collector & Bond::StackFrame::GetCollector |
( |
| ) |
|
|
inline |
Returns the Collector whose Collectable objects are destroyed when the stack frame is popped off of the VM's call stack.
A native function that allocates memory or objects on behalf of the calling Bond function typically registers them with the Collector of the caller's stack frame, obtained with VM::GetCallerStackFrame(), so that they live until the caller returns.
◆ GetCollector() [2/2]
| const Collector & Bond::StackFrame::GetCollector |
( |
| ) |
const |
|
inline |
Returns the Collector whose Collectable objects are destroyed when the stack frame is popped off of the VM's call stack.
◆ GetVM() [1/2]
| VM & Bond::StackFrame::GetVM |
( |
| ) |
|
|
inline |
Returns the VM that owns the stack frame.
◆ GetVM() [2/2]
| const VM & Bond::StackFrame::GetVM |
( |
| ) |
const |
|
inline |
Returns the VM that owns the stack frame.
◆ operator=()
◆ SetReturnValue()
template<typename ReturnType>
| void Bond::StackFrame::SetReturnValue |
( |
const ReturnType & | returnValue | ) |
|
Sets the return value of the invoked function.
Integers smaller than 32 bits are widened to 32 bits according to the Bond return type, and enums are stored as their underlying type. When BOND_RUNTIME_CHECKS_ENABLED is non-zero, a Bond::Exception is thrown if ReturnType does not match the return type of the function.
- Template Parameters
-
| ReturnType | The native type of the return value. |
- Parameters
-
| returnValue | The value to be returned. |
◆ InvocationStackFrame
| friend class InvocationStackFrame |
|
friend |
◆ VM
The documentation for this class was generated from the following file: