📄 globlbin.c
字号:
theModuleItem = (struct defglobalModule *) GetModuleItem(NULL,FindModuleItem("defglobal")->moduleIndex); AssignBsaveDefmdlItemHdrVals(&tempDefglobalModule.header, &theModuleItem->header); GenWrite(&tempDefglobalModule,(unsigned long) sizeof(struct bsaveDefglobalModule),fp); } /*===========================*/ /* Write out each defglobal. */ /*===========================*/ NumberOfDefglobals = 0; for (theModule = (struct defmodule *) GetNextDefmodule(NULL); theModule != NULL; theModule = (struct defmodule *) GetNextDefmodule(theModule)) { SetCurrentModule((VOID *) theModule); for (theDefglobal = (struct defglobal *) GetNextDefglobal(NULL); theDefglobal != NULL; theDefglobal = (struct defglobal *) GetNextDefglobal(theDefglobal)) { AssignBsaveConstructHeaderVals(&newDefglobal.header, &theDefglobal->header); newDefglobal.initial = HashedExpressionIndex(theDefglobal->initial); GenWrite(&newDefglobal,(unsigned long) sizeof(struct bsaveDefglobal),fp); } } /*=============================================================*/ /* If a binary image was already loaded when the bsave command */ /* was issued, then restore the counts indicating the number */ /* of defglobals and defglobal modules in the binary image */ /* (these were overwritten by the binary save). */ /*=============================================================*/ if (Bloaded()) { RestoreBloadCount(&NumberOfDefglobalModules); RestoreBloadCount(&NumberOfDefglobals); } } #endif /* BLOAD_AND_BSAVE *//***********************************************//* BloadStorageDefglobals: Allocates space for *//* the defglobals used by this binary image. *//***********************************************/static VOID BloadStorageDefglobals() { unsigned long int space; /*=======================================================*/ /* Determine the number of defglobal and defglobalModule */ /* data structures to be read. */ /*=======================================================*/ GenRead(&space,(unsigned long) sizeof(unsigned long int)); GenRead(&NumberOfDefglobals,(unsigned long) sizeof(long int)); GenRead(&NumberOfDefglobalModules,(unsigned long) sizeof(long int)); /*===================================*/ /* Allocate the space needed for the */ /* defglobalModule data structures. */ /*===================================*/ if (NumberOfDefglobalModules == 0) { DefglobalArray = NULL; ModuleArray = NULL; } space = NumberOfDefglobalModules * sizeof(struct defglobalModule); ModuleArray = (struct defglobalModule HUGE_ADDR *) genlongalloc(space); /*===================================*/ /* Allocate the space needed for the */ /* defglobal data structures. */ /*===================================*/ if (NumberOfDefglobals == 0) { DefglobalArray = NULL; return; } space = (unsigned long) (NumberOfDefglobals * sizeof(struct defglobal)); DefglobalArray = (struct defglobal HUGE_ADDR *) genlongalloc(space); }/******************************************************//* BloadBinaryItem: Loads and refreshes the defglobal *//* constructs used by this binary image. *//******************************************************/static VOID BloadBinaryItem() { unsigned long int space; /*======================================================*/ /* Read in the amount of space used by the binary image */ /* (this is used to skip the construct in the event it */ /* is not available in the version of CLIPS being run). */ /*======================================================*/ GenRead(&space,(unsigned long) sizeof(unsigned long int)); /*=============================================*/ /* Read in the defglobalModule data structures */ /* and refresh the pointers. */ /*=============================================*/ BloadandRefresh(NumberOfDefglobalModules, (unsigned) sizeof(struct bsaveDefglobalModule), UpdateDefglobalModule); /*=======================================*/ /* Read in the defglobal data structures */ /* and refresh the pointers. */ /*=======================================*/ BloadandRefresh(NumberOfDefglobals, (unsigned) sizeof(struct bsaveDefglobal), UpdateDefglobal); } /************************************************//* UpdateDefglobalModule: Bload refresh routine *//* for defglobal module data structures. *//************************************************/static VOID UpdateDefglobalModule(buf,obji) VOID *buf; long obji; { struct bsaveDefglobalModule *bdmPtr; bdmPtr = (struct bsaveDefglobalModule *) buf; UpdateDefmoduleItemHeader(&bdmPtr->header,&ModuleArray[obji].header, (int) sizeof(struct defglobal), (VOID *) DefglobalArray); } /******************************************//* UpdateDefglobal: Bload refresh routine *//* for defglobal data structures. *//******************************************/static VOID UpdateDefglobal(buf,obji) VOID *buf; long obji; { struct bsaveDefglobal *bdp; bdp = (struct bsaveDefglobal *) buf; UpdateConstructHeader(&bdp->header,&DefglobalArray[obji].header, (int) sizeof(struct defglobalModule),(VOID *) ModuleArray, (int) sizeof(struct defglobal),(VOID *) DefglobalArray); #if DEBUGGING_FUNCTIONS DefglobalArray[obji].watch = WatchGlobals;#endif DefglobalArray[obji].initial = HashedExpressionPointer(bdp->initial); DefglobalArray[obji].current.type = RVOID; } /***************************************//* ClearBload: Defglobal clear routine *//* when a binary load is in effect. *//***************************************/static VOID ClearBload() { long i; unsigned long space; /*=======================================================*/ /* Decrement in use counters for atomic values contained */ /* in the construct headers. Also decrement data */ /* structures used to store the defglobal's value. */ /*=======================================================*/ for (i = 0; i < NumberOfDefglobals; i++) { UnmarkConstructHeader(&DefglobalArray[i].header); ValueDeinstall(&(DefglobalArray[i].current)); if (DefglobalArray[i].current.type == MULTIFIELD) { ReturnMultifield(DefglobalArray[i].current.value); } } /*==============================================================*/ /* Deallocate the space used for the defglobal data structures. */ /*==============================================================*/ space = NumberOfDefglobals * sizeof(struct defglobal); if (space != 0) genlongfree((VOID *) DefglobalArray,space); /*=====================================================================*/ /* Deallocate the space used for the defglobal module data structures. */ /*=====================================================================*/ space = NumberOfDefglobalModules * sizeof(struct defglobalModule); if (space != 0) genlongfree((VOID *) ModuleArray,space); }/********************************************************//* BloadDefglobalModuleReference: Returns the defglobal *//* module pointer for using with the bload function. *//********************************************************/globle VOID *BloadDefglobalModuleReference(index) int index; { return ((VOID *) &ModuleArray[index]); }#endif /* DEFGLOBAL_CONSTRUCT && (BLOAD || BLOAD_AND_BSAVE || BLOAD_ONLY) && (! RUN_TIME) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -