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

📄 tmpltbin.c

📁 clips源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
              theSlot != NULL;              theSlot = theSlot->next)           {            tempTemplateSlot.constraints = ConstraintIndex(theSlot->constraints);            tempTemplateSlot.slotName = theSlot->slotName->bucket;            tempTemplateSlot.multislot = theSlot->multislot;            tempTemplateSlot.noDefault = theSlot->noDefault;            tempTemplateSlot.defaultPresent = theSlot->defaultPresent;            tempTemplateSlot.defaultDynamic = theSlot->defaultDynamic;            tempTemplateSlot.defaultList = HashedExpressionIndex(theEnv,theSlot->defaultList);            if (theSlot->next != NULL) tempTemplateSlot.next = 0L;            else tempTemplateSlot.next = -1L;            GenWrite(&tempTemplateSlot,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).                                                      */   /*=============================================================*/   RestoreBloadCount(theEnv,&DeftemplateBinaryData(theEnv)->NumberOfDeftemplates);   RestoreBloadCount(theEnv,&DeftemplateBinaryData(theEnv)->NumberOfTemplateSlots);   RestoreBloadCount(theEnv,&DeftemplateBinaryData(theEnv)->NumberOfTemplateModules);  }#endif /* BLOAD_AND_BSAVE *//****************************************************//* BloadStorage: Allocates storage requirements for *//*   the deftemplates used by this binary image.    *//****************************************************/static void BloadStorage(  void *theEnv)  {   size_t space;   /*=========================================================*/   /* Determine the number of deftemplate, deftemplateModule, */   /* and templateSlot data structures to be read.            */   /*=========================================================*/   GenReadBinary(theEnv,&space,sizeof(size_t));   GenReadBinary(theEnv,&DeftemplateBinaryData(theEnv)->NumberOfDeftemplates,sizeof(long int));   GenReadBinary(theEnv,&DeftemplateBinaryData(theEnv)->NumberOfTemplateSlots,sizeof(long int));   GenReadBinary(theEnv,&DeftemplateBinaryData(theEnv)->NumberOfTemplateModules,sizeof(long int));   /*====================================*/   /* Allocate the space needed for the  */   /* deftemplateModule data structures. */   /*====================================*/   if (DeftemplateBinaryData(theEnv)->NumberOfTemplateModules == 0)     {      DeftemplateBinaryData(theEnv)->DeftemplateArray = NULL;      DeftemplateBinaryData(theEnv)->SlotArray = NULL;      DeftemplateBinaryData(theEnv)->ModuleArray = NULL;      return;     }   space = DeftemplateBinaryData(theEnv)->NumberOfTemplateModules * sizeof(struct deftemplateModule);   DeftemplateBinaryData(theEnv)->ModuleArray = (struct deftemplateModule *) genalloc(theEnv,space);   /*===================================*/   /* Allocate the space needed for the */   /* deftemplate data structures.      */   /*===================================*/   if (DeftemplateBinaryData(theEnv)->NumberOfDeftemplates == 0)     {      DeftemplateBinaryData(theEnv)->DeftemplateArray = NULL;      DeftemplateBinaryData(theEnv)->SlotArray = NULL;      return;     }   space = DeftemplateBinaryData(theEnv)->NumberOfDeftemplates * sizeof(struct deftemplate);   DeftemplateBinaryData(theEnv)->DeftemplateArray = (struct deftemplate *) genalloc(theEnv,space);   /*===================================*/   /* Allocate the space needed for the */   /* templateSlot data structures.     */   /*===================================*/   if (DeftemplateBinaryData(theEnv)->NumberOfTemplateSlots == 0)     {      DeftemplateBinaryData(theEnv)->SlotArray = NULL;      return;     }   space =  DeftemplateBinaryData(theEnv)->NumberOfTemplateSlots * sizeof(struct templateSlot);   DeftemplateBinaryData(theEnv)->SlotArray = (struct templateSlot *) genalloc(theEnv,space);  }/********************************************************//* BloadBinaryItem: Loads and refreshes the deftemplate *//*   constructs used by this binary image.              *//********************************************************/static void BloadBinaryItem(  void *theEnv)  {   size_t 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 being run).          */   /*======================================================*/   GenReadBinary(theEnv,&space,sizeof(size_t));   /*===============================================*/   /* Read in the deftemplateModule data structures */   /* and refresh the pointers.                     */   /*===============================================*/   BloadandRefresh(theEnv,DeftemplateBinaryData(theEnv)->NumberOfTemplateModules,sizeof(struct bsaveDeftemplateModule),                   UpdateDeftemplateModule);   /*===============================================*/   /* Read in the deftemplateModule data structures */   /* and refresh the pointers.                     */   /*===============================================*/   BloadandRefresh(theEnv,DeftemplateBinaryData(theEnv)->NumberOfDeftemplates,sizeof(struct bsaveDeftemplate),                   UpdateDeftemplate);   /*==========================================*/   /* Read in the templateSlot data structures */   /* and refresh the pointers.                */   /*==========================================*/   BloadandRefresh(theEnv,DeftemplateBinaryData(theEnv)->NumberOfTemplateSlots,sizeof(struct bsaveTemplateSlot),                   UpdateDeftemplateSlot);  }/**************************************************//* UpdateDeftemplateModule: Bload refresh routine *//*   for deftemplateModule data structures.       *//**************************************************/static void UpdateDeftemplateModule(  void *theEnv,  void *buf,  long obji)  {   struct bsaveDeftemplateModule *bdmPtr;   bdmPtr = (struct bsaveDeftemplateModule *) buf;   UpdateDefmoduleItemHeader(theEnv,&bdmPtr->header,&DeftemplateBinaryData(theEnv)->ModuleArray[obji].header,                             (int) sizeof(struct deftemplate),                             (void *) DeftemplateBinaryData(theEnv)->DeftemplateArray);  }/********************************************//* UpdateDeftemplate: Bload refresh routine *//*   for deftemplate data structures.       *//********************************************/static void UpdateDeftemplate(  void *theEnv,  void *buf,  long obji)  {   struct deftemplate *theDeftemplate;   struct bsaveDeftemplate *bdtPtr;   bdtPtr = (struct bsaveDeftemplate *) buf;   theDeftemplate = (struct deftemplate *) &DeftemplateBinaryData(theEnv)->DeftemplateArray[obji];   UpdateConstructHeader(theEnv,&bdtPtr->header,&theDeftemplate->header,                         (int) sizeof(struct deftemplateModule),(void *) DeftemplateBinaryData(theEnv)->ModuleArray,                         (int) sizeof(struct deftemplate),(void *) DeftemplateBinaryData(theEnv)->DeftemplateArray);   if (bdtPtr->slotList != -1L)     { theDeftemplate->slotList = (struct templateSlot *) &DeftemplateBinaryData(theEnv)->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 = FactData(theEnv)->WatchFacts;#endif   theDeftemplate->inScope = FALSE;   theDeftemplate->numberOfSlots = (unsigned short) bdtPtr->numberOfSlots;   theDeftemplate->factList = NULL;   theDeftemplate->lastFact = NULL;  }/************************************************//* UpdateDeftemplateSlot: Bload refresh routine *//*   for templateSlot data structures.          *//************************************************/static void UpdateDeftemplateSlot(  void *theEnv,  void *buf,  long obji)  {   struct templateSlot *theSlot;   struct bsaveTemplateSlot *btsPtr;   btsPtr = (struct bsaveTemplateSlot *) buf;   theSlot = (struct templateSlot *) &DeftemplateBinaryData(theEnv)->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 *) &DeftemplateBinaryData(theEnv)->SlotArray[obji + 1]; }   else     { theSlot->next = NULL; }  }/*****************************************//* ClearBload: Deftemplate clear routine *//*   when a binary load is in effect.    *//*****************************************/static void ClearBload(  void *theEnv)  {   size_t space;   int i;   /*=============================================*/   /* Decrement in use counters for atomic values */   /* contained in the construct headers.         */   /*=============================================*/   for (i = 0; i < DeftemplateBinaryData(theEnv)->NumberOfDeftemplates; i++)     { UnmarkConstructHeader(theEnv,&DeftemplateBinaryData(theEnv)->DeftemplateArray[i].header); }   /*=======================================*/   /* Decrement in use counters for symbols */   /* used as slot names.                   */   /*=======================================*/   for (i = 0; i < DeftemplateBinaryData(theEnv)->NumberOfTemplateSlots; i++)     { DecrementSymbolCount(theEnv,DeftemplateBinaryData(theEnv)->SlotArray[i].slotName); }   /*======================================================================*/   /* Deallocate the space used for the deftemplateModule data structures. */   /*======================================================================*/   space =  DeftemplateBinaryData(theEnv)->NumberOfTemplateModules * sizeof(struct deftemplateModule);   if (space != 0) genfree(theEnv,(void *) DeftemplateBinaryData(theEnv)->ModuleArray,space);   DeftemplateBinaryData(theEnv)->NumberOfTemplateModules = 0;      /*================================================================*/   /* Deallocate the space used for the deftemplate data structures. */   /*================================================================*/   space = DeftemplateBinaryData(theEnv)->NumberOfDeftemplates * sizeof(struct deftemplate);   if (space != 0) genfree(theEnv,(void *) DeftemplateBinaryData(theEnv)->DeftemplateArray,space);   DeftemplateBinaryData(theEnv)->NumberOfDeftemplates = 0;      /*=================================================================*/   /* Deallocate the space used for the templateSlot data structures. */   /*=================================================================*/   space =  DeftemplateBinaryData(theEnv)->NumberOfTemplateSlots * sizeof(struct templateSlot);   if (space != 0) genfree(theEnv,(void *) DeftemplateBinaryData(theEnv)->SlotArray,space);   DeftemplateBinaryData(theEnv)->NumberOfTemplateSlots = 0;      /*======================================*/   /* Create the initial-fact deftemplate. */   /*======================================*/#if (! BLOAD_ONLY)   CreateImpliedDeftemplate(theEnv,(SYMBOL_HN *) EnvAddSymbol(theEnv,"initial-fact"),FALSE);#endif  }/************************************************************//* BloadDeftemplateModuleReference: Returns the deftemplate *//*   module pointer for use with the bload function.        *//************************************************************/globle void *BloadDeftemplateModuleReference(  void *theEnv,  int theIndex)  {   return ((void *) &DeftemplateBinaryData(theEnv)->ModuleArray[theIndex]);  }#endif /* DEFTEMPLATE_CONSTRUCT && (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME) */

⌨️ 快捷键说明

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