Loads CBO modules and resolves their native function bindings.
More...
#include <bond/vm/cboloader.h>
Loads CBO modules and resolves their native function bindings.
A CboLoader aggregates one or more CBO inputs, combines their contents into a single CodeSegment, and binds native functions from supplied NativeBindingCollections.
◆ CboLoader() [1/3]
| Bond::CboLoader::CboLoader |
( |
Allocator & | allocator | ) |
|
|
inlineexplicit |
Constructs a CboLoader using the same allocator for temporary and persistent data.
- Parameters
-
| allocator | The allocator used while loading and for the resulting CodeSegment. |
◆ CboLoader() [2/3]
Constructs a CboLoader with separate allocators for temporary and persistent data.
- Parameters
-
◆ CboLoader() [3/3]
| Bond::CboLoader::CboLoader |
( |
const CboLoader & | other | ) |
|
|
delete |
◆ AddCboFile() [1/2]
| void Bond::CboLoader::AddCboFile |
( |
const void * | byteCode, |
|
|
size_t | length ) |
|
inline |
Adds an in-memory CBO file.
- Parameters
-
| byteCode | Pointer to the CBO byte stream. The bytes are not copied and must remain valid until Load() returns. |
| length | Number of bytes in the CBO stream. |
◆ AddCboFile() [2/2]
| void Bond::CboLoader::AddCboFile |
( |
InputStream & | cboStream | ) |
|
|
inline |
Adds a CBO file stream.
- Parameters
-
| cboStream | Input stream containing CBO data. The stream is not copied and must remain valid until Load() returns. |
◆ AddNativeBinding()
Adds a collection of native function bindings used to resolve native declarations.
- Parameters
-
| nativeBinding | Native binding collection to search when binding native functions. The collection is not copied and must remain valid until Load() returns. |
◆ Load()
Loads all added CBO files and returns the merged code segment.
Each CBO is validated with a CboValidator, after which its contents are copied into a single block of memory allocated from the persistent allocator, so the CBO streams are no longer needed once this function returns. Native functions are bound to the functions in the added NativeBindingCollections and references to functions and data are resolved by name.
A Bond::Exception is thrown if a CBO is invalid or was compiled for a different pointer size, if a function or global variable is defined more than once, if a native binding names a function that does not exist or is not native, if a native function has no binding, or if a referenced function or global variable is not defined.
- Returns
- A CodeSegmentHandle owning the loaded CodeSegment.
◆ operator=()
The documentation for this class was generated from the following file:
- include/bond/vm/cboloader.h