📄 dffnxfun.c
字号:
#pragma unused(theEnv)
#endif
((DEFFUNCTION *) value)->busy++;
}
#if ! RUN_TIME
/*****************************************************
NAME : AllocateModule
DESCRIPTION : Creates and initializes a
list of deffunctions for a new module
INPUTS : None
RETURNS : The new deffunction module
SIDE EFFECTS : Deffunction module created
NOTES : None
*****************************************************/
static void *AllocateModule(
void *theEnv)
{
return((void *) get_struct(theEnv,deffunctionModule));
}
/***************************************************
NAME : ReturnModule
DESCRIPTION : Removes a deffunction module and
all associated deffunctions
INPUTS : The deffunction module
RETURNS : Nothing useful
SIDE EFFECTS : Module and deffunctions deleted
NOTES : None
***************************************************/
static void ReturnModule(
void *theEnv,
void *theItem)
{
#if (! BLOAD_ONLY)
FreeConstructHeaderModule(theEnv,(struct defmoduleItemHeader *) theItem,DeffunctionData(theEnv)->DeffunctionConstruct);
#endif
rtn_struct(theEnv,deffunctionModule,theItem);
}
/***************************************************
NAME : ClearDeffunctionsReady
DESCRIPTION : Determines if it is safe to
remove all deffunctions
Assumes *all* constructs will be
deleted - only checks to see if
any deffunctions are currently
executing
INPUTS : None
RETURNS : TRUE if no deffunctions are
executing, FALSE otherwise
SIDE EFFECTS : None
NOTES : Used by (clear) and (bload)
***************************************************/
static intBool ClearDeffunctionsReady(
void *theEnv)
{
return((DeffunctionData(theEnv)->ExecutingDeffunction != NULL) ? FALSE : TRUE);
}
#endif
#if (! BLOAD_ONLY) && (! RUN_TIME)
/***************************************************
NAME : RemoveAllDeffunctions
DESCRIPTION : Removes all deffunctions
INPUTS : None
RETURNS : TRUE if all deffunctions
removed, FALSE otherwise
SIDE EFFECTS : Deffunctions removed
NOTES : None
***************************************************/
static intBool RemoveAllDeffunctions(
void *theEnv)
{
DEFFUNCTION *dptr,*dtmp;
unsigned oldbusy;
intBool success = TRUE;
#if BLOAD || BLOAD_AND_BSAVE
if (Bloaded(theEnv) == TRUE)
return(FALSE);
#endif
dptr = (DEFFUNCTION *) EnvGetNextDeffunction(theEnv,NULL);
while (dptr != NULL)
{
if (dptr->executing > 0)
{
DeffunctionDeleteError(theEnv,EnvGetDeffunctionName(theEnv,(void *) dptr));
success = FALSE;
}
else
{
oldbusy = dptr->busy;
ExpressionDeinstall(theEnv,dptr->code);
dptr->busy = oldbusy;
ReturnPackedExpression(theEnv,dptr->code);
dptr->code = NULL;
}
dptr = (DEFFUNCTION *) EnvGetNextDeffunction(theEnv,(void *) dptr);
}
dptr = (DEFFUNCTION *) EnvGetNextDeffunction(theEnv,NULL);
while (dptr != NULL)
{
dtmp = dptr;
dptr = (DEFFUNCTION *) EnvGetNextDeffunction(theEnv,(void *) dptr);
if (dtmp->executing == 0)
{
if (dtmp->busy > 0)
{
PrintWarningID(theEnv,"DFFNXFUN",1,FALSE);
EnvPrintRouter(theEnv,WWARNING,"Deffunction ");
EnvPrintRouter(theEnv,WWARNING,EnvGetDeffunctionName(theEnv,(void *) dtmp));
EnvPrintRouter(theEnv,WWARNING," only partially deleted due to usage by other constructs.\n");
SetDeffunctionPPForm((void *) dtmp,NULL);
success = FALSE;
}
else
{
RemoveConstructFromModule(theEnv,(struct constructHeader *) dtmp);
RemoveDeffunction(theEnv,dtmp);
}
}
}
return(success);
}
/****************************************************
NAME : DeffunctionDeleteError
DESCRIPTION : Prints out an error message when
a deffunction deletion attempt fails
INPUTS : The deffunction name
RETURNS : Nothing useful
SIDE EFFECTS : Error message printed
NOTES : None
****************************************************/
static void DeffunctionDeleteError(
void *theEnv,
char *dfnxName)
{
CantDeleteItemErrorMessage(theEnv,"deffunction",dfnxName);
}
/***************************************************
NAME : SaveDeffunctionHeaders
DESCRIPTION : Writes out deffunction forward
declarations for (save) command
INPUTS : The logical output name
RETURNS : Nothing useful
SIDE EFFECTS : Writes out deffunctions with no
body of actions
NOTES : Used for deffunctions which are
mutually recursive with other
constructs
***************************************************/
static void SaveDeffunctionHeaders(
void *theEnv,
void *theModule,
char *logicalName)
{
DoForAllConstructsInModule(theEnv,theModule,SaveDeffunctionHeader,
DeffunctionData(theEnv)->DeffunctionModuleIndex,
FALSE,(void *) logicalName);
}
/***************************************************
NAME : SaveDeffunctionHeader
DESCRIPTION : Writes a deffunction forward
declaration to the save file
INPUTS : 1) The deffunction
2) The logical name of the output
RETURNS : Nothing useful
SIDE EFFECTS : Defffunction header written
NOTES : None
***************************************************/
static void SaveDeffunctionHeader(
void *theEnv,
struct constructHeader *theDeffunction,
void *userBuffer)
{
DEFFUNCTION *dfnxPtr = (DEFFUNCTION *) theDeffunction;
char *logicalName = (char *) userBuffer;
register int i;
if (EnvGetDeffunctionPPForm(theEnv,(void *) dfnxPtr) != NULL)
{
EnvPrintRouter(theEnv,logicalName,"(deffunction ");
EnvPrintRouter(theEnv,logicalName,EnvDeffunctionModule(theEnv,(void *) dfnxPtr));
EnvPrintRouter(theEnv,logicalName,"::");
EnvPrintRouter(theEnv,logicalName,EnvGetDeffunctionName(theEnv,(void *) dfnxPtr));
EnvPrintRouter(theEnv,logicalName," (");
for (i = 0 ; i < dfnxPtr->minNumberOfParameters ; i++)
{
EnvPrintRouter(theEnv,logicalName,"?p");
PrintLongInteger(theEnv,logicalName,(long) i);
if (i != dfnxPtr->minNumberOfParameters-1)
EnvPrintRouter(theEnv,logicalName," ");
}
if (dfnxPtr->maxNumberOfParameters == -1)
{
if (dfnxPtr->minNumberOfParameters != 0)
EnvPrintRouter(theEnv,logicalName," ");
EnvPrintRouter(theEnv,logicalName,"$?wildargs))\n\n");
}
else
EnvPrintRouter(theEnv,logicalName,"))\n\n");
}
}
/***************************************************
NAME : SaveDeffunctions
DESCRIPTION : Writes out deffunctions
for (save) command
INPUTS : The logical output name
RETURNS : Nothing useful
SIDE EFFECTS : Writes out deffunctions
NOTES : None
***************************************************/
static void SaveDeffunctions(
void *theEnv,
void *theModule,
char *logicalName)
{
SaveConstruct(theEnv,theModule,logicalName,DeffunctionData(theEnv)->DeffunctionConstruct);
}
#endif
#if DEBUGGING_FUNCTIONS
/******************************************************************
NAME : DeffunctionWatchAccess
DESCRIPTION : Parses a list of deffunction names passed by
AddWatchItem() and sets the traces accordingly
INPUTS : 1) A code indicating which trace flag is to be set
Ignored
2) The value to which to set the trace flags
3) A list of expressions containing the names
of the deffunctions for which to set traces
RETURNS : TRUE if all OK, FALSE otherwise
SIDE EFFECTS : Watch flags set in specified deffunctions
NOTES : Accessory function for AddWatchItem()
******************************************************************/
#if IBM_TBC
#pragma argsused
#endif
static unsigned DeffunctionWatchAccess(
void *theEnv,
int code,
unsigned newState,
EXPRESSION *argExprs)
{
#if MAC_MCW || IBM_MCW || MAC_XCD
#pragma unused(code)
#endif
return(ConstructSetWatchAccess(theEnv,DeffunctionData(theEnv)->DeffunctionConstruct,newState,argExprs,
EnvGetDeffunctionWatch,EnvSetDeffunctionWatch));
}
/***********************************************************************
NAME : DeffunctionWatchPrint
DESCRIPTION : Parses a list of deffunction names passed by
AddWatchItem() and displays the traces accordingly
INPUTS : 1) The logical name of the output
2) A code indicating which trace flag is to be examined
Ignored
3) A list of expressions containing the names
of the deffunctions for which to examine traces
RETURNS : TRUE if all OK, FALSE otherwise
SIDE EFFECTS : Watch flags displayed for specified deffunctions
NOTES : Accessory function for AddWatchItem()
***********************************************************************/
#if IBM_TBC
#pragma argsused
#endif
static unsigned DeffunctionWatchPrint(
void *theEnv,
char *logName,
int code,
EXPRESSION *argExprs)
{
#if MAC_MCW || IBM_MCW || MAC_XCD
#pragma unused(code)
#endif
return(ConstructPrintWatchAccess(theEnv,DeffunctionData(theEnv)->DeffunctionConstruct,logName,argExprs,
EnvGetDeffunctionWatch,EnvSetDeffunctionWatch));
}
/*********************************************************
NAME : EnvSetDeffunctionWatch
DESCRIPTION : Sets the trace to ON/OFF for the
deffunction
INPUTS : 1) TRUE to set the trace on,
FALSE to set it off
2) A pointer to the deffunction
RETURNS : Nothing useful
SIDE EFFECTS : Watch flag for the deffunction set
NOTES : None
*********************************************************/
#if IBM_TBC
#pragma argsused
#endif
globle void EnvSetDeffunctionWatch(
void *theEnv,
unsigned newState,
void *dptr)
{
#if MAC_MCW || IBM_MCW || MAC_XCD
#pragma unused(theEnv)
#endif
((DEFFUNCTION *) dptr)->trace = (unsigned short) newState;
}
/*********************************************************
NAME : EnvGetDeffunctionWatch
DESCRIPTION : Determines if trace messages are
gnerated when executing deffunction
INPUTS : A pointer to the deffunction
RETURNS : TRUE if a trace is active,
FALSE otherwise
SIDE EFFECTS : None
NOTES : None
*********************************************************/
#if IBM_TBC
#pragma argsused
#endif
globle unsigned EnvGetDeffunctionWatch(
void *theEnv,
void *dptr)
{
#if MAC_MCW || IBM_MCW || MAC_XCD
#pragma unused(theEnv)
#endif
return(((DEFFUNCTION *) dptr)->trace);
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -