?? objbin.c
字號:
snp->name->neededSymbol = TRUE; snp->putHandlerName->neededSymbol = TRUE; } } }/*************************************************** NAME : MarkDefclassItems DESCRIPTION : Marks needed items for a defclass INPUTS : 1) The defclass 2) User buffer (ignored) RETURNS : Nothing useful SIDE EFFECTS : Bsave indices set and needed ephemerals marked NOTES : None ***************************************************/#if IBM_TBC#pragma argsused#endifstatic void MarkDefclassItems( void *theEnv, struct constructHeader *theDefclass, void *buf) {#if MAC_MCW || IBM_MCW || MAC_XCD#pragma unused(buf)#endif DEFCLASS *cls = (DEFCLASS *) theDefclass; long i; EXPRESSION *tmpexp; MarkConstructHeaderNeededItems(&cls->header,ObjectBinaryData(theEnv)->ClassCount++); ObjectBinaryData(theEnv)->LinkCount += cls->directSuperclasses.classCount + cls->directSubclasses.classCount + cls->allSuperclasses.classCount;#if DEFMODULE_CONSTRUCT cls->scopeMap->neededBitMap = TRUE;#endif /* =================================================== Mark items needed by slot default value expressions =================================================== */ for (i = 0 ; i < cls->slotCount ; i++) { cls->slots[i].bsaveIndex = ObjectBinaryData(theEnv)->SlotCount++; cls->slots[i].overrideMessage->neededSymbol = TRUE; if (cls->slots[i].defaultValue != NULL) { if (cls->slots[i].dynamicDefault) { ExpressionData(theEnv)->ExpressionCount += ExpressionSize((EXPRESSION *) cls->slots[i].defaultValue); MarkNeededItems(theEnv,(EXPRESSION *) cls->slots[i].defaultValue); } else { /* ================================================= Static default values are stotred as data objects and must be converted into expressions ================================================= */ tmpexp = ConvertValueToExpression(theEnv,(DATA_OBJECT *) cls->slots[i].defaultValue); ExpressionData(theEnv)->ExpressionCount += ExpressionSize(tmpexp); MarkNeededItems(theEnv,tmpexp); ReturnExpression(theEnv,tmpexp); } } } /* ======================================== Count canonical slots needed by defclass ======================================== */ ObjectBinaryData(theEnv)->TemplateSlotCount += (long) cls->instanceSlotCount; if (cls->instanceSlotCount != 0) ObjectBinaryData(theEnv)->SlotNameMapCount += (long) cls->maxSlotNameID + 1; /* =============================================== Mark items needed by defmessage-handler actions =============================================== */ for (i = 0 ; i < cls->handlerCount ; i++) { cls->handlers[i].name->neededSymbol = TRUE; ExpressionData(theEnv)->ExpressionCount += ExpressionSize(cls->handlers[i].actions); MarkNeededItems(theEnv,cls->handlers[i].actions); } ObjectBinaryData(theEnv)->HandlerCount += (long) cls->handlerCount; }/*************************************************** NAME : BsaveObjectsExpressions DESCRIPTION : Writes out all expressions needed by classes and handlers INPUTS : The file pointer of the binary file RETURNS : Nothing useful SIDE EFFECTS : File updated NOTES : None ***************************************************/static void BsaveObjectsExpressions( void *theEnv, FILE *fp) { if ((ObjectBinaryData(theEnv)->ClassCount == 0L) && (ObjectBinaryData(theEnv)->HandlerCount == 0L)) return; /* ================================================ Save the defclass slot default value expressions ================================================ */ DoForAllConstructs(theEnv,BsaveDefaultSlotExpressions,DefclassData(theEnv)->DefclassModuleIndex, FALSE,(void *) fp); /* ============================================== Save the defmessage-handler action expressions ============================================== */ DoForAllConstructs(theEnv,BsaveHandlerActionExpressions,DefclassData(theEnv)->DefclassModuleIndex, FALSE,(void *) fp); }/*************************************************** NAME : BsaveDefaultSlotExpressions DESCRIPTION : Writes expressions for default slot values to binary file INPUTS : 1) The defclass 2) The binary file pointer RETURNS : Nothing useful SIDE EFFECTS : Slot value expressions written NOTES : None ***************************************************/static void BsaveDefaultSlotExpressions( void *theEnv, struct constructHeader *theDefclass, void *buf) { DEFCLASS *cls = (DEFCLASS *) theDefclass; long i; EXPRESSION *tmpexp; for (i = 0 ; i < cls->slotCount ; i++) { if (cls->slots[i].defaultValue != NULL) { if (cls->slots[i].dynamicDefault) BsaveExpression(theEnv,(EXPRESSION *) cls->slots[i].defaultValue,(FILE *) buf); else { /* ================================================= Static default values are stotred as data objects and must be converted into expressions ================================================= */ tmpexp = ConvertValueToExpression(theEnv,(DATA_OBJECT *) cls->slots[i].defaultValue); BsaveExpression(theEnv,tmpexp,(FILE *) buf); ReturnExpression(theEnv,tmpexp); } } } }/*************************************************** NAME : BsaveHandlerActionExpressions DESCRIPTION : Writes expressions for handler actions to binary file INPUTS : 1) The defclass 2) The binary file pointer RETURNS : Nothing useful SIDE EFFECTS : Handler actions expressions written NOTES : None ***************************************************/static void BsaveHandlerActionExpressions( void *theEnv, struct constructHeader *theDefclass, void *buf) { DEFCLASS *cls = (DEFCLASS *) theDefclass; long i; for (i = 0 ; i < cls->handlerCount ; i++) BsaveExpression(theEnv,cls->handlers[i].actions,(FILE *) buf); }/************************************************************************************* NAME : BsaveStorageObjects DESCRIPTION : Writes out number of each type of structure required for COOL Space required for counts (unsigned long) Number of class modules (long) Number of classes (long) Number of links to classes (long) Number of slots (long) Number of instance template slots (long) Number of handlers (long) Number of definstances (long) INPUTS : File pointer of binary file RETURNS : Nothing useful SIDE EFFECTS : Binary file adjusted NOTES : None *************************************************************************************/static void BsaveStorageObjects( void *theEnv, FILE *fp) { size_t space; long maxClassID; if ((ObjectBinaryData(theEnv)->ClassCount == 0L) && (ObjectBinaryData(theEnv)->HandlerCount == 0L)) { space = 0L; GenWrite((void *) &space,sizeof(size_t),fp); return; } space = sizeof(long) * 9; GenWrite((void *) &space,sizeof(long),fp); GenWrite((void *) &ObjectBinaryData(theEnv)->ModuleCount,sizeof(long),fp); GenWrite((void *) &ObjectBinaryData(theEnv)->ClassCount,sizeof(long),fp); GenWrite((void *) &ObjectBinaryData(theEnv)->LinkCount,sizeof(long),fp); GenWrite((void *) &ObjectBinaryData(theEnv)->SlotNameCount,sizeof(long),fp); GenWrite((void *) &ObjectBinaryData(theEnv)->SlotCount,sizeof(long),fp); GenWrite((void *) &ObjectBinaryData(theEnv)->TemplateSlotCount,sizeof(long),fp); GenWrite((void *) &ObjectBinaryData(theEnv)->SlotNameMapCount,sizeof(long),fp); GenWrite((void *) &ObjectBinaryData(theEnv)->HandlerCount,sizeof(long),fp); maxClassID = DefclassData(theEnv)->MaxClassID; GenWrite((void *) &maxClassID,sizeof(long),fp); }/************************************************************************************* NAME : BsaveObjects DESCRIPTION : Writes out classes and message-handlers in binary format Space required (unsigned long) Followed by the data structures in order INPUTS : File pointer of binary file RETURNS : Nothing useful SIDE EFFECTS : Binary file adjusted NOTES : None *************************************************************************************/static void BsaveObjects( void *theEnv, FILE *fp) { size_t space; struct defmodule *theModule; DEFCLASS_MODULE *theModuleItem; BSAVE_DEFCLASS_MODULE dummy_mitem; BSAVE_SLOT_NAME dummy_slot_name; SLOT_NAME *snp; register unsigned i; if ((ObjectBinaryData(theEnv)->ClassCount == 0L) && (ObjectBinaryData(theEnv)->HandlerCount == 0L)) { space = 0L; GenWrite((void *) &space,sizeof(size_t),fp); return; } space = (ObjectBinaryData(theEnv)->ModuleCount * sizeof(BSAVE_DEFCLASS_MODULE)) + (ObjectBinaryData(theEnv)->ClassCount * sizeof(BSAVE_DEFCLASS)) + (ObjectBinaryData(theEnv)->LinkCount * sizeof(long)) + (ObjectBinaryData(theEnv)->SlotCount * sizeof(BSAVE_SLOT_DESC)) + (ObjectBinaryData(theEnv)->SlotNameCount * sizeof(BSAVE_SLOT_NAME)) + (ObjectBinaryData(theEnv)->TemplateSlotCount * sizeof(long)) + (ObjectBinaryData(theEnv)->SlotNameMapCount * sizeof(unsigned)) + (ObjectBinaryData(theEnv)->HandlerCount * sizeof(BSAVE_HANDLER)) + (ObjectBinaryData(theEnv)->HandlerCount * sizeof(unsigned)); GenWrite((void *) &space,sizeof(size_t),fp); ObjectBinaryData(theEnv)->ClassCount = 0L; ObjectBinaryData(theEnv)->LinkCount = 0L; ObjectBinaryData(theEnv)->SlotCount = 0L; ObjectBinaryData(theEnv)->SlotNameCount = 0L; ObjectBinaryData(theEnv)->TemplateSlotCount = 0L; ObjectBinaryData(theEnv)->SlotNameMapCount = 0L; ObjectBinaryData(theEnv)->HandlerCount = 0L; /* ================================= Write out each defclass module ================================= */ theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL); while (theModule != NULL) { theModuleItem = (DEFCLASS_MODULE *) GetModuleItem(theEnv,theModule,FindModuleItem(theEnv,"defclass")->moduleIndex); AssignBsaveDefmdlItemHdrVals(&dummy_mitem.header,&theModuleItem->header); GenWrite((void *) &dummy_mitem,sizeof(BSAVE_DEFCLASS_MODULE),fp); theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,(void *) theModule); } /* ===================== Write out the classes ===================== */ DoForAllConstructs(theEnv,BsaveDefclass,DefclassData(theEnv)->DefclassModuleIndex,FALSE,(void *) fp); /* ========================= Write out the class links ========================= */ ObjectBinaryData(theEnv)->LinkCount = 0L; DoForAllConstructs(theEnv,BsaveClassLinks,DefclassData(theEnv)->DefclassModuleIndex,FALSE,(void *) fp); /* =============================== Write out the slot name entries =============================== */ for (i = 0 ; i < SLOT_NAME_TABLE_HASH_SIZE ; i++) for (snp = DefclassData(theEnv)->SlotNameTable[i] ; snp != NULL ; snp = snp->nxt) { if ((snp->id != ISA_ID) && (snp->id != NAME_ID)) { dummy_slot_name.id = snp->id; dummy_slot_name.hashTableIndex = snp->hashTableIndex; dummy_slot_name.name = (long) snp->name->bucket; dummy_slot_name.putHandlerName = (long) snp->putHandlerName->bucket; GenWrite((void *) &dummy_slot_name,sizeof(BSAVE_SLOT_NAME),fp); } } /* =================== Write out the slots =================== */ DoForAllConstructs(theEnv,BsaveSlots,DefclassData(theEnv)->DefclassModuleIndex,FALSE,(void *) fp); /* ===================================== Write out the template instance slots ===================================== */ DoForAllConstructs(theEnv,BsaveTemplateSlots,DefclassData(theEnv)->DefclassModuleIndex,FALSE,(void *) fp); /* ============================================= Write out the ordered instance slot name maps ============================================= */ DoForAllConstructs(theEnv,BsaveSlotMap,DefclassData(theEnv)->DefclassModuleIndex,FALSE,(void *) fp); /* ============================== Write out the message-handlers ============================== */ DoForAllConstructs(theEnv,BsaveHandlers,DefclassData(theEnv)->DefclassModuleIndex,FALSE,(void *) fp); /* ========================================== Write out the ordered message-handler maps ========================================== */ DoForAllConstructs(theEnv,BsaveHandlerMap,DefclassData(theEnv)->DefclassModuleIndex,FALSE,(void *) fp); RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->ModuleCount); RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->ClassCount); RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->LinkCount); RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->SlotCount); RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->SlotNameCount); RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->TemplateSlotCount); RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->SlotNameMapCount); RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->HandlerCount); }/*************************************************** NAME : BsaveDefclass DESCRIPTION : Writes defclass binary data INPUTS : 1) The defclass 2) The binary file pointer RETURNS : Nothing useful SIDE EFFECTS : Defclass binary data written NOTES : None ***************************************************/static void BsaveDefclass( void *theEnv, struct constructHeader *theDefclass, void *buf) { DEFCLASS *cls = (DEFCLASS *) theDefclass; BSAVE_DEFCLASS dummy_class; AssignBsaveConstructHeaderVals(&dummy_class.header,&cls->header); dummy_class.abstract = cls->abstract; dummy_class.reactive = cls->reactive; dummy_class.system = cls->system; dummy_class.id = cls->id; dummy_class.slotCount = cls->slotCount; dummy_class.instanceSlotCount = cls->instanceSlotCount; dummy_class.localInstanceSlotCount = cls->localInstanceSlotCount;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -