📄 dffnxfun.c
字号:
#if BLOAD_ONLY || RUN_TIME
return(FALSE);
#else
#if BLOAD || BLOAD_AND_BSAVE
if (Bloaded(theEnv) == TRUE)
return(FALSE);
#endif
if (vptr == NULL)
return(RemoveAllDeffunctions(theEnv));
if (EnvIsDeffunctionDeletable(theEnv,vptr) == FALSE)
return(FALSE);
RemoveConstructFromModule(theEnv,(struct constructHeader *) vptr);
RemoveDeffunction(theEnv,vptr);
return(TRUE);
#endif
}
/****************************************************
NAME : EnvGetNextDeffunction
DESCRIPTION : Accesses list of deffunctions
INPUTS : Deffunction pointer
RETURNS : The next deffunction, or the
first deffunction (if input is NULL)
SIDE EFFECTS : None
NOTES : None
****************************************************/
globle void *EnvGetNextDeffunction(
void *theEnv,
void *ptr)
{
return((void *) GetNextConstructItem(theEnv,(struct constructHeader *) ptr,DeffunctionData(theEnv)->DeffunctionModuleIndex));
}
/***************************************************
NAME : EnvIsDeffunctionDeletable
DESCRIPTION : Determines if a deffunction is
executing or referenced by another
expression
INPUTS : Deffunction pointer
RETURNS : TRUE if the deffunction can
be deleted, FALSE otherwise
SIDE EFFECTS : None
NOTES : None
***************************************************/
globle int EnvIsDeffunctionDeletable(
void *theEnv,
void *ptr)
{
DEFFUNCTION *dptr;
if (! ConstructsDeletable(theEnv))
{ return FALSE; }
dptr = (DEFFUNCTION *) ptr;
return(((dptr->busy == 0) && (dptr->executing == 0)) ? TRUE : FALSE);
}
#if (! BLOAD_ONLY) && (! RUN_TIME)
/***************************************************
NAME : RemoveDeffunction
DESCRIPTION : Removes a deffunction
INPUTS : Deffunction pointer
RETURNS : Nothing useful
SIDE EFFECTS : Deffunction deallocated
NOTES : Assumes deffunction is not in use!!
***************************************************/
globle void RemoveDeffunction(
void *theEnv,
void *vdptr)
{
DEFFUNCTION *dptr = (DEFFUNCTION *) vdptr;
if (dptr == NULL)
return;
DecrementSymbolCount(theEnv,GetDeffunctionNamePointer((void *) dptr));
ExpressionDeinstall(theEnv,dptr->code);
ReturnPackedExpression(theEnv,dptr->code);
SetDeffunctionPPForm((void *) dptr,NULL);
ClearUserDataList(theEnv,dptr->header.usrData);
rtn_struct(theEnv,deffunctionStruct,dptr);
}
#endif
/********************************************************
NAME : UndeffunctionCommand
DESCRIPTION : Deletes the named deffunction(s)
INPUTS : None
RETURNS : Nothing useful
SIDE EFFECTS : Deffunction(s) removed
NOTES : H/L Syntax: (undeffunction <name> | *)
********************************************************/
globle void UndeffunctionCommand(
void *theEnv)
{
UndefconstructCommand(theEnv,"undeffunction",DeffunctionData(theEnv)->DeffunctionConstruct);
}
/****************************************************************
NAME : GetDeffunctionModuleCommand
DESCRIPTION : Determines to which module a deffunction belongs
INPUTS : None
RETURNS : The symbolic name of the module
SIDE EFFECTS : None
NOTES : H/L Syntax: (deffunction-module <dfnx-name>)
****************************************************************/
globle void *GetDeffunctionModuleCommand(
void *theEnv)
{
return(GetConstructModuleCommand(theEnv,"deffunction-module",DeffunctionData(theEnv)->DeffunctionConstruct));
}
#if DEBUGGING_FUNCTIONS
/****************************************************
NAME : PPDeffunctionCommand
DESCRIPTION : Displays the pretty-print form of a
deffunction
INPUTS : None
RETURNS : Nothing useful
SIDE EFFECTS : Pretty-print form displayed to
WDISPLAY logical name
NOTES : H/L Syntax: (ppdeffunction <name>)
****************************************************/
globle void PPDeffunctionCommand(
void *theEnv)
{
PPConstructCommand(theEnv,"ppdeffunction",DeffunctionData(theEnv)->DeffunctionConstruct);
}
/***************************************************
NAME : ListDeffunctionsCommand
DESCRIPTION : Displays all deffunction names
INPUTS : None
RETURNS : Nothing useful
SIDE EFFECTS : Deffunction name sprinted
NOTES : H/L Interface
***************************************************/
globle void ListDeffunctionsCommand(
void *theEnv)
{
ListConstructCommand(theEnv,"list-deffunctions",DeffunctionData(theEnv)->DeffunctionConstruct);
}
/***************************************************
NAME : EnvListDeffunctions
DESCRIPTION : Displays all deffunction names
INPUTS : 1) The logical name of the output
2) The module
RETURNS : Nothing useful
SIDE EFFECTS : Deffunction name sprinted
NOTES : C Interface
***************************************************/
globle void EnvListDeffunctions(
void *theEnv,
char *logicalName,
struct defmodule *theModule)
{
ListConstruct(theEnv,DeffunctionData(theEnv)->DeffunctionConstruct,logicalName,theModule);
}
#endif
/***************************************************************
NAME : GetDeffunctionListFunction
DESCRIPTION : Groups all deffunction names into
a multifield list
INPUTS : A data object buffer to hold
the multifield result
RETURNS : Nothing useful
SIDE EFFECTS : Multifield allocated and filled
NOTES : H/L Syntax: (get-deffunction-list [<module>])
***************************************************************/
globle void GetDeffunctionListFunction(
void *theEnv,
DATA_OBJECT *returnValue)
{
GetConstructListFunction(theEnv,"get-deffunction-list",returnValue,DeffunctionData(theEnv)->DeffunctionConstruct);
}
/***************************************************************
NAME : EnvGetDeffunctionList
DESCRIPTION : Groups all deffunction names into
a multifield list
INPUTS : 1) A data object buffer to hold
the multifield result
2) The module from which to obtain deffunctions
RETURNS : Nothing useful
SIDE EFFECTS : Multifield allocated and filled
NOTES : External C access
***************************************************************/
globle void EnvGetDeffunctionList(
void *theEnv,
DATA_OBJECT *returnValue,
struct defmodule *theModule)
{
GetConstructList(theEnv,returnValue,DeffunctionData(theEnv)->DeffunctionConstruct,theModule);
}
/*******************************************************
NAME : CheckDeffunctionCall
DESCRIPTION : Checks the number of arguments
passed to a deffunction
INPUTS : 1) Deffunction pointer
2) The number of arguments
RETURNS : TRUE if OK, FALSE otherwise
SIDE EFFECTS : Message printed on errors
NOTES : None
*******************************************************/
globle int CheckDeffunctionCall(
void *theEnv,
void *vdptr,
int args)
{
DEFFUNCTION *dptr;
if (vdptr == NULL)
return(FALSE);
dptr = (DEFFUNCTION *) vdptr;
if (args < dptr->minNumberOfParameters)
{
if (dptr->maxNumberOfParameters == -1)
ExpectedCountError(theEnv,EnvGetDeffunctionName(theEnv,(void *) dptr),
AT_LEAST,dptr->minNumberOfParameters);
else
ExpectedCountError(theEnv,EnvGetDeffunctionName(theEnv,(void *) dptr),
EXACTLY,dptr->minNumberOfParameters);
return(FALSE);
}
else if ((args > dptr->minNumberOfParameters) &&
(dptr->maxNumberOfParameters != -1))
{
ExpectedCountError(theEnv,EnvGetDeffunctionName(theEnv,(void *) dptr),
EXACTLY,dptr->minNumberOfParameters);
return(FALSE);
}
return(TRUE);
}
/* =========================================
*****************************************
INTERNALLY VISIBLE FUNCTIONS
=========================================
***************************************** */
/***************************************************
NAME : PrintDeffunctionCall
DESCRIPTION : PrintExpression() support function
for deffunction calls
INPUTS : 1) The output logical name
2) The deffunction
RETURNS : Nothing useful
SIDE EFFECTS : Call expression printed
NOTES : None
***************************************************/
#if IBM_TBC
#pragma argsused
#endif
static void PrintDeffunctionCall(
void *theEnv,
char *logName,
void *value)
{
#if DEVELOPER
EnvPrintRouter(theEnv,logName,"(");
EnvPrintRouter(theEnv,logName,EnvGetDeffunctionName(theEnv,value));
if (GetFirstArgument() != NULL)
{
EnvPrintRouter(theEnv,logName," ");
PrintExpression(theEnv,logName,GetFirstArgument());
}
EnvPrintRouter(theEnv,logName,")");
#else
#if MAC_MCW || IBM_MCW || MAC_XCD
#pragma unused(theEnv)
#pragma unused(logName)
#pragma unused(value)
#endif
#endif
}
/*******************************************************
NAME : EvaluateDeffunctionCall
DESCRIPTION : Primitive support function for
calling a deffunction
INPUTS : 1) The deffunction
2) A data object buffer to hold
the evaluation result
RETURNS : FALSE if the deffunction
returns the symbol FALSE,
TRUE otherwise
SIDE EFFECTS : Data obejct buffer set and any
side-effects of calling the deffunction
NOTES : None
*******************************************************/
static intBool EvaluateDeffunctionCall(
void *theEnv,
void *value,
DATA_OBJECT *result)
{
CallDeffunction(theEnv,(DEFFUNCTION *) value,GetFirstArgument(),result);
if ((GetpType(result) == SYMBOL) &&
(GetpValue(result) == EnvFalseSymbol(theEnv)))
return(FALSE);
return(TRUE);
}
/***************************************************
NAME : DecrementDeffunctionBusyCount
DESCRIPTION : Lowers the busy count of a
deffunction construct
INPUTS : The deffunction
RETURNS : Nothing useful
SIDE EFFECTS : Busy count decremented if a clear
is not in progress (see comment)
NOTES : None
***************************************************/
static void DecrementDeffunctionBusyCount(
void *theEnv,
void *value)
{
/* ==============================================
The deffunctions to which expressions in other
constructs may refer may already have been
deleted - thus, it is important not to modify
the busy flag during a clear.
============================================== */
if (! ConstructData(theEnv)->ClearInProgress)
((DEFFUNCTION *) value)->busy--;
}
/***************************************************
NAME : IncrementDeffunctionBusyCount
DESCRIPTION : Raises the busy count of a
deffunction construct
INPUTS : The deffunction
RETURNS : Nothing useful
SIDE EFFECTS : Busy count incremented
NOTES : None
***************************************************/
#if IBM_TBC
#pragma argsused
#endif
static void IncrementDeffunctionBusyCount(
void *theEnv,
void *value)
{
#if MAC_MCW || IBM_MCW || MAC_XCD
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -