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

📄 modulbin.c

📁 clips源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
      GenWrite(&newDefmodule,sizeof(struct bsaveDefmodule),fp);     }   /*==========================================*/   /* Write out each port item data structure. */   /*==========================================*/   DefmoduleData(theEnv)->NumberOfPortItems = 0;   defmodulePtr = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL);   while (defmodulePtr != NULL)     {      for (theList = defmodulePtr->importList;           theList != NULL;           theList = theList->next)        {         DefmoduleData(theEnv)->NumberOfPortItems++;         if (theList->moduleName == NULL) newPortItem.moduleName = -1L;         else newPortItem.moduleName = (long) theList->moduleName->bucket;         if (theList->constructType == NULL) newPortItem.constructType = -1L;         else newPortItem.constructType = (long) theList->constructType->bucket;         if (theList->constructName == NULL) newPortItem.constructName = -1L;         else newPortItem.constructName = (long) theList->constructName->bucket;         if (theList->next == NULL) newPortItem.next = -1L;         else newPortItem.next = DefmoduleData(theEnv)->NumberOfPortItems;         GenWrite(&newPortItem,sizeof(struct bsavePortItem),fp);        }      for (theList = defmodulePtr->exportList;           theList != NULL;           theList = theList->next)        {         DefmoduleData(theEnv)->NumberOfPortItems++;         if (theList->moduleName == NULL) newPortItem.moduleName = -1L;         else newPortItem.moduleName = (long) theList->moduleName->bucket;         if (theList->constructType == NULL) newPortItem.constructType = -1L;         else newPortItem.constructType = (long) theList->constructType->bucket;         if (theList->constructName == NULL) newPortItem.constructName = -1L;         else newPortItem.constructName = (long) theList->constructName->bucket;         if (theList->next == NULL) newPortItem.next = -1L;         else newPortItem.next = DefmoduleData(theEnv)->NumberOfPortItems;         GenWrite(&newPortItem,sizeof(struct bsavePortItem),fp);        }      defmodulePtr = (struct defmodule *) EnvGetNextDefmodule(theEnv,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).                            */   /*=============================================================*/   RestoreBloadCount(theEnv,&DefmoduleData(theEnv)->BNumberOfDefmodules);   RestoreBloadCount(theEnv,&DefmoduleData(theEnv)->NumberOfPortItems);  }#endif /* BLOAD_AND_BSAVE *//**********************************************************//* BloadStorage: Allocates storage requirements for the   *//*   defmodules and port items used by this binary image. *//**********************************************************/static void BloadStorage(  void *theEnv)  {   size_t space;   /*=======================================*/   /* Determine the number of defmodule and */   /* port item data structures to be read. */   /*=======================================*/   GenReadBinary(theEnv,&space,sizeof(size_t));   GenReadBinary(theEnv,&DefmoduleData(theEnv)->BNumberOfDefmodules,sizeof(long int));   GenReadBinary(theEnv,&DefmoduleData(theEnv)->NumberOfPortItems,sizeof(long int));   /*================================*/   /* Allocate the space needed for  */   /* the defmodule data structures. */   /*================================*/   if (DefmoduleData(theEnv)->BNumberOfDefmodules == 0)     {      DefmoduleData(theEnv)->DefmoduleArray = NULL;      return;     }   space = (DefmoduleData(theEnv)->BNumberOfDefmodules * sizeof(struct defmodule));   DefmoduleData(theEnv)->DefmoduleArray = (struct defmodule *) genalloc(theEnv,space);   /*================================*/   /* Allocate the space needed for  */   /* the port item data structures. */   /*================================*/   if (DefmoduleData(theEnv)->NumberOfPortItems == 0)     {      DefmoduleData(theEnv)->PortItemArray = NULL;      return;     }   space = (DefmoduleData(theEnv)->NumberOfPortItems * sizeof(struct portItem));   DefmoduleData(theEnv)->PortItemArray = (struct portItem *) genalloc(theEnv,space);  }/********************************************//* BloadBinaryItem: Loads and refreshes the *//*   defmodules used by this binary image.  *//********************************************/static void BloadBinaryItem(  void *theEnv)  {   size_t space;   GenReadBinary(theEnv,&space,sizeof(size_t));   if (DefmoduleData(theEnv)->BNumberOfDefmodules == 0) return;   BloadandRefresh(theEnv,DefmoduleData(theEnv)->BNumberOfDefmodules,sizeof(struct bsaveDefmodule),UpdateDefmodule);   BloadandRefresh(theEnv,DefmoduleData(theEnv)->NumberOfPortItems,sizeof(struct bsavePortItem),UpdatePortItem);   SetListOfDefmodules(theEnv,(void *) DefmoduleData(theEnv)->DefmoduleArray);   EnvSetCurrentModule(theEnv,(void *) EnvGetNextDefmodule(theEnv,NULL));  }/******************************************//* UpdateDefmodule: Bload refresh routine *//*   for defmodule data structure.        *//******************************************/static void UpdateDefmodule(  void *theEnv,  void *buf,  long obji)  {   struct bsaveDefmodule *bdp;   struct moduleItem *theItem;   int i;   bdp = (struct bsaveDefmodule *) buf;   DefmoduleData(theEnv)->DefmoduleArray[obji].name = SymbolPointer(bdp->name);   IncrementSymbolCount(DefmoduleData(theEnv)->DefmoduleArray[obji].name);   if (bdp->next != -1L)     { DefmoduleData(theEnv)->DefmoduleArray[obji].next = (struct defmodule *) &DefmoduleData(theEnv)->DefmoduleArray[bdp->next]; }   else     { DefmoduleData(theEnv)->DefmoduleArray[obji].next = NULL; }   if (GetNumberOfModuleItems(theEnv) == 0)     { DefmoduleData(theEnv)->DefmoduleArray[obji].itemsArray = NULL; }   else     {      DefmoduleData(theEnv)->DefmoduleArray[obji].itemsArray =          (struct defmoduleItemHeader **) gm2(theEnv,sizeof(void *) * GetNumberOfModuleItems(theEnv));     }   for (i = 0, theItem = GetListOfModuleItems(theEnv);        (i < GetNumberOfModuleItems(theEnv)) && (theItem != NULL) ;        i++, theItem = theItem->next)     {      if (theItem->bloadModuleReference == NULL)        { DefmoduleData(theEnv)->DefmoduleArray[obji].itemsArray[i] = NULL; }      else        {         DefmoduleData(theEnv)->DefmoduleArray[obji].itemsArray[i] =             (struct defmoduleItemHeader *)             (*theItem->bloadModuleReference)(theEnv,obji);        }     }   DefmoduleData(theEnv)->DefmoduleArray[obji].ppForm = NULL;   if (bdp->importList != -1L)     { DefmoduleData(theEnv)->DefmoduleArray[obji].importList = (struct portItem *) &DefmoduleData(theEnv)->PortItemArray[bdp->importList]; }   else     { DefmoduleData(theEnv)->DefmoduleArray[obji].importList = NULL; }   if (bdp->exportList != -1L)     { DefmoduleData(theEnv)->DefmoduleArray[obji].exportList = (struct portItem *) &DefmoduleData(theEnv)->PortItemArray[bdp->exportList]; }   else     { DefmoduleData(theEnv)->DefmoduleArray[obji].exportList = NULL; }   DefmoduleData(theEnv)->DefmoduleArray[obji].bsaveID = bdp->bsaveID;  }/*****************************************//* UpdatePortItem: Bload refresh routine *//*   for port item data structure.       *//*****************************************/static void UpdatePortItem(  void *theEnv,  void *buf,  long obji)  {   struct bsavePortItem *bdp;   bdp = (struct bsavePortItem *) buf;   if (bdp->moduleName != -1L)     {      DefmoduleData(theEnv)->PortItemArray[obji].moduleName = SymbolPointer(bdp->moduleName);      IncrementSymbolCount(DefmoduleData(theEnv)->PortItemArray[obji].moduleName);     }   else     { DefmoduleData(theEnv)->PortItemArray[obji].moduleName = NULL; }   if (bdp->constructType != -1L)     {      DefmoduleData(theEnv)->PortItemArray[obji].constructType = SymbolPointer(bdp->constructType);      IncrementSymbolCount(DefmoduleData(theEnv)->PortItemArray[obji].constructType);     }   else     { DefmoduleData(theEnv)->PortItemArray[obji].constructType = NULL; }   if (bdp->constructName != -1L)     {      DefmoduleData(theEnv)->PortItemArray[obji].constructName = SymbolPointer(bdp->constructName);      IncrementSymbolCount(DefmoduleData(theEnv)->PortItemArray[obji].constructName);     }   else     { DefmoduleData(theEnv)->PortItemArray[obji].constructName = NULL; }   if (bdp->next != -1L)     { DefmoduleData(theEnv)->PortItemArray[obji].next = (struct portItem *) &DefmoduleData(theEnv)->PortItemArray[bdp->next]; }   else     { DefmoduleData(theEnv)->PortItemArray[obji].next = NULL; }  }/***************************************//* ClearBload: Defmodule clear routine *//*   when a binary load is in effect.  *//***************************************/static void ClearBload(  void *theEnv)  {   long i;   size_t space;   struct portItem *theList;   /*===========================*/   /* Decrement in use counters */   /* used by the binary image. */   /*===========================*/   for (i = 0; i < DefmoduleData(theEnv)->BNumberOfDefmodules; i++)     {      DecrementSymbolCount(theEnv,DefmoduleData(theEnv)->DefmoduleArray[i].name);      for (theList = DefmoduleData(theEnv)->DefmoduleArray[i].importList;           theList != NULL;           theList = theList->next)        {         if (theList->moduleName != NULL) DecrementSymbolCount(theEnv,theList->moduleName);         if (theList->constructType != NULL) DecrementSymbolCount(theEnv,theList->constructType);         if (theList->constructName != NULL) DecrementSymbolCount(theEnv,theList->constructName);        }      for (theList = DefmoduleData(theEnv)->DefmoduleArray[i].exportList;           theList != NULL;           theList = theList->next)        {         if (theList->moduleName != NULL) DecrementSymbolCount(theEnv,theList->moduleName);         if (theList->constructType != NULL) DecrementSymbolCount(theEnv,theList->constructType);         if (theList->constructName != NULL) DecrementSymbolCount(theEnv,theList->constructName);        }      rm(theEnv,DefmoduleData(theEnv)->DefmoduleArray[i].itemsArray,sizeof(void *) * GetNumberOfModuleItems(theEnv));     }   /*================================*/   /* Deallocate the space used for  */   /* the defmodule data structures. */   /*================================*/   space = DefmoduleData(theEnv)->BNumberOfDefmodules * sizeof(struct defmodule);   if (space != 0) genfree(theEnv,(void *) DefmoduleData(theEnv)->DefmoduleArray,space);   DefmoduleData(theEnv)->BNumberOfDefmodules = 0;      /*================================*/   /* Deallocate the space used for  */   /* the port item data structures. */   /*================================*/   space = DefmoduleData(theEnv)->NumberOfPortItems * sizeof(struct portItem);   if (space != 0) genfree(theEnv,(void *) DefmoduleData(theEnv)->PortItemArray,space);   DefmoduleData(theEnv)->NumberOfPortItems = 0;      /*===========================*/   /* Reset module information. */   /*===========================*/   SetListOfDefmodules(theEnv,NULL);   CreateMainModule(theEnv);   DefmoduleData(theEnv)->MainModuleRedefinable = TRUE;  }#endif /*  (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME) */

⌨️ 快捷键说明

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