Simple Virtual Machine
A simple but flexible virtual machine
SVM symbols in code

This module contains API functions to handle symbols in SVM code. More...

Functions

SVM_FUNCTION SVM_Boolean svm_code_symbol_has_address (const void *svm, const SVM_Code code, const SVM_Value_String label)
 This function checks whether a SVM code defines a symbol given as a string value. More...
 
SVM_FUNCTION SVM_Boolean svm_code_symbol_has_address__string (const void *svm, const SVM_Code code, const SVM_String label)
 This function checks whether a SVM code defines a symbol given as a SVM_String. More...
 
SVM_FUNCTION SVM_Boolean svm_code_symbol_has_address__raw (const void *svm, const SVM_Code code, const char *label)
 This function checks whether a SVM code defines a symbol given as a C nul-terminated string. More...
 
SVM_FUNCTION SVM_Value_Stringsvm_code_symbol_list (const void *svm, const SVM_Code code)
 This function returns all symbols defined in a SVM code. More...
 
SVM_FUNCTION SVM_Value_Symbol svm_code_symbol_get_address (const void *svm, const SVM_Code code, const SVM_Value_String label)
 This function solves a symbol in a SVM code given as a string value. More...
 
SVM_FUNCTION SVM_Value_Symbol svm_code_symbol_get_address__string (const void *svm, const SVM_Code code, const SVM_String label)
 This function solves a symbol in a SVM code given as a SVM_String. More...
 
SVM_FUNCTION SVM_Value_Symbol svm_code_symbol_get_address__raw (const void *svm, const SVM_Code code, const char *label)
 This function solves a symbol in a SVM code given as a C nul-terminated string. More...
 

Detailed Description

This module contains API functions to handle symbols in SVM code.

Function Documentation

◆ svm_code_symbol_get_address()

SVM_FUNCTION SVM_Value_Symbol svm_code_symbol_get_address ( const void *  svm,
const SVM_Code  code,
const SVM_Value_String  label 
)

This function solves a symbol in a SVM code given as a string value.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]codeThe code to be diagnosed.
[in]labelThe label to solve.
Returns
The symbol value containing the global address corresponding to the label.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the label does not allow a global jump in the code.

◆ svm_code_symbol_get_address__raw()

SVM_FUNCTION SVM_Value_Symbol svm_code_symbol_get_address__raw ( const void *  svm,
const SVM_Code  code,
const char *  label 
)

This function solves a symbol in a SVM code given as a C nul-terminated string.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]codeThe code to be diagnosed.
[in]labelThe label to solve.
Returns
The symbol value containing the global address corresponding to the label.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the label does not allow a global jump in the code.

◆ svm_code_symbol_get_address__string()

SVM_FUNCTION SVM_Value_Symbol svm_code_symbol_get_address__string ( const void *  svm,
const SVM_Code  code,
const SVM_String  label 
)

This function solves a symbol in a SVM code given as a SVM_String.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]codeThe code to be diagnosed.
[in]labelThe label to solve.
Returns
The symbol value containing the global address corresponding to the label.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the label does not allow a global jump in the code.

◆ svm_code_symbol_has_address()

SVM_FUNCTION SVM_Boolean svm_code_symbol_has_address ( const void *  svm,
const SVM_Code  code,
const SVM_Value_String  label 
)

This function checks whether a SVM code defines a symbol given as a string value.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]codeThe code to be diagnosed.
[in]labelThe label to solve.
Returns
TRUE if the symbol is eligible to a global call in the SVM code, FALSE otherwise.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)

◆ svm_code_symbol_has_address__raw()

SVM_FUNCTION SVM_Boolean svm_code_symbol_has_address__raw ( const void *  svm,
const SVM_Code  code,
const char *  label 
)

This function checks whether a SVM code defines a symbol given as a C nul-terminated string.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]codeThe code to be diagnosed.
[in]labelThe label to solve.
Returns
TRUE if the symbol is eligible to a global call in the SVM code, FALSE otherwise.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)

◆ svm_code_symbol_has_address__string()

SVM_FUNCTION SVM_Boolean svm_code_symbol_has_address__string ( const void *  svm,
const SVM_Code  code,
const SVM_String  label 
)

This function checks whether a SVM code defines a symbol given as a SVM_String.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]codeThe code to be diagnosed.
[in]labelThe label to solve.
Returns
TRUE if the symbol is eligible to a global call in the SVM code, FALSE otherwise.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)

◆ svm_code_symbol_list()

SVM_FUNCTION SVM_Value_String * svm_code_symbol_list ( const void *  svm,
const SVM_Code  code 
)

This function returns all symbols defined in a SVM code.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]codeThe code to be introspected.

This function returns all symbols of a SVM code. Labels are not returned by this function.

Returns
A NULL terminated array of string values containing the symbol names.
Note
The returned array is a valid SVM variable: its scope can be changed if needed, and the pointer shall not be freed explicitely.

Usage example:

for( ; !label ; ++label) // we don't need to keep label on the first label
{
SVM_Value_Symbol symbol = svm_code_symbol_get_address(svm,code,*label);
// ...
}
SVM_TYPE typedef const void * SVM_Value_String
This type is used to represent a string the SVM can store in one of its memories.
Definition: svm.h:548
SVM_TYPE typedef const void * SVM_Value_Symbol
This type is used to represent a symbol the SVM can store in one of its memories.
Definition: svm.h:592
SVM_FUNCTION SVM_Value_Symbol svm_code_symbol_get_address(const void *svm, const SVM_Code code, const SVM_Value_String label)
This function solves a symbol in a SVM code given as a string value.
SVM_FUNCTION SVM_Value_String * svm_code_symbol_list(const void *svm, const SVM_Code code)
This function returns all symbols defined in a SVM code.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
See also
svm_code_label_list