?? conscomp.c
字號:
} currentPtr = ConstructCompilerData(theEnv)->ListOfCodeGeneratorItems; while ((currentPtr != NULL) ? (priority < currentPtr->priority) : FALSE) { lastPtr = currentPtr; currentPtr = currentPtr->next; } if (lastPtr == NULL) { newPtr->next = ConstructCompilerData(theEnv)->ListOfCodeGeneratorItems; ConstructCompilerData(theEnv)->ListOfCodeGeneratorItems = newPtr; } else { newPtr->next = currentPtr; lastPtr->next = newPtr; } /*=========================*/ /* Return a pointer to the */ /* code generator item. */ /*=========================*/ return(newPtr); }/************************************************************//* CloseFileIfNeeded: Determines if a C file to which data *//* structures have been written should be closed. The *//* file is closed either when all data structures of *//* that specific type are written to files or the maximum *//* number of array entries for a single file has been *//* exceeded. *//************************************************************/globle FILE *CloseFileIfNeeded( void *theEnv, FILE *theFile, int *theCount, int *arrayVersion, int maxIndices, int *canBeReopened, struct CodeGeneratorFile *codeFile) { /*==========================================*/ /* If the maximum number of entries for the */ /* file hasn't been exceeded, then... */ /*==========================================*/ if (*theCount < maxIndices) { /*====================================*/ /* If the file can be reopened later, */ /* close it. Otherwise, keep it open. */ /*====================================*/ if (canBeReopened != NULL) { *canBeReopened = TRUE; GenClose(theEnv,theFile); return(NULL); } return(theFile); } /*===========================================*/ /* Otherwise, the number of entries allowed */ /* in a file has been reached. Indicate that */ /* the file can't be reopened. */ /*===========================================*/ if (canBeReopened != NULL) { *canBeReopened = FALSE; } /*===============================================*/ /* If the file is closed, then we need to reopen */ /* it to print the final closing right brace. */ /*===============================================*/ if (theFile == NULL) { if ((canBeReopened == NULL) || (codeFile == NULL)) { SystemError(theEnv,"CONSCOMP",3); EnvExitRouter(theEnv,EXIT_FAILURE); } if (codeFile->filePrefix == NULL) { return(NULL); } theFile = NewCFile(theEnv,codeFile->filePrefix,codeFile->id,codeFile->version,TRUE); if (theFile == NULL) { SystemError(theEnv,"CONSCOMP",4); EnvExitRouter(theEnv,EXIT_FAILURE); } } /*================================*/ /* Print the final closing brace. */ /*================================*/ fprintf(theFile,"};\n"); GenClose(theEnv,theFile); /*============================================*/ /* Update index values for subsequent writing */ /* of data structures to files. */ /*============================================*/ *theCount = 0; (*arrayVersion)++; /*=========================*/ /* Return NULL to indicate */ /* the file is closed. */ /*=========================*/ return(NULL); }/**************************************************************//* OpenFileIfNeeded: Determines if a C file to which data *//* structures have been written should be closed. The *//* file is closed either when all data structures of *//* that specific type are written to files or the maximum *//* number of array entries for a single file has been *//* exceeded. *//******************************************************************/globle FILE *OpenFileIfNeeded( void *theEnv, FILE *theFile, char *fileName, int fileID, int imageID, int *fileCount, int arrayVersion, FILE *headerFP, char *structureName, char *structPrefix, int reopenOldFile, struct CodeGeneratorFile *codeFile) { char arrayName[80]; char *newName; int newID, newVersion; /*===========================================*/ /* If a file is being reopened, use the same */ /* version number, name, and ID as before. */ /*===========================================*/ if (reopenOldFile) { if (codeFile == NULL) { SystemError(theEnv,"CONSCOMP",5); EnvExitRouter(theEnv,EXIT_FAILURE); } newName = codeFile->filePrefix; newID = codeFile->id; newVersion = codeFile->version; } /*=====================================================*/ /* Otherwise, use the specified version number, name, */ /* and ID. If the appropriate argument is supplied, */ /* remember these values for later reopening the file. */ /*=====================================================*/ else { newName = fileName; newVersion = *fileCount; newID = fileID; if (codeFile != NULL) { codeFile->version = newVersion; codeFile->filePrefix = newName; codeFile->id = newID; } } /*=========================================*/ /* If the file is already open, return it. */ /*=========================================*/ if (theFile != NULL) { fprintf(theFile,",\n"); return(theFile); } /*================*/ /* Open the file. */ /*================*/ if ((theFile = NewCFile(theEnv,newName,newID,newVersion,reopenOldFile)) == NULL) { return(NULL); } /*=========================================*/ /* If this is the first time the file has */ /* been opened, write out the beginning of */ /* the array variable definition. */ /*=========================================*/ if (reopenOldFile == FALSE) { (*fileCount)++; gensprintf(arrayName,"%s%d_%d",structPrefix,imageID,arrayVersion); fprintf(theFile,"%s %s[] = {\n",structureName,arrayName); fprintf(headerFP,"extern %s %s[];\n",structureName,arrayName); } else { fprintf(theFile,",\n"); } /*==================*/ /* Return the file. */ /*==================*/ return(theFile); }/*************************************************//* MarkConstructBsaveIDs: Mark all occurences of *//* a specific construct with a unique ID. *//*************************************************/globle void MarkConstructBsaveIDs( void *theEnv, int constructModuleIndex) { long theCount = 0; DoForAllConstructs(theEnv,MarkConstruct,constructModuleIndex,FALSE,&theCount); }/*************************************************************//* MarkConstruct: Sets the bsaveID for a specific construct. *//* Used with the MarkConstructBsaveIDs function to mark all *//* occurences of a specific construct with a unique ID. *//*************************************************************/#if IBM_TBC#pragma argsused#endifstatic void MarkConstruct( void *theEnv, struct constructHeader *theConstruct, void *vTheBuffer) { long *count = (long *) vTheBuffer;#if MAC_MCW || IBM_MCW || MAC_XCD#pragma unused(theEnv)#endif theConstruct->bsaveID = (*count)++; }/***********************************************************//* ConstructHeaderToCode: Writes the C code representation *//* of a single construct header to the specified file. *//***********************************************************/globle void ConstructHeaderToCode( void *theEnv, FILE *theFile, struct constructHeader *theConstruct, int imageID, int maxIndices, int moduleCount, char *constructModulePrefix, char *constructPrefix) { /*================*/ /* Construct Name */ /*================*/ fprintf(theFile,"{"); PrintSymbolReference(theEnv,theFile,theConstruct->name); /*===================*/ /* Pretty Print Form */ /*===================*/ fprintf(theFile,",NULL,"); /*====================*/ /* Construct Module */ /*====================*/ fprintf(theFile,"MIHS &%s%d_%d[%d],", constructModulePrefix, imageID, (moduleCount / maxIndices) + 1, moduleCount % maxIndices); /*==========*/ /* Bsave ID */ /*==========*/ fprintf(theFile,"0,"); /*================*/ /* Next Construct */ /*================*/ if (theConstruct->next == NULL) { fprintf(theFile,"NULL}"); } else { fprintf(theFile,"CHS &%s%d_%ld[%ld]}", constructPrefix, imageID, (theConstruct->next->bsaveID / maxIndices) + 1, theConstruct->next->bsaveID % maxIndices); } }/***********************************************************//* ConstructModuleToCode: Writes the C code representation *//* of a single construct module to the specified file. *//***********************************************************/globle void ConstructModuleToCode( void *theEnv, FILE *theFile, struct defmodule *theModule, int imageID, int maxIndices, int constructIndex, char *constructPrefix) { struct defmoduleItemHeader *theModuleItem; /*======================*/ /* Associated Defmodule */ /*======================*/ fprintf(theFile,"{"); theModuleItem = (struct defmoduleItemHeader *) GetModuleItem(theEnv,theModule,constructIndex); PrintDefmoduleReference(theEnv,theFile,theModule); fprintf(theFile,","); /*=============================*/ /* First Construct Module Item */ /*=============================*/ if (theModuleItem->firstItem == NULL) fprintf(theFile,"NULL,"); else fprintf(theFile,"CHS &%s%d_%ld[%ld],", constructPrefix, imageID, (long) (theModuleItem->firstItem->bsaveID / maxIndices) + 1, (long) theModuleItem->firstItem->bsaveID % maxIndices); /*============================*/ /* Last Construct Module Item */ /*============================*/ if (theModuleItem->lastItem == NULL) fprintf(theFile,"NULL"); else fprintf(theFile,"CHS &%s%d_%ld[%ld]", constructPrefix, imageID, (long) (theModuleItem->lastItem->bsaveID / maxIndices) + 1, (long) theModuleItem->lastItem->bsaveID % maxIndices); fprintf(theFile,"}"); }#else /* CONSTRUCT_COMPILER && (! RUN_TIME) */ void ConstructsToCCommand(void *);/************************************//* ConstructsToCCommand: Definition *//* for rule compiler stub. *//************************************/void ConstructsToCCommand( void *theEnv) {#if MAC_MCW || IBM_MCW || MAC_XCD#pragma unused(theEnv)#endif }#endif /* CONSTRUCT_COMPILER && (! RUN_TIME) */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -