Simple Virtual Machine
A simple but flexible virtual machine
SVM variables

This module contains API functions to handle variables. More...

Modules

 SVM variables scope
 This module contains API functions to handle the scope of variables.
 
 SVM variables detection
 This module contains API functions to detect variable types.
 

Functions

SVM_FUNCTION SVM_Variablesvm_variable_array_new (const void *svm, SVM_Size size)
 This function creates an array of variables. More...
 
SVM_FUNCTION void svm_variable_delete (const void *svm, const SVM_Variable variable)
 This function alters the scope of the given variable. More...
 

Detailed Description

This module contains API functions to handle variables.

A variable in this API refers to a generic pointer used as a key associated to an object internally managed by the virtual machine.

There are two ways to obtain a variable:

The scope of a variable can be:

The scope of the object associated to a variable can be different when:

Variables are equally comparable: Two variables being equal refer to the same associated object:

static SVM_Process process;
SVM_Value instruction_one(const void *svm, SVM_Size argc, SVM_Parameter argv[])
{
process = svm_process_get_current(svm);
return NULL;
}
SVM_Value instruction_two(const void *svm, SVM_Size argc, SVM_Parameter argv[])
{
if(svm_process_get_current(svm) == process)
{
// we get here only in the last process which invoked instruction one!
}
return NULL;
}
SVM_TYPE typedef unsigned long int SVM_Size
This type is used to represent an object size.
Definition: svm.h:257
SVM_TYPE typedef const void * SVM_Parameter
This type is used by the SVM to pass instruction parameters to the corresponding plugin function.
Definition: svm.h:180
SVM_TYPE typedef const void * SVM_Process
This type is used to represent an execution thread in the SVM.
Definition: svm.h:304
SVM_TYPE typedef const void * SVM_Value
This type is used to represent any value the SVM can store in one of its memories.
Definition: svm.h:530
SVM_FUNCTION SVM_Process svm_process_get_current(const void *svm)
This function retrieves the current process.
See also
SVM types

Function Documentation

◆ svm_variable_array_new()

SVM_FUNCTION SVM_Variable * svm_variable_array_new ( const void *  svm,
SVM_Size  size 
)

This function creates an array of variables.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]sizeThe size of the array.
Returns
A pointer to a C array of SVM_Variable. Every cell of the array has to be initialised by a value before being passed to an API function.
Note
The returned array is a valid SVM variable: its scope can be changed if needed, and the pointer shall not be freed explicitely.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)

◆ svm_variable_delete()

SVM_FUNCTION void svm_variable_delete ( const void *  svm,
const SVM_Variable  variable 
)

This function alters the scope of the given variable.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]variableThe variable to free.

This variable becomes immediately invisible.

The object associated to this variable may be deleted immediately.

Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)