?? modulcmp.c
字號:
portItemPtr != NULL; portItemPtr = portItemPtr->next) { portItemCount++; } } /*=====================*/ /* Write the bsave id. */ /*=====================*/ fprintf(moduleFile,"0,%ld,",theConstruct->bsaveID); /*======================*/ /* Write the user data. */ /*======================*/ fprintf(moduleFile,"NULL,"); /*===========================*/ /* Write the next reference. */ /*===========================*/ if (theConstruct->next == NULL) { fprintf(moduleFile,"NULL}"); } else { fprintf(moduleFile,"&%s%d_%d[%d]}",ConstructPrefix(DefmoduleData(theEnv)->DefmoduleCodeItem),imageID, (int) (theConstruct->next->bsaveID / maxIndices) + 1, (int) theConstruct->next->bsaveID % maxIndices); } /*===================================================*/ /* Increment the number of defmodule data structures */ /* written and close the output file if necessary. */ /*===================================================*/ moduleCount++; moduleFile = CloseFileIfNeeded(theEnv,moduleFile,&moduleCount,&moduleArrayVersion, maxIndices,NULL,NULL); } /*=========================*/ /* Close the output files. */ /*=========================*/ moduleCount = maxIndices; CloseFileIfNeeded(theEnv,moduleFile,&moduleCount, &moduleArrayVersion,maxIndices,NULL,NULL); fprintf(itemsFile,"};\n"); GenClose(theEnv,itemsFile); /*=========================================*/ /* Write out the portItem data structures. */ /*=========================================*/ if (portItemCount == 0) return(TRUE); return(PortItemsToCode(theEnv,fileName,fileID,headerFP,imageID,maxIndices,&fileCount)); }/************************************************************//* PortItemsToCode: Writes the C code representation of all *//* portItem data structure nodes the specified file. *//************************************************************/static int PortItemsToCode( void *theEnv, char *fileName, int fileID, FILE *headerFP, int imageID, int maxIndices, int *fileCount) { struct defmodule *theDefmodule = NULL; struct portItem *thePortItem = NULL; int portItemCount = 0; int importChecked = FALSE; int exportChecked = FALSE; FILE *portItemsFile = NULL; int portItemArrayVersion = 1; /*=================================================================*/ /* Loop through each of the portItem data structures writing their */ /* C code representation to the file as they are traversed. */ /*=================================================================*/ for (thePortItem = GetNextPortItem(theEnv,&theDefmodule,&thePortItem,&importChecked,&exportChecked); thePortItem != NULL; thePortItem = GetNextPortItem(theEnv,&theDefmodule,&thePortItem,&importChecked,&exportChecked)) { /*===========================================*/ /* Open a new file to write to if necessary. */ /*===========================================*/ portItemsFile = OpenFileIfNeeded(theEnv,portItemsFile,fileName,fileID,imageID, fileCount,portItemArrayVersion,headerFP, "struct portItem",PortPrefix(), FALSE,NULL); if (portItemsFile == NULL) { portItemCount = maxIndices; CloseFileIfNeeded(theEnv,portItemsFile,&portItemCount, &portItemArrayVersion,maxIndices,NULL,NULL); return(FALSE); } /*================================================*/ /* Write the portItem data structure to the file. */ /*================================================*/ fprintf(portItemsFile,"{"); PrintSymbolReference(theEnv,portItemsFile,thePortItem->moduleName); fprintf(portItemsFile,","); PrintSymbolReference(theEnv,portItemsFile,thePortItem->constructType); fprintf(portItemsFile,","); PrintSymbolReference(theEnv,portItemsFile,thePortItem->constructName); fprintf(portItemsFile,","); if (thePortItem->next == NULL) { fprintf(portItemsFile,"NULL}"); } else { fprintf(portItemsFile,"&%s%d_%d[%d]}",PortPrefix(),imageID, ((portItemCount+1) / maxIndices) + 1, (portItemCount+1) % maxIndices); } /*==================================================*/ /* Increment the number of portItem data structures */ /* written and close the output file if necessary. */ /*==================================================*/ portItemCount++; CloseFileIfNeeded(theEnv,portItemsFile,&portItemCount,&portItemArrayVersion, maxIndices,NULL,NULL); } /*===================================================*/ /* Close the output file and return TRUE to indicate */ /* the data structures were successfully written. */ /*===================================================*/ portItemCount = maxIndices; CloseFileIfNeeded(theEnv,portItemsFile,&portItemCount, &portItemArrayVersion,maxIndices,NULL,NULL); return(TRUE); }/*********************************************************************//* GetNextPortItem: Given a pointer to a portItem data structure *//* and its defmodule, returns the "next" portItem data structure. *//* If passed a NULL value for both the defmodule and portItem *//* data structure, it returns the "first" portItem data structure. *//*********************************************************************/static struct portItem *GetNextPortItem( void *theEnv, struct defmodule **theDefmodule, struct portItem **thePortItem, int *importChecked, int *exportChecked) { /*====================================================*/ /* If the defmodule pointer is NULL, then the "first" */ /* portItem data structure should be returned. Start */ /* the search in the "first" defmodule. */ /*====================================================*/ if (*theDefmodule == NULL) { *theDefmodule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL); *thePortItem = NULL; *importChecked = FALSE; *exportChecked = FALSE; } /*==============================================*/ /* Loop through all of the defmodules until the */ /* "next" portItem data structure is found. */ /*==============================================*/ while (*theDefmodule != NULL) { /*==========================================*/ /* Check to see if there's another portItem */ /* in the import/export list that's being */ /* checked in the module being examined. */ /*==========================================*/ if (*thePortItem != NULL) *thePortItem = (*thePortItem)->next; if (*thePortItem != NULL) return(*thePortItem); /*==================================================*/ /* If we haven't checked the import list yet, begin */ /* checking it. If there aren't any items in the */ /* import list, then check the export list. */ /*==================================================*/ if (! (*importChecked)) { *thePortItem = (*theDefmodule)->importList; *importChecked = TRUE; if (*thePortItem == NULL) { *thePortItem = (*theDefmodule)->exportList; *exportChecked = TRUE; } } /*======================================*/ /* Otherwise, if we haven't checked the */ /* export list yet, begin checking it. */ /*======================================*/ else if (! (*exportChecked)) { *exportChecked = TRUE; *thePortItem = (*theDefmodule)->exportList; } /*==========================================*/ /* If the import or export list contained a */ /* portItem data structure, then return it. */ /*==========================================*/ if (*thePortItem != NULL) return(*thePortItem); /*==================================*/ /* Otherwise, check the next module */ /* for a portItem data structure. */ /*==================================*/ *theDefmodule = (struct defmodule *) EnvGetNextDefmodule(theEnv,*theDefmodule); *importChecked = FALSE; *exportChecked = FALSE; } /*=======================================================*/ /* All the portItem data structures have been traversed. */ /* Return NULL to indicate that none are left. */ /*=======================================================*/ return(NULL); }#endif /* CONSTRUCT_COMPILER && (! RUN_TIME) */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -