📄 objcmp.c
字号:
imageID,fileCount, *slotArrayVersion,headerFP, "SLOT_DESC",SlotPrefix(), *reopenSlotFile,slotCodeFile); if (*slotFile == NULL) return(CLIPS_FALSE); for (i = 0 ; i < theDefclass->slotCount ; i++) { sd = &theDefclass->slots[i]; if (i > 0) fprintf(*slotFile,",\n"); fprintf(*slotFile,"{ %u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,", sd->shared,sd->multiple, sd->composite,sd->noInherit, sd->noWrite,sd->initializeOnly, sd->dynamicDefault,sd->defaultSpecified, sd->noDefault,sd->reactive, sd->publicVisibility,sd->createReadAccessor, sd->createWriteAccessor,sd->overrideMessageSpecified); PrintClassReference(*slotFile,sd->cls,imageID,maxIndices); fprintf(*slotFile,","); PrintSlotNameReference(*slotFile,sd->slotName,imageID,maxIndices); fprintf(*slotFile,",\n "); PrintSymbolReference(*slotFile,sd->overrideMessage); if (sd->defaultValue != NULL) { fprintf(*slotFile,",(VOID *) "); if (sd->dynamicDefault) ExpressionToCode(*slotFile,(EXPRESSION *) sd->defaultValue); else { tmpexp = ConvertValueToExpression((DATA_OBJECT *) sd->defaultValue); ExpressionToCode(*slotFile,tmpexp); ReturnExpression(tmpexp); } } else fprintf(*slotFile,",NULL"); fprintf(*slotFile,","); PrintConstraintReference(*slotFile,sd->constraint,imageID,maxIndices); fprintf(*slotFile,",0,0L,"); if (sd->shared) { theLocationInfo.theLong = sd->sharedValue.desc->bsaveIndex; fprintf(*slotFile,"{ &%s%d_%u[%u],0,0,0,NULL } }", SlotPrefix(),imageID, theLocationInfo.theLocation.thePartition, theLocationInfo.theLocation.theOffset); } else fprintf(*slotFile,"{ NULL,0,0,0,NULL } }"); } *slotArrayCount += theDefclass->slotCount; *slotFile = CloseFileIfNeeded(*slotFile,slotArrayCount, slotArrayVersion,maxIndices, reopenSlotFile,slotCodeFile); return(CLIPS_TRUE); }/************************************************************* NAME : TemplateSlotsToCode DESCRIPTION : Prints out instance template - the entire instance slot template for a particular class is guaranteed to be in the same array partition INPUTS : 1) A buffer for the template 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 template partition # 10) A buffer holding the template 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 : CLIPS_TRUE if all OK, CLIPS_FALSE otherwise SIDE EFFECTS : Templates written NOTES : None *************************************************************/static BOOLEAN TemplateSlotsToCode(templateSlotFile,fileName,fileID,imageID, headerFP,fileCount,maxIndices,theDefclass, templateSlotArrayVersion,templateSlotArrayCount, reopenTemplateSlotFile,templateSlotCodeFile) FILE **templateSlotFile,*headerFP; char *fileName; int fileID,imageID,*fileCount,maxIndices; DEFCLASS *theDefclass; int *templateSlotArrayVersion,*templateSlotArrayCount,*reopenTemplateSlotFile; struct CodeGeneratorFile *templateSlotCodeFile; { register unsigned i; SLOT_DESC *sd; PACKED_LOCATION_INFO theLocationInfo; if (theDefclass->instanceSlotCount == 0) return(CLIPS_TRUE); *templateSlotFile = OpenFileIfNeeded(*templateSlotFile,fileName,fileID, imageID,fileCount, *templateSlotArrayVersion,headerFP, "SLOT_DESC *",TemplateSlotPrefix(), *reopenTemplateSlotFile,templateSlotCodeFile); if (*templateSlotFile == NULL) return(CLIPS_FALSE); for (i = 0 ; i < theDefclass->instanceSlotCount ; i++) { sd = theDefclass->instanceTemplate[i]; if (i > 0) fprintf(*templateSlotFile,","); theLocationInfo.theLong = sd->bsaveIndex; fprintf(*templateSlotFile,"&%s%d_%u[%u]", SlotPrefix(),imageID, theLocationInfo.theLocation.thePartition, theLocationInfo.theLocation.theOffset); } *templateSlotArrayCount += theDefclass->instanceSlotCount; *templateSlotFile = CloseFileIfNeeded(*templateSlotFile,templateSlotArrayCount, templateSlotArrayVersion,maxIndices, reopenTemplateSlotFile,templateSlotCodeFile); return(CLIPS_TRUE); }/************************************************************* NAME : OrderedSlotsToCode DESCRIPTION : Prints out slot name map - the entire slot name map for a particular class is guaranteed to be in the same array partition INPUTS : 1) A buffer for the slot map 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 slot map partition # 10) A buffer holding the slot map 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 : CLIPS_TRUE if all OK, CLIPS_FALSE otherwise SIDE EFFECTS : Slot maps written NOTES : None *************************************************************/static BOOLEAN OrderedSlotsToCode(orderedSlotFile,fileName,fileID,imageID, headerFP,fileCount,maxIndices,theDefclass, orderedSlotArrayVersion,orderedSlotArrayCount, reopenOrderedSlotFile,orderedSlotCodeFile) FILE **orderedSlotFile,*headerFP; char *fileName; int fileID,imageID,*fileCount,maxIndices; DEFCLASS *theDefclass; int *orderedSlotArrayVersion,*orderedSlotArrayCount,*reopenOrderedSlotFile; struct CodeGeneratorFile *orderedSlotCodeFile; { register unsigned i; if (theDefclass->instanceSlotCount == 0) return(CLIPS_TRUE); *orderedSlotFile = OpenFileIfNeeded(*orderedSlotFile,fileName,fileID, imageID,fileCount, *orderedSlotArrayVersion,headerFP, "unsigned",OrderedSlotPrefix(), *reopenOrderedSlotFile,orderedSlotCodeFile); if (*orderedSlotFile == NULL) return(CLIPS_FALSE); for (i = 0 ; i <= theDefclass->maxSlotNameID ; i++) { if (i > 0) fprintf(*orderedSlotFile,","); fprintf(*orderedSlotFile,"%u",theDefclass->slotNameMap[i]); } *orderedSlotArrayCount += theDefclass->maxSlotNameID + 1; *orderedSlotFile = CloseFileIfNeeded(*orderedSlotFile,orderedSlotArrayCount, orderedSlotArrayVersion,maxIndices, reopenOrderedSlotFile,orderedSlotCodeFile); return(CLIPS_TRUE); }/************************************************************* NAME : HandlersToCode DESCRIPTION : Prints out message-handlers - all message-handlers for a particular class are guaranteed to be in the same array partition INPUTS : 1) A buffer for the handler 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 handler partition # 10) A buffer holding the handler 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 : CLIPS_TRUE if all OK, CLIPS_FALSE otherwise SIDE EFFECTS : Handlers written NOTES : None *************************************************************/static BOOLEAN HandlersToCode(handlerFile,fileName,fileID,imageID, headerFP,fileCount,maxIndices,theDefclass, handlerArrayVersion,handlerArrayCount, reopenHandlerFile,handlerCodeFile) FILE **handlerFile,*headerFP; char *fileName; int fileID,imageID,*fileCount,maxIndices; DEFCLASS *theDefclass; int *handlerArrayVersion,*handlerArrayCount,*reopenHandlerFile; struct CodeGeneratorFile *handlerCodeFile; { register unsigned i; HANDLER *hnd; if (theDefclass->handlerCount == 0) return(CLIPS_TRUE); *handlerFile = OpenFileIfNeeded(*handlerFile,fileName,fileID, imageID,fileCount, *handlerArrayVersion,headerFP, "HANDLER",HandlerPrefix(),*reopenHandlerFile, handlerCodeFile); if (*handlerFile == NULL) return(CLIPS_FALSE); for (i = 0 ; i < theDefclass->handlerCount ; i++) { if (i > 0) fprintf(*handlerFile,",\n"); hnd = &theDefclass->handlers[i]; fprintf(*handlerFile,"{ %u,%u,0,0,0,",hnd->system,hnd->type); PrintSymbolReference(*handlerFile,hnd->name); fprintf(*handlerFile,","); PrintClassReference(*handlerFile,hnd->cls,imageID,maxIndices); fprintf(*handlerFile,",%d,%d,%d,",hnd->minParams,hnd->maxParams, hnd->localVarCount); ExpressionToCode(*handlerFile,hnd->actions); fprintf(*handlerFile,",NULL }"); } *handlerArrayCount += theDefclass->handlerCount; *handlerFile = CloseFileIfNeeded(*handlerFile,handlerArrayCount, handlerArrayVersion,maxIndices, reopenHandlerFile,handlerCodeFile); return(CLIPS_TRUE); }/**************************************************************** NAME : OrderedHandlersToCode DESCRIPTION : Prints out handler map - the entire handler map for a particular class is guaranteed to be in the same array partition INPUTS : 1) A buffer for the handler map 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 handler map partition # 10) A buffer holding the handler map 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 : CLIPS_TRUE if all OK, CLIPS_FALSE otherwise SIDE EFFECTS : Handler maps written NOTES : None ****************************************************************/static BOOLEAN OrderedHandlersToCode(orderedHandlerFile,fileName,fileID,imageID, headerFP,fileCount,maxIndices,theDefclass, orderedHandlerArrayVersion,orderedHandlerArrayCount, reopenOrderedHandlerFile,orderedHandlerCodeFile) FILE **orderedHandlerFile,*headerFP; char *fileName; int fileID,imageID,*fileCount,maxIndices; DEFCLASS *theDefclass; int *orderedHandlerArrayVersion,*orderedHandlerArrayCount,*reopenOrderedHandlerFile; struct CodeGeneratorFile *orderedHandlerCodeFile; { register unsigned i; if (theDefclass->handlerCount == 0) return(CLIPS_TRUE); *orderedHandlerFile = OpenFileIfNeeded(*orderedHandlerFile,fileName,fileID, imageID,fileCount, *orderedHandlerArrayVersion,headerFP, "unsigned",OrderedHandlerPrefix(), *reopenOrderedHandlerFile, orderedHandlerCodeFile); if (*orderedHandlerFile == NULL) return(CLIPS_FALSE); for (i = 0 ; i < theDefclass->handlerCount ; i++) { if (i > 0) fprintf(*orderedHandlerFile,","); fprintf(*orderedHandlerFile,"%u",theDefclass->handlerOrderMap[i]); } *orderedHandlerArrayCount += theDefclass->handlerCount; *orderedHandlerFile = CloseFileIfNeeded(*orderedHandlerFile,orderedHandlerArrayCount, orderedHandlerArrayVersion,maxIndices, reopenOrderedHandlerFile, orderedHandlerCodeFile); return(CLIPS_TRUE); }#endif/*************************************************** NAME : DESCRIPTION : INPUTS : RETURNS : SIDE EFFECTS : NOTES : ***************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -