Embryo (3) - Linux Manuals

Embryo: Embryo virtual machine library.

NAME

Embryo.h - Embryo virtual machine library.

SYNOPSIS


Defines


#define EMBRYO_FUNCTION_NONE 0x7fffffff
An invalid/non-existant function.
#define EMBRYO_FUNCTION_MAIN -1
Start at program entry point.
#define EMBRYO_FUNCTION_CONT -2
Continue from last address.
#define EMBRYO_CELL_NONE 0x7fffffff
An invalid cell reference.
#define EMBRYO_PROGRAM_OK 1
Program was run successfully.
#define EMBRYO_PROGRAM_SLEEP 2
The program's execution was interrupted by a Small sleep command.
#define EMBRYO_PROGRAM_FAIL 0
An error in the program caused it to fail.
#define EMBRYO_FLOAT_TO_CELL(f) ((Embryo_Float_Cell) f).c
Float to Embryo_Cell.
#define EMBRYO_CELL_TO_FLOAT(c) ((Embryo_Float_Cell) c).f
Embryo_Cell to float.

Enumerations


enum { , EMBRYO_ERROR_ASSERT, EMBRYO_ERROR_STACKERR, EMBRYO_ERROR_BOUNDS, EMBRYO_ERROR_MEMACCESS, EMBRYO_ERROR_INVINSTR, EMBRYO_ERROR_STACKLOW, EMBRYO_ERROR_HEAPLOW, EMBRYO_ERROR_CALLBACK, EMBRYO_ERROR_NATIVE, EMBRYO_ERROR_DIVIDE, EMBRYO_ERROR_SLEEP, EMBRYO_ERROR_MEMORY = 16, EMBRYO_ERROR_FORMAT, EMBRYO_ERROR_VERSION, EMBRYO_ERROR_NOTFOUND, EMBRYO_ERROR_INDEX, EMBRYO_ERROR_DEBUG, EMBRYO_ERROR_INIT, EMBRYO_ERROR_USERDATA, EMBRYO_ERROR_INIT_JIT, EMBRYO_ERROR_PARAMS, EMBRYO_ERROR_DOMAIN }

Functions


EAPI int embryo_init (void)
Initialises the Embryo library.
EAPI int embryo_shutdown (void)
Shuts down the Embryo library.
EAPI Embryo_Program * embryo_program_new (void *data, int size)
Creates a new Embryo program, with bytecode data that can be freed.
EAPI Embryo_Program * embryo_program_const_new (void *data, int size)
Creates a new Embryo program, with bytecode data that cannot be freed.
EAPI Embryo_Program * embryo_program_load (char *file)
Creates a new Embryo program based on the bytecode data stored in the given file.
EAPI void embryo_program_free (Embryo_Program *ep)
Frees the given Embryo program.
EAPI void embryo_program_native_call_add (Embryo_Program *ep, const char *name, Embryo_Cell(*func)(Embryo_Program *ep, Embryo_Cell *params))
Adds a native program call to the given Embryo program.
EAPI void embryo_program_vm_reset (Embryo_Program *ep)
Resets the current virtual machine session of the given program.
EAPI void embryo_program_vm_push (Embryo_Program *ep)
Starts a new virtual machine session for the given program.
EAPI void embryo_program_vm_pop (Embryo_Program *ep)
Frees the current virtual machine session associated with the given program.
EAPI void embryo_swap_16 (unsigned short *v)
Ensures that the given unsigned short integer is in the small endian format.
EAPI void embryo_swap_32 (unsigned int *v)
Ensures that the given unsigned integer is in the small endian format.
EAPI Embryo_Function embryo_program_function_find (Embryo_Program *ep, const char *name)
Returns the function in the given program with the given name.
EAPI Embryo_Cell embryo_program_variable_find (Embryo_Program *ep, const char *name)
Retrieves the location of the public variable in the given program with the given name.
EAPI int embryo_program_variable_count_get (Embryo_Program *ep)
Retrieves the number of public variables in the given program.
EAPI Embryo_Cell embryo_program_variable_get (Embryo_Program *ep, int num)
Retrieves the location of the public variable in the given program with the given identifier.
EAPI void embryo_program_error_set (Embryo_Program *ep, int error)
Sets the error code for the given program to the given code.
EAPI int embryo_program_error_get (Embryo_Program *ep)
Retrieves the current error code for the given program.
EAPI void embryo_program_data_set (Embryo_Program *ep, void *data)
Sets the data associated to the given program.
EAPI void * embryo_program_data_get (Embryo_Program *ep)
Retrieves the data associated to the given program.
EAPI const char * embryo_error_string_get (int error)
Retrieves a string describing the given error code.
EAPI int embryo_data_string_length_get (Embryo_Program *ep, Embryo_Cell *str_cell)
Retrieves the length of the string starting at the given cell.
EAPI void embryo_data_string_get (Embryo_Program *ep, Embryo_Cell *str_cell, char *dst)
Copies the string starting at the given cell to the given buffer.
EAPI void embryo_data_string_set (Embryo_Program *ep, const char *src, Embryo_Cell *str_cell)
Copies string in the given buffer into the virtual machine memory starting at the given cell.
EAPI Embryo_Cell * embryo_data_address_get (Embryo_Program *ep, Embryo_Cell addr)
Retreives a pointer to the address in the virtual machine given by the given cell.
EAPI Embryo_Cell embryo_data_heap_push (Embryo_Program *ep, int cells)
Increases the size of the heap of the given virtual machine by the given number of Embryo_Cells.
EAPI void embryo_data_heap_pop (Embryo_Program *ep, Embryo_Cell down_to)
Decreases the size of the heap of the given virtual machine down to the given size.
EAPI int embryo_program_recursion_get (Embryo_Program *ep)
Returns the number of virtual machines are running for the given program.
EAPI int embryo_program_run (Embryo_Program *ep, Embryo_Function func)
Runs the given function of the given Embryo program in the current virtual machine.
EAPI Embryo_Cell embryo_program_return_value_get (Embryo_Program *ep)
Retreives the return value of the last called function of the given program.
EAPI void embryo_program_max_cycle_run_set (Embryo_Program *ep, int max)
Sets the maximum number of abstract machine cycles any given program run can execute before being put to sleep and returning.
EAPI int embryo_program_max_cycle_run_get (Embryo_Program *ep)
Retreives the maximum number of abstract machine cycles a program is allowed to run.
EAPI int embryo_parameter_cell_push (Embryo_Program *ep, Embryo_Cell cell)
Pushes an Embryo_Cell onto the function stack to use as a parameter for the next function that is called in the given program.
EAPI int embryo_parameter_string_push (Embryo_Program *ep, const char *str)
Pushes a string onto the function stack to use as a parameter for the next function that is called in the given program.
EAPI int embryo_parameter_cell_array_push (Embryo_Program *ep, Embryo_Cell *cells, int num)
Pushes an array of Embryo_Cells onto the function stack to be used as parameters for the next function that is called in the given program.

Detailed Description

Embryo virtual machine library.

This file includes the routines needed for Embryo library interaction. This is the only file you need to include.

Define Documentation

#define EMBRYO_FUNCTION_CONT -2

Continue from last address.

For use with embryo_program_run.

Referenced by embryo_program_run().

#define EMBRYO_FUNCTION_MAIN -1

Start at program entry point.

For use with embryo_program_run.

Referenced by embryo_program_run().

Enumeration Type Documentation

anonymous enum

Enumerator:

EMBRYO_ERROR_ASSERT
Forced exit.
EMBRYO_ERROR_STACKERR
Assertion failed.
EMBRYO_ERROR_BOUNDS
Stack/heap collision.
EMBRYO_ERROR_MEMACCESS
Index out of bounds.
EMBRYO_ERROR_INVINSTR
Invalid memory access.
EMBRYO_ERROR_STACKLOW
Invalid instruction.
EMBRYO_ERROR_HEAPLOW
Stack underflow.
EMBRYO_ERROR_CALLBACK
Heap underflow.
EMBRYO_ERROR_NATIVE
No callback, or invalid callback.
EMBRYO_ERROR_DIVIDE
Native function failed.
EMBRYO_ERROR_SLEEP
Divide by zero.
EMBRYO_ERROR_MEMORY
Go into sleepmode - code can be restarted.
EMBRYO_ERROR_FORMAT
Out of memory.
EMBRYO_ERROR_VERSION
Invalid file format.
EMBRYO_ERROR_NOTFOUND
File is for a newer version of the Embryo_Program.
EMBRYO_ERROR_INDEX
Function not found.
EMBRYO_ERROR_DEBUG
Invalid index parameter (bad entry point).
EMBRYO_ERROR_INIT
Debugger cannot run.
EMBRYO_ERROR_USERDATA
Embryo_Program not initialized (or doubly initialized).
EMBRYO_ERROR_INIT_JIT
Unable to set user data field (table full).
EMBRYO_ERROR_PARAMS
Cannot initialize the JIT.
EMBRYO_ERROR_DOMAIN
Parameter error.

Author

Generated automatically by Doxygen for Embryo from the source code.