Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Bond::CodeSegment Class Reference

Collection of functions, static initializers and data loaded from CBO files. More...

#include <bond/vm/codesegment.h>

Public Member Functions

 CodeSegment (const Function *functionTable, size_t functionCount, const Function *staticInitializerTable, size_t staticInitializerCount, const DataEntry *dataTable, size_t dataCount)
 Constructs a CodeSegment from prebuilt tables.
const FunctionGetFunction (const QualifiedName &qualifiedName) const
 Finds a function by qualified name.
const FunctionGetFunction (const char *qualifiedName) const
 Finds a function by qualified name string.
int32_t GetFunctionIndex (const QualifiedName &qualifiedName) const
 Gets the index of a function by qualified name.
int32_t GetFunctionIndex (const char *qualifiedName) const
 Gets the index of a function by qualified name string.
const FunctionGetFunctionAtIndex (uint32_t functionIndex) const
 Returns the function at the specified index.
size_t GetFunctionCount () const
 Returns the number of functions in the function table.
const FunctionGetStaticInitializerAtIndex (uint32_t initializerIndex) const
 Returns the static initializer at the specified index.
size_t GetStaticInitializerCount () const
 Returns the number of static initializers.
const DataEntryGetDataEntry (const QualifiedName &qualifiedName) const
 Finds a data entry by qualified name.
const DataEntryGetDataEntry (const char *qualifiedName) const
 Finds a data entry by qualified name string.
int32_t GetDataEntryIndex (const QualifiedName &qualifiedName) const
 Gets the index of a data entry by qualified name.
int32_t GetDataEntryIndex (const char *qualifiedName) const
 Gets the index of a data entry by qualified name string.
const DataEntryGetDataEntryAtIndex (uint32_t dataIndex) const
 Returns the data entry at the specified index.
size_t GetDataCount () const
 Returns the number of data entries in the data table.
void CallStaticInitializers (VM &vm) const
 Calls all static initializer functions in this code segment.

Detailed Description

Collection of functions, static initializers and data loaded from CBO files.

A CodeSegment is produced by CboLoader and consumed by the VM. It supports looking up functions and data entries by qualified name, and calling static initializers before an application's entry point is invoked.

Constructor & Destructor Documentation

◆ CodeSegment()

Bond::CodeSegment::CodeSegment ( const Function * functionTable,
size_t functionCount,
const Function * staticInitializerTable,
size_t staticInitializerCount,
const DataEntry * dataTable,
size_t dataCount )
inline

Constructs a CodeSegment from prebuilt tables.

Parameters
functionTableArray of callable functions.
functionCountNumber of entries in functionTable.
staticInitializerTableArray of static initializer functions.
staticInitializerCountNumber of entries in staticInitializerTable.
dataTableArray of named data entries.
dataCountNumber of entries in dataTable.

Member Function Documentation

◆ CallStaticInitializers()

void Bond::CodeSegment::CallStaticInitializers ( VM & vm) const

Calls all static initializer functions in this code segment.

Parameters
vmVM instance used to invoke initializer functions.

◆ GetDataCount()

size_t Bond::CodeSegment::GetDataCount ( ) const
inline

Returns the number of data entries in the data table.

Returns
Data table size.

◆ GetDataEntry() [1/2]

const DataEntry * Bond::CodeSegment::GetDataEntry ( const char * qualifiedName) const

Finds a data entry by qualified name string.

Parameters
qualifiedNameFully qualified data entry name string.
Returns
Pointer to the data entry, or nullptr if it is not found.

◆ GetDataEntry() [2/2]

const DataEntry * Bond::CodeSegment::GetDataEntry ( const QualifiedName & qualifiedName) const

Finds a data entry by qualified name.

Parameters
qualifiedNameFully qualified data entry name.
Returns
Pointer to the data entry, or nullptr if it is not found.

◆ GetDataEntryAtIndex()

const DataEntry & Bond::CodeSegment::GetDataEntryAtIndex ( uint32_t dataIndex) const
inline

Returns the data entry at the specified index.

Parameters
dataIndexIndex of the data entry in the data table.
Returns
Reference to the data entry at dataIndex.

◆ GetDataEntryIndex() [1/2]

int32_t Bond::CodeSegment::GetDataEntryIndex ( const char * qualifiedName) const

Gets the index of a data entry by qualified name string.

Parameters
qualifiedNameFully qualified data entry name string.
Returns
Data entry index, or -1 if it is not found.

◆ GetDataEntryIndex() [2/2]

int32_t Bond::CodeSegment::GetDataEntryIndex ( const QualifiedName & qualifiedName) const

Gets the index of a data entry by qualified name.

Parameters
qualifiedNameFully qualified data entry name.
Returns
Data entry index, or -1 if it is not found.

◆ GetFunction() [1/2]

const Function * Bond::CodeSegment::GetFunction ( const char * qualifiedName) const

Finds a function by qualified name string.

Parameters
qualifiedNameFully qualified function name string.
Returns
Pointer to the function, or nullptr if it is not found.

◆ GetFunction() [2/2]

const Function * Bond::CodeSegment::GetFunction ( const QualifiedName & qualifiedName) const

Finds a function by qualified name.

Parameters
qualifiedNameFully qualified function name.
Returns
Pointer to the function, or nullptr if it is not found.

◆ GetFunctionAtIndex()

const Function & Bond::CodeSegment::GetFunctionAtIndex ( uint32_t functionIndex) const
inline

Returns the function at the specified index.

Parameters
functionIndexIndex of the function in the function table.
Returns
Reference to the function at functionIndex.

◆ GetFunctionCount()

size_t Bond::CodeSegment::GetFunctionCount ( ) const
inline

Returns the number of functions in the function table.

Returns
Function table size.

◆ GetFunctionIndex() [1/2]

int32_t Bond::CodeSegment::GetFunctionIndex ( const char * qualifiedName) const

Gets the index of a function by qualified name string.

Parameters
qualifiedNameFully qualified function name string.
Returns
Function index, or -1 if it is not found.

◆ GetFunctionIndex() [2/2]

int32_t Bond::CodeSegment::GetFunctionIndex ( const QualifiedName & qualifiedName) const

Gets the index of a function by qualified name.

Parameters
qualifiedNameFully qualified function name.
Returns
Function index, or -1 if it is not found.

◆ GetStaticInitializerAtIndex()

const Function & Bond::CodeSegment::GetStaticInitializerAtIndex ( uint32_t initializerIndex) const
inline

Returns the static initializer at the specified index.

Parameters
initializerIndexIndex of the static initializer.
Returns
Reference to the static initializer at initializerIndex.

◆ GetStaticInitializerCount()

size_t Bond::CodeSegment::GetStaticInitializerCount ( ) const
inline

Returns the number of static initializers.

Returns
Static initializer table size.

The documentation for this class was generated from the following file:
  • include/bond/vm/codesegment.h