⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dffnxfun.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 3 页
字号:
   if (Bloaded() == CLIPS_TRUE)     return(CLIPS_FALSE);#endif   if (vptr == NULL)      return(RemoveAllDeffunctions());   if (IsDeffunctionDeletable(vptr) == CLIPS_FALSE)     return(CLIPS_FALSE);   RemoveConstructFromModule((struct constructHeader *) vptr);   RemoveDeffunction(vptr);   return(CLIPS_TRUE);#endif  }/****************************************************  NAME         : GetNextDeffunction  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 *GetNextDeffunction(ptr)  VOID *ptr;  {   return((VOID *) GetNextConstructItem((struct constructHeader *) ptr,DeffunctionModuleIndex));  }/***************************************************  NAME         : IsDeffunctionDeletable  DESCRIPTION  : Determines if a deffunction is                 executing or referenced by another                 expression  INPUTS       : Deffunction pointer  RETURNS      : CLIPS_TRUE if the deffunction can                 be deleted, CLIPS_FALSE otherwise  SIDE EFFECTS : None  NOTES        : None ***************************************************/globle int IsDeffunctionDeletable(ptr)  VOID *ptr;  {#if (MAC_MPW || MAC_MCW) && (RUN_TIME || BLOAD_ONLY)#pragma unused(ptr)#endif#if BLOAD_ONLY || RUN_TIME   return(CLIPS_FALSE);#else   DEFFUNCTION *dptr;#if BLOAD || BLOAD_AND_BSAVE   if (Bloaded())     return(CLIPS_FALSE);#endif   dptr = (DEFFUNCTION *) ptr;   return(((dptr->busy == 0) && (dptr->executing == 0)) ? CLIPS_TRUE : CLIPS_FALSE);#endif  }#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(vdptr)  VOID *vdptr;  {   DEFFUNCTION *dptr = (DEFFUNCTION *) vdptr;      if (dptr == NULL)     return;   DecrementSymbolCount(GetDeffunctionNamePointer((VOID *) dptr));   ExpressionDeinstall(dptr->code);   ReturnPackedExpression(dptr->code);   SetDeffunctionPPForm((VOID *) dptr,NULL);   rtn_struct(deffunctionStruct,dptr);  }#endif/********************************************************  NAME         : UndeffunctionCommand  DESCRIPTION  : Deletes the named deffunction(s)  INPUTS       : None  RETURNS      : Nothing useful  SIDE EFFECTS : Deffunction(s) removed  NOTES        : CLIPS Syntax: (undeffunction <name> | *) ********************************************************/globle VOID UndeffunctionCommand()  {   UndefconstructCommand("undeffunction",DeffunctionConstruct);  }/****************************************************************  NAME         : GetDeffunctionModuleCommand  DESCRIPTION  : Determines to which module a deffunction belongs  INPUTS       : None  RETURNS      : The symbolic name of the module  SIDE EFFECTS : None  NOTES        : CLIPS Syntax: (deffunction-module <dfnx-name>) ****************************************************************/globle SYMBOL_HN *GetDeffunctionModuleCommand()  {   return(GetConstructModuleCommand("deffunction-module",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        : CLIPS Synatx: (ppdeffunction <name>) ****************************************************/globle VOID PPDeffunctionCommand()  {   PPConstructCommand("ppdeffunction",DeffunctionConstruct);  }/***************************************************  NAME         : ListDeffunctionsCommand  DESCRIPTION  : Displays all deffunction names  INPUTS       : None  RETURNS      : Nothing useful  SIDE EFFECTS : Deffunction name sprinted  NOTES        : CLIPS Interface ***************************************************/globle VOID ListDeffunctionsCommand()  {   ListConstructCommand("list-deffunctions",DeffunctionConstruct);  }/***************************************************  NAME         : ListDeffunctions  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 ListDeffunctions(logicalName,theModule)  char *logicalName;  struct defmodule *theModule;  {   ListConstruct(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        : CLIPS Syntax: (get-deffunction-list [<module>]) ***************************************************************/globle VOID GetDeffunctionListFunction(returnValue)  DATA_OBJECT*returnValue;  {   GetConstructListFunction("get-deffunction-list",returnValue,DeffunctionConstruct);  }/***************************************************************  NAME         : GetDeffunctionList  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 GetDeffunctionList(returnValue,theModule)  DATA_OBJECT *returnValue;  struct defmodule *theModule;  {   GetConstructList(returnValue,DeffunctionConstruct,theModule);  }  /*******************************************************  NAME         : CheckDeffunctionCall  DESCRIPTION  : Checks the number of arguments                 passed to a deffunction  INPUTS       : 1) Deffunction pointer                 2) The number of arguments  RETURNS      : CLIPS_TRUE if OK, CLIPS_FALSE otherwise  SIDE EFFECTS : Message printed on errors  NOTES        : None *******************************************************/globle int CheckDeffunctionCall(vdptr,args)  VOID *vdptr;  int args;  {   DEFFUNCTION *dptr;      if (vdptr == NULL)     return(CLIPS_FALSE);   dptr = (DEFFUNCTION *) vdptr;   if (args < dptr->minNumberOfParameters)     {      if (dptr->maxNumberOfParameters == -1)        ExpectedCountError(GetDeffunctionName((VOID *) dptr),                           AT_LEAST,dptr->minNumberOfParameters);      else        ExpectedCountError(GetDeffunctionName((VOID *) dptr),                           EXACTLY,dptr->minNumberOfParameters);      return(CLIPS_FALSE);     }   else if ((args > dptr->minNumberOfParameters) &&            (dptr->maxNumberOfParameters != -1))     {      ExpectedCountError(GetDeffunctionName((VOID *) dptr),                         EXACTLY,dptr->minNumberOfParameters);      return(CLIPS_FALSE);     }   return(CLIPS_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#endifstatic VOID PrintDeffunctionCall(log,value)  char *log;  VOID *value;  {#if MAC_MPW || MAC_MCW#pragma unused(log)#pragma unused(value)#endif#if DEVELOPER   PrintCLIPS(log,"(");   PrintCLIPS(log,GetDeffunctionName(value));   if (GetFirstArgument() != NULL)     {      PrintCLIPS(log," ");      PrintExpression(log,GetFirstArgument());     }   PrintCLIPS(log,")");#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      : CLIPS_FALSE if the deffunction                 returns the symbol CLIPS_FALSE,                 CLIPS_TRUE otherwise  SIDE EFFECTS : Data obejct buffer set and any                 side-effects of calling the deffunction  NOTES        : None *******************************************************/static BOOLEAN EvaluateDeffunctionCall(value,result)  VOID *value;  DATA_OBJECT *result;  {   CallDeffunction((DEFFUNCTION *) value,GetFirstArgument(),result);   if ((GetpType(result) == SYMBOL) &&       (GetpValue(result) == CLIPSFalseSymbol))     return(CLIPS_FALSE);   return(CLIPS_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(value)  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 (! 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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -