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

📄 modulutl.c

📁 clips源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
   DefmoduleData(theEnv)->CurrentModule->visitedFlag = FALSE;   for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL);        theModule != NULL;        theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule))     { theModule->visitedFlag = FALSE; }  }/***********************************************************//* SearchImportedConstructModules: Low level routine which *//*   searches a module and other modules from which it     *//*   imports constructs for a specified construct.         *//***********************************************************/static void *SearchImportedConstructModules(  void *theEnv,  struct symbolHashNode *constructType,  struct defmodule *matchModule,  struct moduleItem *theModuleItem,  struct symbolHashNode *findName,  int *count,  int searchCurrent,  struct defmodule *notYetDefinedInModule)  {   struct defmodule *theModule;   struct portItem *theImportList, *theExportList;   void *rv, *arv = NULL;   int searchModule, exported;   struct defmodule *currentModule;   /*=========================================*/   /* Start the search in the current module. */   /* If the current module has already been  */   /* visited, then return.                   */   /*=========================================*/   currentModule = ((struct defmodule *) EnvGetCurrentModule(theEnv));   if (currentModule->visitedFlag) return(NULL);   /*=======================================================*/   /* The searchCurrent flag indicates whether the current  */   /* module should be included in the search. In addition, */   /* if matchModule is non-NULL, the current module will   */   /* only be searched if it is the specific module from    */   /* which we want the construct imported.                 */   /*=======================================================*/   if ((searchCurrent) &&       ((matchModule == NULL) || (currentModule == matchModule)))     {      /*===============================================*/      /* Look for the construct in the current module. */      /*===============================================*/      rv = (*theModuleItem->findFunction)(theEnv,ValueToString(findName));      /*========================================================*/      /* If we're in the process of defining the construct in   */      /* the module we're searching then go ahead and increment */      /* the count indicating the number of modules in which    */      /* the construct was found.                               */      /*========================================================*/      if (notYetDefinedInModule == currentModule)        {         (*count)++;         arv = rv;        }      /*=========================================================*/      /* Otherwise, if the construct is in the specified module, */      /* increment the count only if the construct actually      */      /* belongs to the module. [Some constructs, like the COOL  */      /* system classes, can be found in any module, but they    */      /* actually belong to the MAIN module.]                    */      /*=========================================================*/      else if (rv != NULL)        {         if (((struct constructHeader *) rv)->whichModule->theModule == currentModule)           { (*count)++; }         arv = rv;        }     }   /*=====================================*/   /* Mark the current module as visited. */   /*=====================================*/   currentModule->visitedFlag = TRUE;   /*===================================*/   /* Search through all of the modules */   /* imported by the current module.   */   /*===================================*/   theModule = ((struct defmodule *) EnvGetCurrentModule(theEnv));   theImportList = theModule->importList;   while (theImportList != NULL)     {      /*===================================================*/      /* Determine if the module should be searched (based */      /* upon whether the entire module, all constructs of */      /* a specific type, or specifically named constructs */      /* are imported).                                    */      /*===================================================*/      searchModule = FALSE;      if ((theImportList->constructType == NULL) ||          (theImportList->constructType == constructType))        {         if ((theImportList->constructName == NULL) ||             (theImportList->constructName == findName))           { searchModule = TRUE; }        }      /*=================================*/      /* Determine if the module exists. */      /*=================================*/      if (searchModule)        {         theModule = (struct defmodule *)                     EnvFindDefmodule(theEnv,ValueToString(theImportList->moduleName));         if (theModule == NULL) searchModule = FALSE;        }      /*=======================================================*/      /* Determine if the construct is exported by the module. */      /*=======================================================*/      if (searchModule)        {         exported = FALSE;         theExportList = theModule->exportList;         while ((theExportList != NULL) && (! exported))           {            if ((theExportList->constructType == NULL) ||                (theExportList->constructType == constructType))              {               if ((theExportList->constructName == NULL) ||                   (theExportList->constructName == findName))                 { exported = TRUE; }               }            theExportList = theExportList->next;           }         if (! exported) searchModule = FALSE;        }      /*=================================*/      /* Search in the specified module. */      /*=================================*/      if (searchModule)        {         EnvSetCurrentModule(theEnv,(void *) theModule);         if ((rv = SearchImportedConstructModules(theEnv,constructType,matchModule,                                                  theModuleItem,findName,                                                  count,TRUE,                                                  notYetDefinedInModule)) != NULL)           { arv = rv; }        }      /*====================================*/      /* Move on to the next imported item. */      /*====================================*/      theImportList = theImportList->next;     }   /*=========================*/   /* Return a pointer to the */   /* last construct found.   */   /*=========================*/   return(arv);  }/**************************************************************//* ConstructExported: Returns TRUE if the specified construct *//*   is exported from the specified module.                   *//**************************************************************/globle intBool ConstructExported(  void *theEnv,  char *constructTypeStr,  struct symbolHashNode *moduleName,  struct symbolHashNode *findName)  {   struct symbolHashNode *constructType;   struct defmodule *theModule;   struct portItem *theExportList;      constructType = FindSymbolHN(theEnv,constructTypeStr);   theModule = EnvFindDefmodule(theEnv,ValueToString(moduleName));      if ((constructType == NULL) || (theModule == NULL) || (findName == NULL))     { return(FALSE); }      theExportList = theModule->exportList;   while (theExportList != NULL)     {      if ((theExportList->constructType == NULL) ||          (theExportList->constructType == constructType))       {        if ((theExportList->constructName == NULL) ||            (theExportList->constructName == findName))          { return TRUE; }       }      theExportList = theExportList->next;     }   return FALSE;  }         /***************************************//* ListItemsDriver: Driver routine for *//*   listing items in a module.        *//***************************************/globle void ListItemsDriver(  void *theEnv,  char *logicalName,  struct defmodule *theModule,  char *singleName,  char *pluralName,  void *(*nextFunction)(void *,void *),  char *(*nameFunction)(void *),  void (*printFunction)(void *,char *,void *),  int (*doItFunction)(void *,void *))  {   void *constructPtr;   char *constructName;   long count = 0;   int allModules = FALSE;   int doIt;   /*==========================*/   /* Save the current module. */   /*==========================*/   SaveCurrentModule(theEnv);   /*======================*/   /* Print out the items. */   /*======================*/   if (theModule == NULL)     {      theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL);      allModules = TRUE;     }   while (theModule != NULL)     {      if (allModules)        {         EnvPrintRouter(theEnv,logicalName,EnvGetDefmoduleName(theEnv,theModule));         EnvPrintRouter(theEnv,logicalName,":\n");        }      EnvSetCurrentModule(theEnv,(void *) theModule);      constructPtr = (*nextFunction)(theEnv,NULL);      while (constructPtr != NULL)        {         if (EvaluationData(theEnv)->HaltExecution == TRUE) return;         if (doItFunction == NULL) doIt = TRUE;         else doIt = (*doItFunction)(theEnv,constructPtr);         if (! doIt) {}         else if (nameFunction != NULL)           {            constructName = (*nameFunction)(constructPtr);            if (constructName != NULL)              {               if (allModules) EnvPrintRouter(theEnv,logicalName,"   ");               EnvPrintRouter(theEnv,logicalName,constructName);               EnvPrintRouter(theEnv,logicalName,"\n");              }           }         else if (printFunction != NULL)           {            if (allModules) EnvPrintRouter(theEnv,logicalName,"   ");            (*printFunction)(theEnv,logicalName,constructPtr);            EnvPrintRouter(theEnv,logicalName,"\n");           }         constructPtr = (*nextFunction)(theEnv,constructPtr);         count++;        }      if (allModules) theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule);      else theModule = NULL;     }   /*=================================================*/   /* Print the tally and restore the current module. */   /*=================================================*/   if (singleName != NULL) PrintTally(theEnv,logicalName,count,singleName,pluralName);   RestoreCurrentModule(theEnv);  }/********************************************************//* DoForAllModules: Executes an action for all modules. *//********************************************************/globle long DoForAllModules(  void *theEnv,  void (*actionFunction)(struct defmodule *,void *),  int interruptable,  void *userBuffer)  {   void *theModule;   long moduleCount = 0L;   /*==========================*/   /* Save the current module. */   /*==========================*/   SaveCurrentModule(theEnv);   /*==================================*/   /* Loop through all of the modules. */   /*==================================*/   for (theModule = EnvGetNextDefmodule(theEnv,NULL);        theModule != NULL;        theModule = EnvGetNextDefmodule(theEnv,theModule), moduleCount++)     {      EnvSetCurrentModule(theEnv,(void *) theModule);      if ((interruptable) && GetHaltExecution(theEnv))        {         RestoreCurrentModule(theEnv);         return(-1L);        }      (*actionFunction)((struct defmodule *) theModule,userBuffer);     }   /*=============================*/   /* Restore the current module. */   /*=============================*/   RestoreCurrentModule(theEnv);   /*=========================================*/   /* Return the number of modules traversed. */   /*=========================================*/   return(moduleCount);  }

⌨️ 快捷键说明

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