Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

FunctionCalls Namespace Reference

The FunctionCalls namespace holds functions pertaining to the exection of different types of functions and handling their return values. More...


Functions

CENTUMSHAREDCODE_API ExecutionReturn HandleReturnValue (CScope *scope, ExecutionReturn ret)
 This function takes the return value of a function that is to have its results pushed onto the local stack and calls HandleReturnValueAll with the appropriate parameters.
CENTUMSHAREDCODE_API ExecutionReturn HandleUReturnValue (CScope *scope, ExecutionReturn ret)
 This function takes the return value of a function that is to have its results pushed onto the usings stack and calls HandleReturnValueAll with the appropriate parameters.
CENTUMSHAREDCODE_API void ExtractAndReleaseParamsAndUsings (CScope *scope)
 The ExtractAndReleaseParamsAndUsings takes a substack from both the parms and usings stacks passed to a function and finishes them.
CENTUMSHAREDCODE_API ExecutionReturn MakeARegisteredCall (CThing *func, CScope *scope)
 The MakeARegisteredCall function is used when a rebi with the CTHING_REGISTEREDFUNCTION flag is to be called.
CENTUMSHAREDCODE_API ExecutionReturn MakeADLLCall (CThing *func, CScope *scope)
 The MakeADllCall function is used when a rebi with the CTHING_DLLFUNCTION flag is to be called.
CENTUMSHAREDCODE_API ExecutionReturn MakeANormalCall (CThing *func, CScope *scope)
 This function is used to execute a rebi that has no special flags relating to its call.
CENTUMSHAREDCODE_API ExecutionReturn HandleReturnValueAll (CScope *scope, ExecutionReturn ret, CThingStack *dest)
 This function deals with the results of a function return as appropriate, adding them to the correct stack, retuning them further or handling an excpetion.
CENTUMSHAREDCODE_API ExecutionReturn HandleReturnedException (CScope *scope, ExecutionReturn ret)
 The HandleReturnedException function attempts to use an exception handler with the current scope.
CENTUMSHAREDCODE_API ExecutionReturn CleanReturnValue (ExecutionReturn ret)
 This function adjusts the return type of a return value to represent that it has passed though a function.


Detailed Description

The FunctionCalls namespace holds functions pertaining to the exection of different types of functions and handling their return values.

Function Documentation

CENTUMSHAREDCODE_API ExecutionReturn FunctionCalls::CleanReturnValue ExecutionReturn  ret  ) 
 

This function adjusts the return type of a return value to represent that it has passed though a function.

Multiple return values are adjusted to reflect having returned through another layer, and single returns are turned into normal results to signal that they should be added to the stack and not passed further on.

Parameters:
ret the return value before adjustements
Returns:
the return value after being adjusted.

CENTUMSHAREDCODE_API void FunctionCalls::ExtractAndReleaseParamsAndUsings CScope scope  ) 
 

The ExtractAndReleaseParamsAndUsings takes a substack from both the parms and usings stacks passed to a function and finishes them.

Parameters:
scope the scope the parameters and usings were passed to.

CENTUMSHAREDCODE_API ExecutionReturn FunctionCalls::HandleReturnedException CScope scope,
ExecutionReturn  ret
 

The HandleReturnedException function attempts to use an exception handler with the current scope.

This function searches though the byte code of the current scope, starting at the current position looking for a bytecode with an ident of 0x03, singifying that it is a handler. This handler is then called with the returned value and the returned value of the handler is subsequently returned. If no handler can be found the value passed to this function is returned unchanged.

Parameters:
scope the scope to look for the exception handler within.
ret the returned exception that needs to be handled.
Returns:
the result of the handler function or the intial value if it cannot be handled.

CENTUMSHAREDCODE_API ExecutionReturn FunctionCalls::HandleReturnValue CScope scope,
ExecutionReturn  ret
 

This function takes the return value of a function that is to have its results pushed onto the local stack and calls HandleReturnValueAll with the appropriate parameters.

This function provides a layer of indirection that prevents code duplication.

See also:
HandleReturnValueAll
Parameters:
scope the current scope
ret the return value to be handled.
Returns:
the return value after it has been processed.

CENTUMSHAREDCODE_API ExecutionReturn FunctionCalls::HandleReturnValueAll CScope scope,
ExecutionReturn  ret,
CThingStack dest
 

This function deals with the results of a function return as appropriate, adding them to the correct stack, retuning them further or handling an excpetion.

First return values of type EXEC_NORMAL have their values pushed onto the stack passed to the function, and normal return with no stack is returned from the function. Return values of type EXEC_RETURN or multiple returns are passed on with no action taken. Return values of type EXEC_RETURNTO or EXEC_RETURNFROM have their top value of their return stack compared either to the label of the current scope if it is a string reference or if their pointers and the scope's rebi if it is a bare reference. If they pass this test return values of type EXEC_RETURNTO have their return stack added to the appropriate stack as if they were a normal return and returns of type EXEC_RETURNFROM are converted into normal returns. Finally exceptions have HandleReturnedException called on them repeatedly until a handler returns a non-exception which is then returned, or until no more handlers can be found (each passed the result of the previous handler) in that case the resulting exception is returned to be handled in the calling scope.

Parameters:
scope the scope in which this return value is to be handled.
ret the returned value to be handled.
dest the stack to push any values onto. If it is needed passing NULL is an error.
Returns:
the return value after being altered by handling.
See also:
HandleReturnedException()

CENTUMSHAREDCODE_API ExecutionReturn FunctionCalls::HandleUReturnValue CScope scope,
ExecutionReturn  ret
 

This function takes the return value of a function that is to have its results pushed onto the usings stack and calls HandleReturnValueAll with the appropriate parameters.

This function provides a layer of indirection that prevents code duplication.

See also:
HandleReturnValueAll
Parameters:
scope the current scope
ret the return value to be handled.
Returns:
the return value after it has been processed.

CENTUMSHAREDCODE_API ExecutionReturn FunctionCalls::MakeADLLCall CThing func,
CScope scope
 

The MakeADllCall function is used when a rebi with the CTHING_DLLFUNCTION flag is to be called.

This function gets the dll name, stored as local data of type DATA_TYPE_DLL_NAME, and then either the name of the function to call, as stored in local data with type: DATA_TYPE_DLL_FUNCTION_NAME or the ordinal as stored in local data of type DATA_TYPE_DLL_FUNCTION_VALUE. Then parameters and usings are extracted from the calling scope ( using CThingStack::GetASubStackUnsafe() ). After being called once as a dll function the rebi is converted into a registed function rebi (flag CTHING_REGISTEREDFUNCTION) for a speed boost. Finally the function itself is called, and then its return stack is reversed and then its return value is processed by the CleanReturnValue function before being returned.

Parameters:
func the rebi with the dll function flag being called.
scope the scope the rebi is being called within.
Returns:
the result of the dll function call.
See also:
CThingStack::GetASubStackUnsafe()

CleanReturnValue()

CENTUMSHAREDCODE_API ExecutionReturn FunctionCalls::MakeANormalCall CThing func,
CScope scope
 

This function is used to execute a rebi that has no special flags relating to its call.

Parameters and usings are extracted from the calling scope ( using CThingStack::GetASubStack() ). Finally the function itself is called, and its return value is processed by the CleanReturnValue function before being returned.

Parameters:
func the rebi being called.
scope the scope the rebi is being called within.
Returns:
the result of the function call.
See also:
CThingStack::GetASubStack()

CleanReturnValue()

CallFunction()

CENTUMSHAREDCODE_API ExecutionReturn FunctionCalls::MakeARegisteredCall CThing func,
CScope scope
 

The MakeARegisteredCall function is used when a rebi with the CTHING_REGISTEREDFUNCTION flag is to be called.

This function gets the address of the external function, stored as local data of type DATA_TYPE_EXTERNAL_FUNCTION. Then parameters and usings are extracted from the calling scope ( using CThingStack::GetASubStackUnsafe() ). Finally the function itself is called, and then its return stack is reversed and then its return value is processed by the CleanReturnValue function before being returned.

Parameters:
func the rebi with the resitered function flag being called.
scope the scope the rebi is being called within.
Returns:
the result of the registered function call.
See also:
CThingStack::GetASubStackUnsafe()

CleanReturnValue()


Generated on Sat Apr 16 16:31:09 2005 for Centum API by  doxygen 1.4.2