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

📄 tmpltbin.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 2 页
字号:
      SetCurrentModule((VOID *) theModule);         for (theDeftemplate = (struct deftemplate *) GetNextDeftemplate(NULL);           theDeftemplate != NULL;           theDeftemplate = (struct deftemplate *) GetNextDeftemplate(theDeftemplate))        {         for (theSlot = theDeftemplate->slotList;              theSlot != NULL;              theSlot = theSlot->next)           {            tempTemplateSlot.constraints = ConstraintIndex(theSlot->constraints);             tempTemplateSlot.slotName = (long) theSlot->slotName->bucket;            tempTemplateSlot.multislot = theSlot->multislot;            tempTemplateSlot.noDefault = theSlot->noDefault;            tempTemplateSlot.defaultPresent = theSlot->defaultPresent;            tempTemplateSlot.defaultDynamic = theSlot->defaultDynamic;            tempTemplateSlot.defaultList = HashedExpressionIndex(theSlot->defaultList);            if (theSlot->next != NULL) tempTemplateSlot.next = 0L;            else tempTemplateSlot.next = -1L;            GenWrite(&tempTemplateSlot,(unsigned long) sizeof(struct bsaveTemplateSlot),fp);           }        }     }      /*=============================================================*/   /* If a binary image was already loaded when the bsave command */   /* was issued, then restore the counts indicating the number   */   /* of deftemplates, deftemplate modules, and deftemplate slots */   /* in the binary image (these were overwritten by the binary   */   /* save).                                                      */   /*=============================================================*/   if (Bloaded())     {      RestoreBloadCount(&NumberOfDeftemplates);      RestoreBloadCount(&NumberOfTemplateSlots);      RestoreBloadCount(&NumberOfTemplateModules);     }  } #endif /* BLOAD_AND_BSAVE *//****************************************************//* BloadStorage: Allocates storage requirements for *//*   the deftemplates used by this binary image.    *//****************************************************/static VOID BloadStorage()  {   unsigned long int space;   /*=========================================================*/   /* Determine the number of deftemplate, deftemplateModule, */   /* and templateSlot data structures to be read.            */   /*=========================================================*/      GenRead(&space,(unsigned long) sizeof(unsigned long int));   GenRead(&NumberOfDeftemplates,(unsigned long) sizeof(long int));   GenRead(&NumberOfTemplateSlots,(unsigned long) sizeof(long int));   GenRead(&NumberOfTemplateModules,(unsigned long) sizeof(long int));      /*====================================*/   /* Allocate the space needed for the  */   /* deftemplateModule data structures. */   /*====================================*/      if (NumberOfTemplateModules == 0)     {      DeftemplateArray = NULL;      SlotArray = NULL;      ModuleArray = NULL;      return;     }        space = NumberOfTemplateModules * sizeof(struct deftemplateModule);   ModuleArray = (struct deftemplateModule HUGE_ADDR *) genlongalloc(space);      /*===================================*/   /* Allocate the space needed for the */   /* deftemplate data structures.      */   /*===================================*/      if (NumberOfDeftemplates == 0)     {      DeftemplateArray = NULL;      SlotArray = NULL;      return;     }   space = NumberOfDeftemplates * sizeof(struct deftemplate);   DeftemplateArray = (struct deftemplate HUGE_ADDR *) genlongalloc(space);   /*===================================*/   /* Allocate the space needed for the */   /* templateSlot data structures.     */   /*===================================*/      if (NumberOfTemplateSlots == 0)     {      SlotArray = NULL;      return;     }   space =  NumberOfTemplateSlots * sizeof(struct templateSlot);   SlotArray = (struct templateSlot HUGE_ADDR *) genlongalloc(space);  }/********************************************************//* BloadBinaryItem: Loads and refreshes the deftemplate *//*   constructs used by this binary image.              *//********************************************************/static VOID BloadBinaryItem()  {   unsigned long int space;      /*======================================================*/   /* Read in the amount of space used by the binary image */   /* (this is used to skip the construct in the event it  */   /* is not available in the version of CLIPS being run). */   /*======================================================*/   GenRead(&space,(unsigned long) sizeof(unsigned long int));      /*===============================================*/   /* Read in the deftemplateModule data structures */   /* and refresh the pointers.                     */   /*===============================================*/   BloadandRefresh(NumberOfTemplateModules,(unsigned) sizeof(struct bsaveDeftemplateModule),                   UpdateDeftemplateModule);                      /*===============================================*/   /* Read in the deftemplateModule data structures */   /* and refresh the pointers.                     */   /*===============================================*/   BloadandRefresh(NumberOfDeftemplates,(unsigned) sizeof(struct bsaveDeftemplate),                   UpdateDeftemplate);                      /*==========================================*/   /* Read in the templateSlot data structures */   /* and refresh the pointers.                */   /*==========================================*/      BloadandRefresh(NumberOfTemplateSlots,(unsigned) sizeof(struct bsaveTemplateSlot),                   UpdateDeftemplateSlot);  }  /**************************************************//* UpdateDeftemplateModule: Bload refresh routine *//*   for deftemplateModule data structures.       *//**************************************************/static VOID UpdateDeftemplateModule(buf,obji)  VOID *buf;  long obji;  {   struct bsaveDeftemplateModule *bdmPtr;      bdmPtr = (struct bsaveDeftemplateModule *) buf;   UpdateDefmoduleItemHeader(&bdmPtr->header,&ModuleArray[obji].header,                             (int) sizeof(struct deftemplate),                             (VOID *) DeftemplateArray);  }  /********************************************//* UpdateDeftemplate: Bload refresh routine *//*   for deftemplate data structures.       *//********************************************/static VOID UpdateDeftemplate(buf,obji)  VOID *buf;  long obji;  {   struct deftemplate *theDeftemplate;   struct bsaveDeftemplate *bdtPtr;      bdtPtr = (struct bsaveDeftemplate *) buf;   theDeftemplate = (struct deftemplate *) &DeftemplateArray[obji];   UpdateConstructHeader(&bdtPtr->header,&theDeftemplate->header,                         (int) sizeof(struct deftemplateModule),(VOID *) ModuleArray,                         (int) sizeof(struct deftemplate),(VOID *) DeftemplateArray);      if (bdtPtr->slotList != -1L)     { theDeftemplate->slotList = (struct templateSlot *) &SlotArray[bdtPtr->slotList]; }   else     { theDeftemplate->slotList = NULL; }      if (bdtPtr->patternNetwork != -1L)     { theDeftemplate->patternNetwork = (struct factPatternNode *) BloadFactPatternPointer(bdtPtr->patternNetwork); }   else     { theDeftemplate->patternNetwork = NULL; }        theDeftemplate->implied = bdtPtr->implied;#if DEBUGGING_FUNCTIONS   theDeftemplate->watch = WatchFacts;#endif   theDeftemplate->inScope = CLIPS_FALSE;   theDeftemplate->numberOfSlots = bdtPtr->numberOfSlots;  }/************************************************//* UpdateDeftemplateSlot: Bload refresh routine *//*   for templateSlot data structures.          *//************************************************/static VOID UpdateDeftemplateSlot(buf,obji)  VOID *buf;  long obji;  {   struct templateSlot *theSlot;   struct bsaveTemplateSlot *btsPtr;   btsPtr = (struct bsaveTemplateSlot *) buf;   theSlot = (struct templateSlot *) &SlotArray[obji];   theSlot->slotName = SymbolPointer(btsPtr->slotName);   IncrementSymbolCount(theSlot->slotName);   theSlot->defaultList = HashedExpressionPointer(btsPtr->defaultList);   theSlot->constraints = ConstraintPointer(btsPtr->constraints);      theSlot->multislot = btsPtr->multislot;   theSlot->noDefault = btsPtr->noDefault;   theSlot->defaultPresent = btsPtr->defaultPresent;   theSlot->defaultDynamic = btsPtr->defaultDynamic;      if (btsPtr->next != -1L)     { theSlot->next = (struct templateSlot *) &SlotArray[obji + 1]; }   else     { theSlot->next = NULL; }  }  /*****************************************//* ClearBload: Deftemplate clear routine *//*   when a binary load is in effect.    *//*****************************************/static VOID ClearBload()  {   unsigned long int space;   int i;      /*=============================================*/   /* Decrement in use counters for atomic values */   /* contained in the construct headers.         */   /*=============================================*/     for (i = 0; i < NumberOfDeftemplates; i++)     { UnmarkConstructHeader(&DeftemplateArray[i].header); }      /*=======================================*/   /* Decrement in use counters for symbols */   /* used as slot names.                   */   /*=======================================*/   for (i = 0; i < NumberOfTemplateSlots; i++)     { DecrementSymbolCount(SlotArray[i].slotName); }        /*======================================================================*/   /* Deallocate the space used for the deftemplateModule data structures. */   /*======================================================================*/   space =  NumberOfTemplateModules * sizeof(struct deftemplateModule);   if (space != 0) genlongfree((VOID *) ModuleArray,space);           /*================================================================*/   /* Deallocate the space used for the deftemplate data structures. */   /*================================================================*/   space = NumberOfDeftemplates * sizeof(struct deftemplate);   if (space != 0) genlongfree((VOID *) DeftemplateArray,space);        /*=================================================================*/   /* Deallocate the space used for the templateSlot data structures. */   /*=================================================================*/   space =  NumberOfTemplateSlots * sizeof(struct templateSlot);   if (space != 0) genlongfree((VOID *) SlotArray,space);      /*======================================*/   /* Create the initial-fact deftemplate. */   /*======================================*/   #if (! BLOAD_ONLY)   CreateImpliedDeftemplate(AddSymbol("initial-fact"),CLIPS_FALSE);#endif  }  /************************************************************//* BloadDeftemplateModuleReference: Returns the deftemplate *//*   module pointer for use with the bload function.        *//************************************************************/globle VOID *BloadDeftemplateModuleReference(index)  int index;  {   return ((VOID *) &ModuleArray[index]);  }  #endif /* DEFTEMPLATE_CONSTRUCT && (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME) */

⌨️ 快捷键说明

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