📄 dffnxfun.c
字号:
NOTES : None ***************************************************/static VOID IncrementDeffunctionBusyCount(value) VOID *value; { ((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() { return((VOID *) get_struct(deffunctionModule)); } /*************************************************** NAME : FreeModule 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 FreeModule(theItem) VOID *theItem; {#if (! BLOAD_ONLY) FreeConstructHeaderModule((struct defmoduleItemHeader *) theItem,DeffunctionConstruct);#endif rtn_struct(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 : CLIPS_TRUE if no deffunctions are executing, CLIPS_FALSE otherwise SIDE EFFECTS : None NOTES : Used by (clear) and (bload) ***************************************************/static BOOLEAN ClearDeffunctionsReady() { return((ExecutingDeffunction != NULL) ? CLIPS_FALSE : CLIPS_TRUE); }#endif#if (! BLOAD_ONLY) && (! RUN_TIME)/*************************************************** NAME : RemoveAllDeffunctions DESCRIPTION : Removes all deffunctions INPUTS : None RETURNS : CLIPS_TRUE if all deffunctions removed, CLIPS_FALSE otherwise SIDE EFFECTS : Deffunctions removed NOTES : None ***************************************************/static BOOLEAN RemoveAllDeffunctions() { DEFFUNCTION *dptr,*dtmp; int oldbusy,success = CLIPS_TRUE;#if BLOAD || BLOAD_AND_BSAVE if (Bloaded() == CLIPS_TRUE) return(CLIPS_FALSE);#endif dptr = (DEFFUNCTION *) GetNextDeffunction(NULL); while (dptr != NULL) { if (dptr->executing > 0) { DeffunctionDeleteError(GetDeffunctionName((VOID *) dptr)); success = CLIPS_FALSE; } else { oldbusy = dptr->busy; ExpressionDeinstall(dptr->code); dptr->busy = oldbusy; ReturnPackedExpression(dptr->code); dptr->code = NULL; } dptr = (DEFFUNCTION *) GetNextDeffunction((VOID *) dptr); } dptr = (DEFFUNCTION *) GetNextDeffunction(NULL); while (dptr != NULL) { dtmp = dptr; dptr = (DEFFUNCTION *) GetNextDeffunction((VOID *) dptr); if (dtmp->executing == 0) { if (dtmp->busy > 0) { PrintWarningID("DFFNXFUN",1,CLIPS_FALSE); PrintCLIPS(WWARNING,"Deffunction "); PrintCLIPS(WWARNING,GetDeffunctionName((VOID *) dtmp)); PrintCLIPS(WWARNING," only partially deleted due to usage by other constructs.\n"); SetDeffunctionPPForm((VOID *) dtmp,NULL); success = CLIPS_FALSE; } else { RemoveConstructFromModule((struct constructHeader *) dtmp); RemoveDeffunction(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(dfnxName) char *dfnxName; { CantDeleteItemErrorMessage("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(logicalName) char *logicalName; { DoForAllConstructs(SaveDeffunctionHeader,DeffunctionModuleIndex, CLIPS_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(theDeffunction,userBuffer) struct constructHeader *theDeffunction; VOID *userBuffer; { DEFFUNCTION *dfnxPtr = (DEFFUNCTION *) theDeffunction; char *logicalName = (char *) userBuffer; register int i; if (GetDeffunctionPPForm((VOID *) dfnxPtr) != NULL) { PrintCLIPS(logicalName,"(deffunction "); PrintCLIPS(logicalName,GetDeffunctionName((VOID *) dfnxPtr)); PrintCLIPS(logicalName," ("); for (i = 0 ; i < dfnxPtr->minNumberOfParameters ; i++) { PrintCLIPS(logicalName,"?p"); PrintLongInteger(logicalName,(long) i); if (i != dfnxPtr->minNumberOfParameters-1) PrintCLIPS(logicalName," "); } if (dfnxPtr->maxNumberOfParameters == -1) { if (dfnxPtr->minNumberOfParameters != 0) PrintCLIPS(logicalName," "); PrintCLIPS(logicalName,"$?wildargs))\n\n"); } else PrintCLIPS(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(logicalName) char *logicalName; { SaveConstruct(logicalName,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 : CLIPS_TRUE if all OK, CLIPS_FALSE otherwise SIDE EFFECTS : Watch flags set in specified deffunctions NOTES : Accessory function for AddWatchItem() ******************************************************************/#if IBM_TBC#pragma argsused#endifstatic BOOLEAN DeffunctionWatchAccess(code,newState,argExprs) int code,newState; EXPRESSION *argExprs; {#if MAC_MPW || MAC_MCW#pragma unused(code)#endif return(ConstructSetWatchAccess(DeffunctionConstruct,newState,argExprs, GetDeffunctionWatch,SetDeffunctionWatch)); }/*********************************************************************** 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 : CLIPS_TRUE if all OK, CLIPS_FALSE otherwise SIDE EFFECTS : Watch flags displayed for specified deffunctions NOTES : Accessory function for AddWatchItem() ***********************************************************************/#if IBM_TBC#pragma argsused#endifstatic BOOLEAN DeffunctionWatchPrint(log,code,argExprs) char *log; int code; EXPRESSION *argExprs; {#if MAC_MPW || MAC_MCW#pragma unused(code)#endif return(ConstructPrintWatchAccess(DeffunctionConstruct,log,argExprs, GetDeffunctionWatch,SetDeffunctionWatch)); } /********************************************************* NAME : SetDeffunctionWatch DESCRIPTION : Sets the trace to ON/OFF for the deffunction INPUTS : 1) CLIPS_TRUE to set the trace on, CLIPS_FALSE to set it off 2) A pointer to the deffunction RETURNS : Nothing useful SIDE EFFECTS : Watch flag for the deffunction set NOTES : None *********************************************************/globle VOID SetDeffunctionWatch(newState,dptr) int newState; VOID *dptr; { ((DEFFUNCTION *) dptr)->trace = (unsigned short) newState; } /********************************************************* NAME : GetDeffunctionWatch DESCRIPTION : Determines if trace messages are gnerated when executing deffunction INPUTS : A pointer to the deffunction RETURNS : CLIPS_TRUE if a trace is active, CLIPS_FALSE otherwise SIDE EFFECTS : None NOTES : None *********************************************************/globle int GetDeffunctionWatch(dptr) VOID *dptr; { return(((DEFFUNCTION *) dptr)->trace); } #endif#endif/*************************************************** NAME : DESCRIPTION : INPUTS : RETURNS : SIDE EFFECTS : NOTES : ***************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -