📄 objcmp.c
字号:
&slotNameArrayVersion,slotNameArrayCount,NULL,NULL); return(TRUE); }/****************************************************** NAME : CloseObjectFiles DESCRIPTION : Closes construct compiler files for defclass structures INPUTS : 1) An array containing all the pertinent file pointers 2) An array containing all the pertinent file reopen flags 3) An array containing all the pertinent file name/id/version info 4) The maximum number of indices allowed in an array RETURNS : Nothing useful SIDE EFFECTS : Files closed NOTES : None *****************************************************/static void CloseObjectFiles( void *theEnv, FILE *itemFiles[SAVE_ITEMS], int itemReopenFlags[SAVE_ITEMS], struct CodeGeneratorFile itemCodeFiles[SAVE_ITEMS], int maxIndices) { int count = maxIndices; int arrayVersion = 0; register int i; for (i = 0 ; i < SAVE_ITEMS ; i++) { count = maxIndices; itemFiles[i] = CloseFileIfNeeded(theEnv,itemFiles[i],&count,&arrayVersion, maxIndices,&itemReopenFlags[i], &itemCodeFiles[i]); } }/*************************************************** NAME : DefclassModuleToCode DESCRIPTION : Writes out the C values for a defclass module item INPUTS : 1) The output file 2) The module for the defclasses 3) The compile image id 4) The maximum number of elements in an array RETURNS : Nothing useful SIDE EFFECTS : Defclass module item written NOTES : None ***************************************************/static void DefclassModuleToCode( void *theEnv, FILE *theFile, struct defmodule *theModule, int imageID, int maxIndices) { fprintf(theFile,"{"); ConstructModuleToCode(theEnv,theFile,theModule,imageID,maxIndices, DefclassData(theEnv)->DefclassModuleIndex,ClassPrefix()); fprintf(theFile,"}"); }/**************************************************************** NAME : SingleDefclassToCode DESCRIPTION : Writes out a single defclass's data to the file INPUTS : 1) The output file 2) The compile image id 3) The maximum number of elements in an array 4) The defclass 5) The module index 6) The partition holding the defclass inheritance links 7) The relative index of the inheritance links in the partition 8) The partition holding the defclass slots 9) The relative index of the slots in the partition 10) The partition holding the defclass template slots 11) The relative index of the template slots in the partition 12) The partition holding the defclass ordered slot map 13) The relative index of the ordered slot map in the partition 14) The partition holding the defclass message-handlers 15) The relative index of the message-handlers in the partition 16) The partition holding the defclass ordered handler map 17) The relative index of the ordered handler map in the partition RETURNS : Nothing useful SIDE EFFECTS : Defclass data written NOTES : None ***************************************************************/static void SingleDefclassToCode( void *theEnv, FILE *theFile, int imageID, int maxIndices, DEFCLASS *theDefclass, int moduleCount, int classLinkArrayVersion, int classLinkArrayCount, int slotArrayVersion, int slotArrayCount, int templateSlotArrayVersion, int templateSlotArrayCount, int orderedSlotArrayVersion, int orderedSlotArrayCount, int handlerArrayVersion, int handlerArrayCount, int orderedHandlerArrayVersion, int orderedHandlerArrayCount) { /* ================== Defclass Header ================== */ fprintf(theFile,"{"); ConstructHeaderToCode(theEnv,theFile,&theDefclass->header,imageID,maxIndices,moduleCount, ModulePrefix(ObjectCompilerData(theEnv)->ObjectCodeItem),ClassPrefix()); /* ========================= Defclass specific data ========================= */ fprintf(theFile,",1,%u,%u,%u,0,0,%u,0,%u,\n ", theDefclass->system,theDefclass->abstract, theDefclass->reactive,(unsigned) theDefclass->id, theDefclass->hashTableIndex); if (theDefclass->directSuperclasses.classCount > 0) fprintf(theFile,"{ %u,&%s%d_%d[%d] },", (unsigned) theDefclass->directSuperclasses.classCount, ClassLinkPrefix(), imageID,classLinkArrayVersion,classLinkArrayCount); else fprintf(theFile,"{ 0,NULL },"); classLinkArrayCount += theDefclass->directSuperclasses.classCount; if (theDefclass->directSubclasses.classCount > 0) fprintf(theFile,"{ %u,&%s%d_%d[%d] },", (unsigned) theDefclass->directSubclasses.classCount, ClassLinkPrefix(), imageID,classLinkArrayVersion,classLinkArrayCount); else fprintf(theFile,"{ 0,NULL },"); classLinkArrayCount += theDefclass->directSubclasses.classCount; if (theDefclass->allSuperclasses.classCount > 0) fprintf(theFile,"{ %u,&%s%d_%d[%d] },", (unsigned) theDefclass->allSuperclasses.classCount, ClassLinkPrefix(), imageID,classLinkArrayVersion,classLinkArrayCount); else fprintf(theFile,"{ 0,NULL },\n "); if (theDefclass->slots != NULL) fprintf(theFile,"&%s%d_%d[%d],", SlotPrefix(),imageID, slotArrayVersion,slotArrayCount); else fprintf(theFile,"NULL,"); if (theDefclass->instanceTemplate != NULL) fprintf(theFile,"&%s%d_%d[%d],", TemplateSlotPrefix(),imageID, templateSlotArrayVersion,templateSlotArrayCount); else fprintf(theFile,"NULL,"); if (theDefclass->slotNameMap != NULL) fprintf(theFile,"&%s%d_%d[%d],", OrderedSlotPrefix(),imageID, orderedSlotArrayVersion,orderedSlotArrayCount); else fprintf(theFile,"NULL,"); fprintf(theFile,"%hd,%hd,%hd,%hd,NULL,NULL,\n ", theDefclass->slotCount,theDefclass->localInstanceSlotCount, theDefclass->instanceSlotCount,theDefclass->maxSlotNameID); if (theDefclass->handlers != NULL) fprintf(theFile,"&%s%d_%d[%d],", HandlerPrefix(),imageID, handlerArrayVersion,handlerArrayCount); else fprintf(theFile,"NULL,"); if (theDefclass->handlerOrderMap != NULL) fprintf(theFile,"&%s%d_%d[%d],", OrderedHandlerPrefix(),imageID, orderedHandlerArrayVersion,orderedHandlerArrayCount); else fprintf(theFile,"NULL,"); fprintf(theFile,"%hd,",theDefclass->handlerCount); PrintClassReference(theEnv,theFile,theDefclass->nxtHash,imageID,maxIndices); fprintf(theFile,","); PrintBitMapReference(theEnv,theFile,theDefclass->scopeMap); fprintf(theFile,",\"\"}"); }/*********************************************************** NAME : InheritanceLinksToCode DESCRIPTION : Prints out superclass/subclass inheritance links - all links for a particular class are guaranteed to be in the same array partition INPUTS : 1) A buffer for the inheritance links file 2) The base image name 3) The id for this type of data 4) The base image id 5) The general header file 6) A buffer for the version number of the file for this type of data 7) The maximum # of elements in any array 8) A pointer to the class 9) A buffer holding the links partition # 10) A buffer holding the links relative index in the partition 11) A buffer for a flag indicating if the buffer file can be reopened later 12) A pointer to the file info for this data if the last file needs to be reopened for termination RETURNS : TRUE if all OK, FALSE otherwise SIDE EFFECTS : Inheritance links written NOTES : None ***********************************************************/static intBool InheritanceLinksToCode( void *theEnv, FILE **classLinkFile, char *fileName, int fileID, int imageID, FILE *headerFP, int *fileCount, int maxIndices, DEFCLASS *theDefclass, int *classLinkArrayVersion, int *classLinkArrayCount, int *reopenClassLinkFile, struct CodeGeneratorFile *classLinkCodeFile) { long i; int inheritanceLinkCount, linkPrinted = FALSE; inheritanceLinkCount = theDefclass->directSuperclasses.classCount + theDefclass->directSubclasses.classCount + theDefclass->allSuperclasses.classCount; if (inheritanceLinkCount == 0) return(TRUE); *classLinkFile = OpenFileIfNeeded(theEnv,*classLinkFile,fileName,fileID, imageID,fileCount, *classLinkArrayVersion,headerFP, "DEFCLASS *",ClassLinkPrefix(), *reopenClassLinkFile,classLinkCodeFile); if (*classLinkFile == NULL) return(FALSE); for (i = 0 ; i < theDefclass->directSuperclasses.classCount ; i++) { if (linkPrinted) fprintf(*classLinkFile,","); PrintClassReference(theEnv,*classLinkFile, theDefclass->directSuperclasses.classArray[i], imageID,maxIndices); linkPrinted = TRUE; } for (i = 0 ; i < theDefclass->directSubclasses.classCount ; i++) { if (linkPrinted) fprintf(*classLinkFile,","); PrintClassReference(theEnv,*classLinkFile, theDefclass->directSubclasses.classArray[i], imageID,maxIndices); linkPrinted = TRUE; } for (i = 0 ; i < theDefclass->allSuperclasses.classCount ; i++) { if (linkPrinted) fprintf(*classLinkFile,","); PrintClassReference(theEnv,*classLinkFile, theDefclass->allSuperclasses.classArray[i], imageID,maxIndices); linkPrinted = TRUE; } *classLinkArrayCount += inheritanceLinkCount; *classLinkFile = CloseFileIfNeeded(theEnv,*classLinkFile,classLinkArrayCount, classLinkArrayVersion,maxIndices, reopenClassLinkFile,classLinkCodeFile); return(TRUE); }/*********************************************************** NAME : SlotsToCode DESCRIPTION : Prints out slots - all slots for a particular class are guaranteed to be in the same array partition INPUTS : 1) A buffer for the slots file 2) The base image name 3) The id for this type of data 4) The base image id 5) The general header file 6) A buffer for the version number of the file for this type of data 7) The maximum # of elements in any array 8) A pointer to the class 9) A buffer holding the slots partition # 10) A buffer holding the slots relative index in the partition 11) A buffer for a flag indicating if the buffer file can be reopened later 12) A pointer to the file info for this data if the last file needs to be reopened for termination RETURNS : TRUE if all OK, FALSE otherwise SIDE EFFECTS : Slots written NOTES : None ***********************************************************/static intBool SlotsToCode( void *theEnv, FILE **slotFile, char *fileName, int fileID, int imageID, FILE *headerFP, int *fileCount, int maxIndices, DEFCLASS *theDefclass, int *slotArrayVersion, int *slotArrayCount, int *reopenSlotFile, struct CodeGeneratorFile *slotCodeFile) { long i; SLOT_DESC *sd; EXPRESSION *tmpexp; PACKED_LOCATION_INFO theLocationInfo; if (theDefclass->slotCount == 0) return(TRUE); *slotFile = OpenFileIfNeeded(theEnv,*slotFile,fileName,fileID, imageID,fileCount, *slotArrayVersion,headerFP,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -