static void DeallocateDefglobalData( void *theEnv) { #if ! RUN_TIME struct defglobalModule *theModuleItem; void *theModule; #if BLOAD || BLOAD_AND_BSAVE if (Bloaded(theEnv)) return; #endif DoForAllConstructs(theEnv,DestroyDefglobalAction,DefglobalData(theEnv)->DefglobalModuleIndex,FALSE,NULL); for (theModule = EnvGetNextDefmodule(theEnv,NULL); theModule != NULL; theModule = EnvGetNextDefmodule(theEnv,theModule)) { theModuleItem = (struct defglobalModule *) GetModuleItem(theEnv,(struct defmodule *) theModule, DefglobalData(theEnv)->DefglobalModuleIndex); rtn_struct(theEnv,defglobalModule,theModuleItem); } #else DoForAllConstructs(theEnv,DestroyDefglobalAction,DefglobalData(theEnv)->DefglobalModuleIndex,FALSE,NULL); #endif }
/*************************************************** NAME : BsaveGenericsExpressions DESCRIPTION : Writes out all expressions needed by generic functions INPUTS : The file pointer of the binary file RETURNS : Nothing useful SIDE EFFECTS : File updated NOTES : None ***************************************************/ static void BsaveGenericsExpressions( FILE *fp) { /* ================================================================ Important to save all expressions for methods before any expressions for restrictions, since methods will be stored first ================================================================ */ DoForAllConstructs(BsaveMethodExpressions,DefgenericModuleIndex, FALSE,(void *) fp); DoForAllConstructs(BsaveRestrictionExpressions,DefgenericModuleIndex, FALSE,(void *) fp); }
static void DeallocateDeffactsData( void *theEnv) { #if ! RUN_TIME struct deffactsModule *theModuleItem; void *theModule; #if BLOAD || BLOAD_AND_BSAVE if (Bloaded(theEnv)) return; #endif DoForAllConstructs(theEnv,DestroyDeffactsAction,DeffactsData(theEnv)->DeffactsModuleIndex,FALSE,NULL); for (theModule = EnvGetNextDefmodule(theEnv,NULL); theModule != NULL; theModule = EnvGetNextDefmodule(theEnv,theModule)) { theModuleItem = (struct deffactsModule *) GetModuleItem(theEnv,(struct defmodule *) theModule, DeffactsData(theEnv)->DeffactsModuleIndex); rtn_struct(theEnv,deffactsModule,theModuleItem); } #else #if MAC_MCW || WIN_MCW || MAC_XCD #pragma unused(theEnv) #endif #endif }
/*************************************************** NAME : BsaveDeffunctionExpressions DESCRIPTION : Writes out all expressions needed by deffunctyions INPUTS : The file pointer of the binary file RETURNS : Nothing useful SIDE EFFECTS : File updated NOTES : None ***************************************************/ static void BsaveDeffunctionExpressions( void *theEnv, FILE *fp) { DoForAllConstructs(theEnv,BsaveDeffunctionExpression,DeffunctionData(theEnv)->DeffunctionModuleIndex, FALSE,(void *) fp); }
/*************************************************** NAME : BsaveDefinstancesExpressions DESCRIPTION : Writes out all expressions needed by deffunctyions INPUTS : The file pointer of the binary file RETURNS : Nothing useful SIDE EFFECTS : File updated NOTES : None ***************************************************/ static void BsaveDefinstancesExpressions( void *theEnv, FILE *fp) { DoForAllConstructs(theEnv,BsaveDefinstancesExpression,DefinstancesData(theEnv)->DefinstancesModuleIndex, FALSE,(void *) fp); }
/*************************************************** 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( FILE *fp) { if ((ClassCount == 0L) && (HandlerCount == 0L)) return; /* ================================================ Save the defclass slot default value expressions ================================================ */ DoForAllConstructs(BsaveDefaultSlotExpressions,DefclassModuleIndex, FALSE,(void *) fp); /* ============================================== Save the defmessage-handler action expressions ============================================== */ DoForAllConstructs(BsaveHandlerActionExpressions,DefclassModuleIndex, FALSE,(void *) fp); }
/*************************************************** NAME : ClearDefinstancesReady DESCRIPTION : Determines if it is safe to remove all definstances Assumes *all* constructs will be deleted INPUTS : None RETURNS : TRUE if all definstances can be deleted, FALSE otherwise SIDE EFFECTS : None NOTES : Used by (clear) and (bload) ***************************************************/ static intBool ClearDefinstancesReady( void *theEnv) { int flagBuffer = TRUE; DoForAllConstructs(theEnv,CheckDefinstancesBusy,DefinstancesData(theEnv)->DefinstancesModuleIndex, FALSE,(void *) &flagBuffer); return(flagBuffer); }
/*************************************************************************** NAME : BsaveDefinstancesFind DESCRIPTION : For all definstances, this routine marks all the needed symbols. Also, it also counts the number of expression structures needed. Also, counts total number of definstances. INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : ExpressionCount (a global from BSAVE.C) is incremented for every expression needed Symbols are marked in their structures NOTES : Also sets bsaveIndex for each definstances (assumes definstances will be bsaved in order of binary list) ***************************************************************************/ static void BsaveDefinstancesFind( void *theEnv) { SaveBloadCount(theEnv,DefinstancesBinaryData(theEnv)->ModuleCount); SaveBloadCount(theEnv,DefinstancesBinaryData(theEnv)->DefinstancesCount); DefinstancesBinaryData(theEnv)->DefinstancesCount = 0L; DefinstancesBinaryData(theEnv)->ModuleCount = DoForAllConstructs(theEnv,MarkDefinstancesItems,DefinstancesData(theEnv)->DefinstancesModuleIndex, FALSE,NULL); }
/*************************************************************************** NAME : BsaveDeffunctionFind DESCRIPTION : For all deffunctions, this routine marks all the needed symbols. Also, it also counts the number of expression structures needed. Also, counts total number of deffunctions. INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : ExpressionCount (a global from BSAVE.C) is incremented for every expression needed Symbols are marked in their structures NOTES : Also sets bsaveIndex for each deffunction (assumes deffunctions will be bsaved in order of binary list) ***************************************************************************/ static void BsaveDeffunctionFind( void *theEnv) { SaveBloadCount(theEnv,DeffunctionBinaryData(theEnv)->ModuleCount); SaveBloadCount(theEnv,DeffunctionBinaryData(theEnv)->DeffunctionCount); DeffunctionBinaryData(theEnv)->DeffunctionCount = 0L; DeffunctionBinaryData(theEnv)->ModuleCount = DoForAllConstructs(theEnv,MarkDeffunctionItems,DeffunctionData(theEnv)->DeffunctionModuleIndex, FALSE,NULL); }
/*************************************************************************** NAME : BsaveDeffunctionFind DESCRIPTION : For all deffunctions, this routine marks all the needed symbols. Also, it also counts the number of expression structures needed. Also, counts total number of deffunctions. INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : ExpressionCount (a global from BSAVE.C) is incremented for every expression needed Symbols are marked in their structures NOTES : Also sets bsaveIndex for each deffunction (assumes deffunctions will be bsaved in order of binary list) ***************************************************************************/ static void BsaveDeffunctionFind() { if (Bloaded()) { SaveBloadCount(ModuleCount); SaveBloadCount(DeffunctionCount); } DeffunctionCount = 0L; ModuleCount = DoForAllConstructs(MarkDeffunctionItems,DeffunctionModuleIndex, FALSE,NULL); }
static void DeallocateDefruleData( Environment *theEnv) { struct defruleModule *theModuleItem; Defmodule *theModule; Activation *theActivation, *tmpActivation; struct salienceGroup *theGroup, *tmpGroup; #if BLOAD || BLOAD_AND_BSAVE if (Bloaded(theEnv)) { return; } #endif DoForAllConstructs(theEnv,DestroyDefruleAction, DefruleData(theEnv)->DefruleModuleIndex,false,NULL); for (theModule = GetNextDefmodule(theEnv,NULL); theModule != NULL; theModule = GetNextDefmodule(theEnv,theModule)) { theModuleItem = (struct defruleModule *) GetModuleItem(theEnv,theModule, DefruleData(theEnv)->DefruleModuleIndex); theActivation = theModuleItem->agenda; while (theActivation != NULL) { tmpActivation = theActivation->next; rtn_struct(theEnv,activation,theActivation); theActivation = tmpActivation; } theGroup = theModuleItem->groupings; while (theGroup != NULL) { tmpGroup = theGroup->next; rtn_struct(theEnv,salienceGroup,theGroup); theGroup = tmpGroup; } #if ! RUN_TIME rtn_struct(theEnv,defruleModule,theModuleItem); #endif } rm(theEnv,DefruleData(theEnv)->AlphaMemoryTable,sizeof (ALPHA_MEMORY_HASH *) * ALPHA_MEMORY_HASH_SIZE); }
/*************************************************************************** NAME : BsaveObjectsFind DESCRIPTION : For all classes and their message-handlers, this routine marks all the needed symbols and system functions. Also, it also counts the number of expression structures needed. INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : ExpressionCount (a global from BSAVE.C) is incremented for every expression needed Symbols are marked in their structures NOTES : Also sets bsaveIndex for each class (assumes classes will be bsaved in order of binary list) ***************************************************************************/ static void BsaveObjectsFind() { register unsigned i; SLOT_NAME *snp; /* ======================================================== The counts need to be saved in case a bload is in effect ======================================================== */ if (Bloaded()) { SaveBloadCount(ModuleCount); SaveBloadCount(ClassCount); SaveBloadCount(LinkCount); SaveBloadCount(SlotNameCount); SaveBloadCount(SlotCount); SaveBloadCount(TemplateSlotCount); SaveBloadCount(SlotNameMapCount); SaveBloadCount(HandlerCount); } ModuleCount= 0L; ClassCount = 0L; SlotCount = 0L; SlotNameCount = 0L; LinkCount = 0L; TemplateSlotCount = 0L; SlotNameMapCount = 0L; HandlerCount = 0L; /* ============================================== Mark items needed by defclasses in all modules ============================================== */ ModuleCount = DoForAllConstructs(MarkDefclassItems,DefclassModuleIndex, FALSE,NULL); /* ============================================= Mark items needed by canonicalized slot names ============================================= */ for (i = 0 ; i < SLOT_NAME_TABLE_HASH_SIZE ; i++) for (snp = SlotNameTable[i] ; snp != NULL ; snp = snp->nxt) { if ((snp->id != ISA_ID) && (snp->id != NAME_ID)) { snp->bsaveIndex = SlotNameCount++; snp->name->neededSymbol = TRUE; snp->putHandlerName->neededSymbol = TRUE; } } }
/*************************************************************************** NAME : BsaveGenericsFind DESCRIPTION : For all generic functions and their methods, this routine marks all the needed symbols and system functions. Also, it also counts the number of expression structures needed. Also, counts total number of generics, methods, restrictions and types. INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : ExpressionCount (a global from BSAVE.C) is incremented for every expression needed Symbols and system function are marked in their structures NOTES : Also sets bsaveIndex for each generic function (assumes generic functions will be bsaved in order of binary list) ***************************************************************************/ static void BsaveGenericsFind() { if (Bloaded()) { SaveBloadCount(ModuleCount); SaveBloadCount(GenericCount); SaveBloadCount(MethodCount); SaveBloadCount(RestrictionCount); SaveBloadCount(TypeCount); } GenericCount = 0L; MethodCount = 0L; RestrictionCount = 0L; TypeCount = 0L; ModuleCount = DoForAllConstructs(MarkDefgenericItems,DefgenericModuleIndex, FALSE,NULL); }
/*************************************************************************** NAME : BsaveGenericsFind DESCRIPTION : For all generic functions and their methods, this routine marks all the needed symbols and system functions. Also, it also counts the number of expression structures needed. Also, counts total number of generics, methods, restrictions and types. INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : ExpressionCount (a global from BSAVE.C) is incremented for every expression needed Symbols and system function are marked in their structures NOTES : Also sets bsaveIndex for each generic function (assumes generic functions will be bsaved in order of binary list) ***************************************************************************/ static void BsaveGenericsFind( void *theEnv) { SaveBloadCount(theEnv,DefgenericBinaryData(theEnv)->ModuleCount); SaveBloadCount(theEnv,DefgenericBinaryData(theEnv)->GenericCount); SaveBloadCount(theEnv,DefgenericBinaryData(theEnv)->MethodCount); SaveBloadCount(theEnv,DefgenericBinaryData(theEnv)->RestrictionCount); SaveBloadCount(theEnv,DefgenericBinaryData(theEnv)->TypeCount); DefgenericBinaryData(theEnv)->GenericCount = 0L; DefgenericBinaryData(theEnv)->MethodCount = 0L; DefgenericBinaryData(theEnv)->RestrictionCount = 0L; DefgenericBinaryData(theEnv)->TypeCount = 0L; DefgenericBinaryData(theEnv)->ModuleCount = DoForAllConstructs(theEnv,MarkDefgenericItems,DefgenericData(theEnv)->DefgenericModuleIndex, FALSE,NULL); }
static void DeallocateDefruleData( void *theEnv) { struct defruleModule *theModuleItem; void *theModule; struct activation *theActivation, *tmpActivation; #if BLOAD || BLOAD_AND_BSAVE if (Bloaded(theEnv)) return; #endif DoForAllConstructs(theEnv,DestroyDefruleAction,DefruleData(theEnv)->DefruleModuleIndex,FALSE,NULL); for (theModule = EnvGetNextDefmodule(theEnv,NULL); theModule != NULL; theModule = EnvGetNextDefmodule(theEnv,theModule)) { theModuleItem = (struct defruleModule *) GetModuleItem(theEnv,(struct defmodule *) theModule, DefruleData(theEnv)->DefruleModuleIndex); theActivation = theModuleItem->agenda; while (theActivation != NULL) { tmpActivation = theActivation->next; #if CONFLICT_RESOLUTION_STRATEGIES if (theActivation->sortedBasis != NULL) { DestroyPartialMatch(theEnv,theActivation->sortedBasis); } #endif rtn_struct(theEnv,activation,theActivation); theActivation = tmpActivation; } #if ! RUN_TIME rtn_struct(theEnv,defruleModule,theModuleItem); #endif } }
/************************************************************************************* NAME : BsaveDeffunctions DESCRIPTION : Writes out deffunction in binary format Space required (unsigned long) All deffunctions (sizeof(DEFFUNCTION) * Number of deffunctions) INPUTS : File pointer of binary file RETURNS : Nothing useful SIDE EFFECTS : Binary file adjusted NOTES : None *************************************************************************************/ static void BsaveDeffunctions( FILE *fp) { unsigned long space; struct defmodule *theModule; DEFFUNCTION_MODULE *theModuleItem; BSAVE_DEFFUNCTION_MODULE dummy_mitem; space = (unsigned long) ((sizeof(BSAVE_DEFFUNCTION_MODULE) * ModuleCount) + (sizeof(BSAVE_DEFFUNCTION) * DeffunctionCount)); GenWrite((void *) &space,(unsigned long) sizeof(unsigned long),fp); /* ================================= Write out each deffunction module ================================= */ DeffunctionCount = 0L; theModule = (struct defmodule *) GetNextDefmodule(NULL); while (theModule != NULL) { theModuleItem = (DEFFUNCTION_MODULE *) GetModuleItem(theModule,FindModuleItem("deffunction")->moduleIndex); AssignBsaveDefmdlItemHdrVals(&dummy_mitem.header,&theModuleItem->header); GenWrite((void *) &dummy_mitem,(unsigned long) sizeof(BSAVE_DEFFUNCTION_MODULE),fp); theModule = (struct defmodule *) GetNextDefmodule((void *) theModule); } /* ========================== Write out each deffunction ========================== */ DoForAllConstructs(BsaveDeffunction,DeffunctionModuleIndex, FALSE,(void *) fp); if (Bloaded()) { RestoreBloadCount(&ModuleCount); RestoreBloadCount(&DeffunctionCount); } }
/************************************************************************************* NAME : BsaveDeffunctions DESCRIPTION : Writes out deffunction in binary format Space required (unsigned long) All deffunctions (sizeof(DEFFUNCTION) * Number of deffunctions) INPUTS : File pointer of binary file RETURNS : Nothing useful SIDE EFFECTS : Binary file adjusted NOTES : None *************************************************************************************/ static void BsaveDeffunctions( void *theEnv, FILE *fp) { size_t space; struct defmodule *theModule; DEFFUNCTION_MODULE *theModuleItem; BSAVE_DEFFUNCTION_MODULE dummy_mitem; space = ((sizeof(BSAVE_DEFFUNCTION_MODULE) * DeffunctionBinaryData(theEnv)->ModuleCount) + (sizeof(BSAVE_DEFFUNCTION) * DeffunctionBinaryData(theEnv)->DeffunctionCount)); GenWrite((void *) &space,sizeof(size_t),fp); /* ================================= Write out each deffunction module ================================= */ DeffunctionBinaryData(theEnv)->DeffunctionCount = 0L; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL); while (theModule != NULL) { theModuleItem = (DEFFUNCTION_MODULE *) GetModuleItem(theEnv,theModule,FindModuleItem(theEnv,"deffunction")->moduleIndex); AssignBsaveDefmdlItemHdrVals(&dummy_mitem.header,&theModuleItem->header); GenWrite((void *) &dummy_mitem,sizeof(BSAVE_DEFFUNCTION_MODULE),fp); theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,(void *) theModule); } /* ========================== Write out each deffunction ========================== */ DoForAllConstructs(theEnv,BsaveDeffunction,DeffunctionData(theEnv)->DeffunctionModuleIndex, FALSE,(void *) fp); RestoreBloadCount(theEnv,&DeffunctionBinaryData(theEnv)->ModuleCount); RestoreBloadCount(theEnv,&DeffunctionBinaryData(theEnv)->DeffunctionCount); }
/************************************************************************************* NAME : BsaveDefinstancesDriver DESCRIPTION : Writes out definstances in binary format Space required (unsigned long) All definstances (sizeof(DEFINSTANCES) * Number of definstances) INPUTS : File pointer of binary file RETURNS : Nothing useful SIDE EFFECTS : Binary file adjusted NOTES : None *************************************************************************************/ static void BsaveDefinstancesDriver( void *theEnv, FILE *fp) { unsigned long space; struct defmodule *theModule; DEFINSTANCES_MODULE *theModuleItem; BSAVE_DEFINSTANCES_MODULE dummy_mitem; space = (unsigned long) ((sizeof(BSAVE_DEFINSTANCES_MODULE) * DefinstancesBinaryData(theEnv)->ModuleCount) + (sizeof(BSAVE_DEFINSTANCES) * DefinstancesBinaryData(theEnv)->DefinstancesCount)); GenWrite((void *) &space,(unsigned long) sizeof(unsigned long),fp); /* ================================= Write out each definstances module ================================= */ DefinstancesBinaryData(theEnv)->DefinstancesCount = 0L; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL); while (theModule != NULL) { theModuleItem = (DEFINSTANCES_MODULE *) GetModuleItem(theEnv,theModule,FindModuleItem(theEnv,"definstances")->moduleIndex); AssignBsaveDefmdlItemHdrVals(&dummy_mitem.header,&theModuleItem->header); GenWrite((void *) &dummy_mitem,(unsigned long) sizeof(BSAVE_DEFINSTANCES_MODULE),fp); theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,(void *) theModule); } /* ========================== Write out each definstances ========================== */ DoForAllConstructs(theEnv,BsaveDefinstances,DefinstancesData(theEnv)->DefinstancesModuleIndex, FALSE,(void *) fp); RestoreBloadCount(theEnv,&DefinstancesBinaryData(theEnv)->ModuleCount); RestoreBloadCount(theEnv,&DefinstancesBinaryData(theEnv)->DefinstancesCount); }
globle void MarkConstructBsaveIDs( int constructModuleIndex) { long theCount = 0; DoForAllConstructs(MarkConstruct,constructModuleIndex,FALSE,&theCount); }
/**************************************************************************************** NAME : BsaveGenerics DESCRIPTION : Writes out generic function in binary format Space required (unsigned long) All generic modules (sizeof(DEFGENERIC_MODULE) * Number of generic modules) All generic headers (sizeof(DEFGENERIC) * Number of generics) All methods (sizeof(DEFMETHOD) * Number of methods) All method restrictions (sizeof(RESTRICTION) * Number of restrictions) All restriction type arrays (sizeof(void *) * # of types) INPUTS : File pointer of binary file RETURNS : Nothing useful SIDE EFFECTS : Binary file adjusted NOTES : None ****************************************************************************************/ static void BsaveGenerics( void *theEnv, FILE *fp) { struct defmodule *theModule; DEFGENERIC_MODULE *theModuleItem; size_t space; BSAVE_DEFGENERIC_MODULE dummy_generic_module; /* ===================================================================== Space is: Sum over all structures(sizeof(structure) * structure-cnt)) ===================================================================== */ space = ((unsigned long) DefgenericBinaryData(theEnv)->ModuleCount * sizeof(BSAVE_DEFGENERIC_MODULE)) + ((unsigned long) DefgenericBinaryData(theEnv)->GenericCount * sizeof(BSAVE_GENERIC)) + ((unsigned long) DefgenericBinaryData(theEnv)->MethodCount * sizeof(BSAVE_METHOD)) + ((unsigned long) DefgenericBinaryData(theEnv)->RestrictionCount * sizeof(BSAVE_RESTRICTION)) + ((unsigned long) DefgenericBinaryData(theEnv)->TypeCount * sizeof(unsigned long)); /* ================================================================ Write out the total amount of space required: modules,headers, methods, restrictions, types ================================================================ */ GenWrite((void *) &space,sizeof(size_t),fp); /* ====================================== Write out the generic function modules ====================================== */ DefgenericBinaryData(theEnv)->GenericCount = 0L; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL); while (theModule != NULL) { theModuleItem = (DEFGENERIC_MODULE *) GetModuleItem(theEnv,theModule,FindModuleItem(theEnv,"defgeneric")->moduleIndex); AssignBsaveDefmdlItemHdrVals(&dummy_generic_module.header, &theModuleItem->header); GenWrite((void *) &dummy_generic_module, sizeof(BSAVE_DEFGENERIC_MODULE),fp); theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,(void *) theModule); } /* ====================================== Write out the generic function headers ====================================== */ DefgenericBinaryData(theEnv)->MethodCount = 0L; DoForAllConstructs(theEnv,BsaveDefgenericHeader,DefgenericData(theEnv)->DefgenericModuleIndex, false,(void *) fp); /* ===================== Write out the methods ===================== */ DefgenericBinaryData(theEnv)->RestrictionCount = 0L; DoForAllConstructs(theEnv,BsaveMethods,DefgenericData(theEnv)->DefgenericModuleIndex, false,(void *) fp); /* ================================= Write out the method restrictions ================================= */ DefgenericBinaryData(theEnv)->TypeCount = 0L; DoForAllConstructs(theEnv,BsaveMethodRestrictions,DefgenericData(theEnv)->DefgenericModuleIndex, false,(void *) fp); /* ============================================================= Finally, write out the type lists for the method restrictions ============================================================= */ DoForAllConstructs(theEnv,BsaveRestrictionTypes,DefgenericData(theEnv)->DefgenericModuleIndex, false,(void *) fp); RestoreBloadCount(theEnv,&DefgenericBinaryData(theEnv)->ModuleCount); RestoreBloadCount(theEnv,&DefgenericBinaryData(theEnv)->GenericCount); RestoreBloadCount(theEnv,&DefgenericBinaryData(theEnv)->MethodCount); RestoreBloadCount(theEnv,&DefgenericBinaryData(theEnv)->RestrictionCount); RestoreBloadCount(theEnv,&DefgenericBinaryData(theEnv)->TypeCount); }
/*************************************************** NAME : ResetDefinstances DESCRIPTION : Calls EvaluateExpression for each of the make-instance calls in all of the definstances constructs INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : All instances in the definstances are evaluated (and created if there are no errors) Any previously existing instances are deleted first. NOTES : None ***************************************************/ static void ResetDefinstances( void *theEnv) { DoForAllConstructs(theEnv,ResetDefinstancesAction,DefinstancesData(theEnv)->DefinstancesModuleIndex,TRUE,NULL); }
/*************************************************** NAME : BsaveDeffunctionExpressions DESCRIPTION : Writes out all expressions needed by deffunctyions INPUTS : The file pointer of the binary file RETURNS : Nothing useful SIDE EFFECTS : File updated NOTES : None ***************************************************/ static void BsaveDeffunctionExpressions( FILE *fp) { DoForAllConstructs(BsaveDeffunctionExpression,DeffunctionModuleIndex, FALSE,(void *) fp); }
void DefglobalRunTimeInitialize( Environment *theEnv) { DoForAllConstructs(theEnv,RuntimeDefglobalAction,DefglobalData(theEnv)->DefglobalModuleIndex,true,NULL); }
/************************************************************************************* 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( FILE *fp) { UNLN 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 ((ClassCount == 0L) && (HandlerCount == 0L)) { space = 0L; GenWrite((void *) &space,(UNLN) sizeof(UNLN),fp); return; } space = (ModuleCount * (UNLN) sizeof(BSAVE_DEFCLASS_MODULE)) + (ClassCount * (UNLN) sizeof(BSAVE_DEFCLASS)) + (LinkCount * (UNLN) sizeof(long)) + (SlotCount * (UNLN) sizeof(BSAVE_SLOT_DESC)) + (SlotNameCount * (UNLN) sizeof(BSAVE_SLOT_NAME)) + (TemplateSlotCount * (UNLN) sizeof(long)) + (SlotNameMapCount * (UNLN) sizeof(unsigned)) + (HandlerCount * (UNLN) sizeof(BSAVE_HANDLER)) + (HandlerCount * (UNLN) sizeof(unsigned)); GenWrite((void *) &space,(UNLN) sizeof(UNLN),fp); ClassCount = 0L; LinkCount = 0L; SlotCount = 0L; SlotNameCount = 0L; TemplateSlotCount = 0L; SlotNameMapCount = 0L; HandlerCount = 0L; /* ================================= Write out each defclass module ================================= */ theModule = (struct defmodule *) GetNextDefmodule(NULL); while (theModule != NULL) { theModuleItem = (DEFCLASS_MODULE *) GetModuleItem(theModule,FindModuleItem("defclass")->moduleIndex); AssignBsaveDefmdlItemHdrVals(&dummy_mitem.header,&theModuleItem->header); GenWrite((void *) &dummy_mitem,(unsigned long) sizeof(BSAVE_DEFCLASS_MODULE),fp); theModule = (struct defmodule *) GetNextDefmodule((void *) theModule); } /* ===================== Write out the classes ===================== */ DoForAllConstructs(BsaveDefclass,DefclassModuleIndex,FALSE,(void *) fp); /* ========================= Write out the class links ========================= */ LinkCount = 0L; DoForAllConstructs(BsaveClassLinks,DefclassModuleIndex,FALSE,(void *) fp); /* =============================== Write out the slot name entries =============================== */ for (i = 0 ; i < SLOT_NAME_TABLE_HASH_SIZE ; i++) for (snp = 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,(UNLN) sizeof(BSAVE_SLOT_NAME),fp); } } /* =================== Write out the slots =================== */ DoForAllConstructs(BsaveSlots,DefclassModuleIndex,FALSE,(void *) fp); /* ===================================== Write out the template instance slots ===================================== */ DoForAllConstructs(BsaveTemplateSlots,DefclassModuleIndex,FALSE,(void *) fp); /* ============================================= Write out the ordered instance slot name maps ============================================= */ DoForAllConstructs(BsaveSlotMap,DefclassModuleIndex,FALSE,(void *) fp); /* ============================== Write out the message-handlers ============================== */ DoForAllConstructs(BsaveHandlers,DefclassModuleIndex,FALSE,(void *) fp); /* ========================================== Write out the ordered message-handler maps ========================================== */ DoForAllConstructs(BsaveHandlerMap,DefclassModuleIndex,FALSE,(void *) fp); if (Bloaded()) { RestoreBloadCount(&ModuleCount); RestoreBloadCount(&ClassCount); RestoreBloadCount(&LinkCount); RestoreBloadCount(&SlotCount); RestoreBloadCount(&SlotNameCount); RestoreBloadCount(&TemplateSlotCount); RestoreBloadCount(&SlotNameMapCount); RestoreBloadCount(&HandlerCount); } }
globle void ResetDefglobals() { if (! GetResetGlobals()) return; DoForAllConstructs(ResetDefglobalAction,DefglobalModuleIndex,TRUE,NULL); }
static void DeallocateDefclassData( void *theEnv) { #if ! RUN_TIME SLOT_NAME *tmpSNPPtr, *nextSNPPtr; int i; struct defclassModule *theModuleItem; void *theModule; int bloaded = FALSE; #if BLOAD || BLOAD_AND_BSAVE if (Bloaded(theEnv)) bloaded = TRUE; #endif /*=============================*/ /* Destroy all the defclasses. */ /*=============================*/ if (! bloaded) { DoForAllConstructs(theEnv,DestroyDefclassAction,DefclassData(theEnv)->DefclassModuleIndex,FALSE,NULL); for (theModule = EnvGetNextDefmodule(theEnv,NULL); theModule != NULL; theModule = EnvGetNextDefmodule(theEnv,theModule)) { theModuleItem = (struct defclassModule *) GetModuleItem(theEnv,(struct defmodule *) theModule, DefclassData(theEnv)->DefclassModuleIndex); rtn_struct(theEnv,defclassModule,theModuleItem); } } /*==========================*/ /* Remove the class tables. */ /*==========================*/ if (! bloaded) { if (DefclassData(theEnv)->ClassIDMap != NULL) { genfree(theEnv,DefclassData(theEnv)->ClassIDMap,DefclassData(theEnv)->AvailClassID * sizeof(DEFCLASS *)); } } if (DefclassData(theEnv)->ClassTable != NULL) { genfree(theEnv,DefclassData(theEnv)->ClassTable,sizeof(DEFCLASS *) * CLASS_TABLE_HASH_SIZE); } /*==============================*/ /* Free up the slot name table. */ /*==============================*/ if (! bloaded) { for (i = 0; i < SLOT_NAME_TABLE_HASH_SIZE; i++) { tmpSNPPtr = DefclassData(theEnv)->SlotNameTable[i]; while (tmpSNPPtr != NULL) { nextSNPPtr = tmpSNPPtr->nxt; rtn_struct(theEnv,slotName,tmpSNPPtr); tmpSNPPtr = nextSNPPtr; } } } if (DefclassData(theEnv)->SlotNameTable != NULL) { genfree(theEnv,DefclassData(theEnv)->SlotNameTable,sizeof(SLOT_NAME *) * SLOT_NAME_TABLE_HASH_SIZE); } #else DEFCLASS *cls; void *tmpexp; register unsigned int i; register int j; if (DefclassData(theEnv)->ClassTable != NULL) { for (j = 0 ; j < CLASS_TABLE_HASH_SIZE ; j++) for (cls = DefclassData(theEnv)->ClassTable[j] ; cls != NULL ; cls = cls->nxtHash) { for (i = 0 ; i < cls->slotCount ; i++) { if ((cls->slots[i].defaultValue != NULL) && (cls->slots[i].dynamicDefault == 0)) { tmpexp = ((DATA_OBJECT *) cls->slots[i].defaultValue)->supplementalInfo; rtn_struct(theEnv,dataObject,cls->slots[i].defaultValue); cls->slots[i].defaultValue = tmpexp; } } } } #endif }
globle void DeftemplateRunTimeInitialize( void *theEnv) { DoForAllConstructs(theEnv,RuntimeDeftemplateAction,DeftemplateData(theEnv)->DeftemplateModuleIndex,TRUE,NULL); }
globle void ResetDefglobals( void *theEnv) { if (! EnvGetResetGlobals(theEnv)) return; DoForAllConstructs(theEnv,ResetDefglobalAction,DefglobalData(theEnv)->DefglobalModuleIndex,TRUE,NULL); }
/**************************************************************************************** NAME : BsaveGenerics DESCRIPTION : Writes out generic function in binary format Space required (unsigned long) All generic modules (sizeof(DEFGENERIC_MODULE) * Number of generic modules) All generic headers (sizeof(DEFGENERIC) * Number of generics) All methods (sizeof(DEFMETHOD) * Number of methods) All method restrictions (sizeof(RESTRICTION) * Number of restrictions) All restriction type arrays (sizeof(void *) * # of types) INPUTS : File pointer of binary file RETURNS : Nothing useful SIDE EFFECTS : Binary file adjusted NOTES : None ****************************************************************************************/ static void BsaveGenerics( FILE *fp) { struct defmodule *theModule; DEFGENERIC_MODULE *theModuleItem; unsigned long space; BSAVE_DEFGENERIC_MODULE dummy_generic_module; /* ===================================================================== Space is: Sum over all structures(sizeof(structure) * structure-cnt)) ===================================================================== */ space = ((unsigned long) ModuleCount * (unsigned long) sizeof(BSAVE_DEFGENERIC_MODULE)) + ((unsigned long) GenericCount * (unsigned long) sizeof(BSAVE_GENERIC)) + ((unsigned long) MethodCount * (unsigned long) sizeof(BSAVE_METHOD)) + ((unsigned long) RestrictionCount * (unsigned long) sizeof(BSAVE_RESTRICTION)) + ((unsigned long) TypeCount * (unsigned long) sizeof(unsigned long)); /* ================================================================ Write out the total amount of space required: modules,headers, methods, restrictions, types ================================================================ */ GenWrite((void *) &space,(unsigned long) sizeof(unsigned long),fp); /* ====================================== Write out the generic function modules ====================================== */ GenericCount = 0L; theModule = (struct defmodule *) GetNextDefmodule(NULL); while (theModule != NULL) { theModuleItem = (DEFGENERIC_MODULE *) GetModuleItem(theModule,FindModuleItem("defgeneric")->moduleIndex); AssignBsaveDefmdlItemHdrVals(&dummy_generic_module.header, &theModuleItem->header); GenWrite((void *) &dummy_generic_module, (unsigned long) sizeof(BSAVE_DEFGENERIC_MODULE),fp); theModule = (struct defmodule *) GetNextDefmodule((void *) theModule); } /* ====================================== Write out the generic function headers ====================================== */ MethodCount = 0L; DoForAllConstructs(BsaveDefgenericHeader,DefgenericModuleIndex, FALSE,(void *) fp); /* ===================== Write out the methods ===================== */ RestrictionCount = 0L; DoForAllConstructs(BsaveMethods,DefgenericModuleIndex, FALSE,(void *) fp); /* ================================= Write out the method restrictions ================================= */ TypeCount = 0L; DoForAllConstructs(BsaveMethodRestrictions,DefgenericModuleIndex, FALSE,(void *) fp); /* ============================================================= Finally, write out the type lists for the method restrictions ============================================================= */ DoForAllConstructs(BsaveRestrictionTypes,DefgenericModuleIndex, FALSE,(void *) fp); if (Bloaded()) { RestoreBloadCount(&ModuleCount); RestoreBloadCount(&GenericCount); RestoreBloadCount(&MethodCount); RestoreBloadCount(&RestrictionCount); RestoreBloadCount(&TypeCount); } }
globle void ValidateBetaMemories( void *theEnv) { EnvPrintRouter(theEnv, WCLIPS, "ValidateBetaMemories"); DoForAllConstructs(theEnv,ValidateRuleBetaMemoriesAction,DefruleData(theEnv)->DefruleModuleIndex,FALSE,NULL); }