XCLE



Execution module

Instructions manual


XCLE: eXtensible Concatenative Language Engine
Copyright (C) 2000-2006 Yann LANDRIN-SCHWEITZER a.k.a. Varkhan


This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


Author: Yann LANDRIN-SCHWEITZER
Contact: varkhan@varkhan.net
Homepage: http://www.varkhan.net/


Return status management


Macro XCLE_EXCEPTION_OK

XCLE_Exception XCLE_EXCEPTION_OK ;
The Exception returned when execution was successful.

Note:
The comparison operator == can be used to test whether an XCLE_Exception
is the same as XCLE_EXCEPTION_OK (since this is a static pointer value).




Function XCLE_ExceptionNew

XCLE_Exception XCLE_ExceptionNew(unsigned long ident, char * messg) ;
Creates a new XCLE_Exception with the specified error number, exception identifier, and message.

Args:
ident: error identifier number
messg: description of the error


Returns:
NULL: if the memory could not be allocated
XCLE_EXCEPTION_OK: XCLE_ExceptionNew(0,NULL)
else a new XCLE_Exception.


Errors:
ENOMEM: if new memory could not be allocated



Function XCLE_ExceptionCopy

XCLE_Exception XCLE_ExceptionCopy(XCLE_Exception exp) ;
Creates a memory copy of the given exception.

Args:
exp: the original exception


Returns:
NULL: if the memory could not be allocated
XCLE_EXCEPTION_OK: if XCLE_EXCEPTION_OK was passed as argument
else a new XCLE_Exception.


Errors:
ENOMEM: if new memory could not be allocated
EINVAL: if a NULL XCLE_Exception was passed as argument



Function XCLE_ExceptionIdent

unsigned long XCLE_ExceptionIdent(XCLE_Exception exp) ;
Returns the error identifier of an exception.

Args:
exp: the exception


Returns:
-1: if a NULL XCLE_Exception was passed as argument
0: if XCLE_EXCEPTION_OK was passed as argument
else the exception's error identifier


Errors:
EINVAL: if a NULL XCLE_Exception was passed as argument



Function XCLE_ExceptionMessg

const char * XCLE_ExceptionMessg(XCLE_Exception exp) ;
Returns the message string of an exception.

Args:
exp: the exception


Returns:
NULL: if a NULL XCLE_Exception was passed as argument
"": if XCLE_EXCEPTION_OK was passed as argument
else the exception's message string


Errors:
EINVAL: if a NULL XCLE_Exception was passed as argument



Function XCLE_ExceptionFree

void XCLE_ExceptionFree(XCLE_Exception exp) ;
Frees an XCLE_Exception.

Args:
exp: XCLE_Exception to free


Note:
Freeing XCLE_EXCEPTION_OK using XCLE_ExceptionFree does nothing




Function XCLE_ExecCtxAlloc

XCLE_ExecCtx XCLE_ExecCtxAlloc(unsigned long chksz) ;
Allocates an execution context.

Args:
chksz: the chunk size used for the exception stack


Returns:
NULL: if the memory could not be allocated
else a new, empty, execution context.


Errors:
ENOMEM: if new memory could not be allocated



Function XCLE_ExecCtxFree

void XCLE_ExecCtxFree(XCLE_ExecCtx ctx) ;
Frees an execution context, along any eventual pending exception.

Args:
ctx: the execution context to free




Function XCLE_ExecCtxThrow

XCLE_ExecCtx XCLE_ExecCtxThrow(XCLE_ExecCtx ctx, char * src, XCLE_Exception exp) ;
Throws an exception in this context.

Args:
ctx: the execution context
src: the name of the calling code
exp: the exception to throw


Returns:
NULL: if 'ctx', 'src', or 'exp' were NULL
else the original context, with the exception added to the pending queue


Errors:
ENOMEM: if new memory could not be allocated
EINVAL: if 'ctx', 'src', or 'exp' were NULL

Note:
Nothing is done if exp is XCLE_EXCEPTION_OK.




Function XCLE_ExecCtxCatch

XCLE_Exception XCLE_ExecCtxCatch(XCLE_ExecCtx ctx) ;
Catches the last thrown exception.

Args:
ctx: the execution context


Returns:
NULL: if the execution context was NULL
XCLE_EXCEPTION_OK: if no exception was pending in this context
else the last thrown exception


Errors:
EINVAL: if the execution context was NULL



Function XCLE_ExecCtxClear

XCLE_ExecCtx XCLE_ExecCtxClear(XCLE_ExecCtx ctx) ;
Clears all pending exceptions in this context.

Args:
ctx: the execution context


Returns:
NULL: if the execution context was NULL
else the original execution context


Errors:
EINVAL: if the execution context was NULL



Function XCLE_ExecCtxMapExceptions

unsigned long XCLE_ExecCtxMapExceptions(XCLE_ExecCtx ctx, , void * dat) ;
Maps all pending exceptions in an execution context (e.g. for displaying).

Args:
ctx: the execution context
map: the mapping handler
dat: user-data pointer


Returns:
NULL: if the execution context or the map handler were NULL
else the sum of all values returned by 'map'


Errors:
EINVAL: if the execution context or the map handler were NULL

Note:
The map handler takes, in order, the informations pertaining to the exception's
calling code, and the exception nature:
lev: the depth of the currently mapped exception (0 for the root exception)
src: the name of the calling code
idt: the exception's identification number
msg: the exception's description
dat: user-defined data pointer (the last argument of XCLE_ExecCtxMapExceptions)




Typedef XCLE_CodeOperator

typedef XCLE_Exception (* XCLE_CodeOperator) (XCLE_ExecCtx, XCLE_Stack, XCLE_Hash, XCLE_Object) ;
The type of the handler segment of Code objects for them to be compatible with this module.

:





Object evaluation


Function XCLE_ObjectEval

XCLE_Exception XCLE_ObjectEval(XCLE_ExecCtx ctx, XCLE_Stack stk, XCLE_Hash hsh, XCLE_Object obj) ;
Evaluates an XCLE_Object.

Args:
ctx: execution context
stk: Stack environment
dom: Variables environment
obj: Object to execute


Returns:
NULL: if a NULL Stack, Hash or Object was passed as argument
XCLE_EXCEPTION_OK: if the execution terminated normally
else the last exception thrown in this context.


Errors:
EINVAL: if a NULL Stack, Hash or Object was passed as argument



Function XCLE_ListEval

XCLE_Exception XCLE_ListEval(XCLE_ExecCtx ctx, XCLE_Stack stk, XCLE_Hash hsh, XCLE_List lst) ;
Evaluates an XCLE_List.

Args:
ctx: execution context
stk: Stack environment
dom: Variables environment
lst: list to execute


Returns:
NULL: if a NULL Stack, Hash or Object was passed as argument
XCLE_EXCEPTION_OK: if the execution terminated normally
else the last exception thrown in this context.


Errors:
EINVAL: if a NULL Stack, Hash or Object was passed as argument



Function XCLE_CodeEval

XCLE_Exception XCLE_CodeEval(XCLE_ExecCtx ctx, XCLE_Stack stk, XCLE_Hash hsh, XCLE_Code cod) ;
Evaluates an XCLE_Code object.

Args:
ctx: execution context
stk: Stack environment
dom: Variables environment
cod: code to execute


Returns:
NULL: if a NULL Stack, Hash or Object was passed as argument
XCLE_EXCEPTION_OK: if the execution terminated normally
else the last exception thrown in this context.


Errors:
EINVAL: if a NULL Stack, Hash or Object was passed as argument




Generated by textdoc2html - 2006-02-22