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

📄 modulbin.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 2 页
字号:
              theList != NULL;               theList = theList->next)           { NumberOfPortItems++; }        }              if (defmodulePtr->exportList == NULL)        { newDefmodule.exportList = -1L; }      else        {         newDefmodule.exportList = NumberOfPortItems;         for (theList = defmodulePtr->exportList;              theList != NULL;               theList = theList->next)           { NumberOfPortItems++; }        }            newDefmodule.bsaveID = defmodulePtr->bsaveID;       GenWrite(&newDefmodule,(unsigned long) sizeof(struct bsaveDefmodule),fp);     }   /*==========================================*/   /* Write out each port item data structure. */   /*==========================================*/   NumberOfPortItems = 0;   defmodulePtr = (struct defmodule *) GetNextDefmodule(NULL);   while (defmodulePtr != NULL)     {      for (theList = defmodulePtr->importList;           theList != NULL;            theList = theList->next)        {          NumberOfPortItems++;          if (theList->moduleName == NULL) newPortItem.moduleName = -1L;         else newPortItem.moduleName = (unsigned long) theList->moduleName->bucket;                  if (theList->constructType == NULL) newPortItem.constructType = -1L;         else newPortItem.constructType = (unsigned long) theList->constructType->bucket;                  if (theList->constructName == NULL) newPortItem.constructName = -1L;         else newPortItem.constructName = (unsigned long) theList->constructName->bucket;                  if (theList->next == NULL) newPortItem.next = -1L;         else newPortItem.next = NumberOfPortItems;                  GenWrite(&newPortItem,(unsigned long) sizeof(struct bsavePortItem),fp);        }              for (theList = defmodulePtr->exportList;           theList != NULL;            theList = theList->next)        {          NumberOfPortItems++;          if (theList->moduleName == NULL) newPortItem.moduleName = -1L;         else newPortItem.moduleName = (unsigned long) theList->moduleName->bucket;                  if (theList->constructType == NULL) newPortItem.constructType = -1L;         else newPortItem.constructType = (unsigned long) theList->constructType->bucket;                  if (theList->constructName == NULL) newPortItem.constructName = -1L;         else newPortItem.constructName = (unsigned long) theList->constructName->bucket;                  if (theList->next == NULL) newPortItem.next = -1L;         else newPortItem.next = NumberOfPortItems;                  GenWrite(&newPortItem,(unsigned long) sizeof(struct bsavePortItem),fp);        }              defmodulePtr = (struct defmodule *) GetNextDefmodule(defmodulePtr);     }   /*=============================================================*/   /* If a binary image was already loaded when the bsave command */   /* was issued, then restore the counts indicating the number   */   /* of defmodule and port items in the binary image (these were */   /* overwritten by the binary save).                            */   /*=============================================================*/           if (Bloaded())      {      RestoreBloadCount(&NumberOfDefmodules);      RestoreBloadCount(&NumberOfPortItems);     }  }  #endif /* BLOAD_AND_BSAVE *//**********************************************************//* BloadStorage: Allocates storage requirements for the   *//*   defmodules and port items used by this binary image. *//**********************************************************/static VOID BloadStorage()  {   unsigned long int space;      /*=======================================*/   /* Determine the number of defmodule and */   /* port item data structures to be read. */   /*=======================================*/   GenRead(&space,(unsigned long) sizeof(unsigned long int));   GenRead(&NumberOfDefmodules,(unsigned long) sizeof(long int));   GenRead(&NumberOfPortItems,(unsigned long) sizeof(long int));      /*================================*/   /* Allocate the space needed for  */   /* the defmodule data structures. */   /*================================*/   if (NumberOfDefmodules == 0)     {      DefmoduleArray = NULL;      return;     }   space = (unsigned long) (NumberOfDefmodules * sizeof(struct defmodule));   DefmoduleArray = (struct defmodule HUGE_ADDR *) genlongalloc(space);      /*================================*/   /* Allocate the space needed for  */   /* the port item data structures. */   /*================================*/   if (NumberOfPortItems == 0)     {      PortItemArray = NULL;      return;     }        space = (unsigned long) (NumberOfPortItems * sizeof(struct portItem));   PortItemArray = (struct portItem HUGE_ADDR *) genlongalloc(space);  }/********************************************//* BloadBinaryItem: Loads and refreshes the *//*   defmodules used by this binary image.  *//********************************************/static VOID BloadBinaryItem()  {   unsigned long int space;   GenRead(&space,(unsigned long) sizeof(unsigned long int));   if (NumberOfDefmodules == 0) return;   BloadandRefresh(NumberOfDefmodules,(unsigned) sizeof(struct bsaveDefmodule),UpdateDefmodule);   BloadandRefresh(NumberOfPortItems,(unsigned) sizeof(struct bsavePortItem),UpdatePortItem);   SetListOfDefmodules((VOID *) DefmoduleArray);   SetCurrentModule((VOID *) GetNextDefmodule(NULL));  }  /******************************************//* UpdateDefmodule: Bload refresh routine *//*   for defmodule data structure.        *//******************************************/static VOID UpdateDefmodule(buf,obji)  VOID *buf;  long obji;  {   struct bsaveDefmodule *bdp;   struct moduleItem *theItem;   int i;      bdp = (struct bsaveDefmodule *) buf;   DefmoduleArray[obji].name = SymbolPointer(bdp->name);   IncrementSymbolCount(DefmoduleArray[obji].name);   if (bdp->next != -1L)     { DefmoduleArray[obji].next = (struct defmodule *) &DefmoduleArray[bdp->next]; }   else     { DefmoduleArray[obji].next = NULL; }           DefmoduleArray[obji].itemsArray = (struct defmoduleItemHeader **) gm2((int) sizeof(VOID *) * GetNumberOfModuleItems());      for (i = 0, theItem = GetListOfModuleItems();        (i < GetNumberOfModuleItems()) && (theItem != NULL) ;         i++, theItem = theItem->next)     {       if (theItem->bloadModuleReference == NULL)        { DefmoduleArray[obji].itemsArray[i] = NULL; }      else        {          DefmoduleArray[obji].itemsArray[i] =              (struct defmoduleItemHeader *)             (*theItem->bloadModuleReference)(obji);        }     }       DefmoduleArray[obji].ppForm = NULL;      if (bdp->importList != -1L)      { DefmoduleArray[obji].importList = (struct portItem *) &PortItemArray[bdp->importList]; }   else      { DefmoduleArray[obji].importList = NULL; }   if (bdp->exportList != -1L)      { DefmoduleArray[obji].exportList = (struct portItem *) &PortItemArray[bdp->exportList]; }   else      { DefmoduleArray[obji].exportList = NULL; }   DefmoduleArray[obji].bsaveID = bdp->bsaveID;  }  /*****************************************//* UpdatePortItem: Bload refresh routine *//*   for port item data structure.       *//*****************************************/static VOID UpdatePortItem(buf,obji)  VOID *buf;  long obji;  {   struct bsavePortItem *bdp;      bdp = (struct bsavePortItem *) buf;      if (bdp->moduleName != -1L)     {       PortItemArray[obji].moduleName = SymbolPointer(bdp->moduleName);      IncrementSymbolCount(PortItemArray[obji].moduleName);     }   else     { PortItemArray[obji].moduleName = NULL; }   if (bdp->constructType != -1L)     {       PortItemArray[obji].constructType = SymbolPointer(bdp->constructType);      IncrementSymbolCount(PortItemArray[obji].constructType);     }   else     { PortItemArray[obji].constructType = NULL; }   if (bdp->constructName != -1L)     {       PortItemArray[obji].constructName = SymbolPointer(bdp->constructName);      IncrementSymbolCount(PortItemArray[obji].constructName);     }   else     { PortItemArray[obji].constructName = NULL; }   if (bdp->next != -1L)     { PortItemArray[obji].next = (struct portItem *) &PortItemArray[bdp->next]; }   else     { PortItemArray[obji].next = NULL; }  }  /***************************************//* ClearBload: Defmodule clear routine *//*   when a binary load is in effect.  *//***************************************/static VOID ClearBload()  {   long i;   unsigned long space;   struct portItem *theList;   /*===========================*/   /* Decrement in use counters */   /* used by the binary image. */   /*===========================*/      for (i = 0; i < NumberOfDefmodules; i++)     {       DecrementSymbolCount(DefmoduleArray[i].name);      for (theList = DefmoduleArray[i].importList;           theList != NULL;           theList = theList->next)        {         if (theList->moduleName != NULL) DecrementSymbolCount(theList->moduleName);         if (theList->constructType != NULL) DecrementSymbolCount(theList->constructType);         if (theList->constructName != NULL) DecrementSymbolCount(theList->constructName);        }              for (theList = DefmoduleArray[i].exportList;           theList != NULL;           theList = theList->next)        {         if (theList->moduleName != NULL) DecrementSymbolCount(theList->moduleName);         if (theList->constructType != NULL) DecrementSymbolCount(theList->constructType);         if (theList->constructName != NULL) DecrementSymbolCount(theList->constructName);        }              rm(DefmoduleArray[i].itemsArray,(int) sizeof(VOID *) * GetNumberOfModuleItems());     }   /*================================*/   /* Deallocate the space used for  */   /* the defmodule data structures. */   /*================================*/      space = NumberOfDefmodules * sizeof(struct defmodule);   if (space != 0) genlongfree((VOID *) DefmoduleArray,space);      /*================================*/   /* Deallocate the space used for  */   /* the port item data structures. */   /*================================*/      space = NumberOfPortItems * sizeof(struct portItem);   if (space != 0) genlongfree((VOID *) PortItemArray,space);   /*===========================*/   /* Reset module information. */   /*===========================*/      SetListOfDefmodules(NULL);   CreateMainModule();   MainModuleRedefinable = CLIPS_TRUE;  }#endif /*  (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME) */

⌨️ 快捷键说明

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