void SaveExecutionInformation() { HKEY hKey; DWORD lpdwDisposition; struct ExecutionInformation executionInfo; if (RegCreateKeyEx(HKEY_CURRENT_USER,TEXT("Software\\CLIPS\\CLIPSWin"),0,"",0, KEY_READ | KEY_WRITE,NULL,&hKey,&lpdwDisposition) != ERROR_SUCCESS) { return; } executionInfo.salienceEvaluation = EnvGetSalienceEvaluation(GlobalEnv); executionInfo.strategy = EnvGetStrategy(GlobalEnv); executionInfo.staticConstraintChecking = (boolean) EnvGetStaticConstraintChecking(GlobalEnv); executionInfo.dynamicConstraintChecking = (boolean) EnvGetDynamicConstraintChecking(GlobalEnv); executionInfo.autoFloatDividend = (boolean) EnvGetAutoFloatDividend(GlobalEnv); executionInfo.resetGlobals = (boolean) EnvGetResetGlobals(GlobalEnv); executionInfo.factDuplication = (boolean) EnvGetFactDuplication(GlobalEnv); executionInfo.incrementalReset = (boolean) EnvGetIncrementalReset(GlobalEnv); executionInfo.sequenceOperatorRecognition = (boolean) EnvGetSequenceOperatorRecognition(GlobalEnv); if (RegSetValueEx(hKey,"Execution",0,REG_BINARY,(BYTE *) &executionInfo, sizeof(struct ExecutionInformation)) != ERROR_SUCCESS) { RegCloseKey(hKey); return; } RegCloseKey(hKey); }
globle int SetIncrementalResetCommand( void *theEnv, EXEC_STATUS) { int oldValue; DATA_OBJECT argPtr; struct defmodule *theModule; oldValue = EnvGetIncrementalReset(theEnv,execStatus); /*============================================*/ /* Check for the correct number of arguments. */ /*============================================*/ if (EnvArgCountCheck(theEnv,execStatus,"set-incremental-reset",EXACTLY,1) == -1) { return(oldValue); } /*=========================================*/ /* The incremental reset behavior can't be */ /* changed when rules are loaded. */ /*=========================================*/ SaveCurrentModule(theEnv,execStatus); for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,execStatus,NULL); theModule != NULL; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,execStatus,theModule)) { EnvSetCurrentModule(theEnv,execStatus,(void *) theModule); if (EnvGetNextDefrule(theEnv,execStatus,NULL) != NULL) { RestoreCurrentModule(theEnv,execStatus); PrintErrorID(theEnv,execStatus,"INCRRSET",1,FALSE); EnvPrintRouter(theEnv,execStatus,WERROR,"The incremental reset behavior cannot be changed with rules loaded.\n"); SetEvaluationError(theEnv,execStatus,TRUE); return(oldValue); } } RestoreCurrentModule(theEnv,execStatus); /*==================================================*/ /* The symbol FALSE disables incremental reset. Any */ /* other value enables incremental reset. */ /*==================================================*/ EnvRtnUnknown(theEnv,execStatus,1,&argPtr); if ((argPtr.value == EnvFalseSymbol(theEnv,execStatus)) && (argPtr.type == SYMBOL)) { EnvSetIncrementalReset(theEnv,execStatus,FALSE); } else { EnvSetIncrementalReset(theEnv,execStatus,TRUE); } /*=======================*/ /* Return the old value. */ /*=======================*/ return(oldValue); }
globle int GetIncrementalResetCommand( void *theEnv) { int oldValue; oldValue = EnvGetIncrementalReset(theEnv); if (EnvArgCountCheck(theEnv,"get-incremental-reset",EXACTLY,0) == -1) { return(oldValue); } return(oldValue); }
globle int SetIncrementalResetCommand( void *theEnv) { int oldValue; DATA_OBJECT argPtr; oldValue = EnvGetIncrementalReset(theEnv); /*============================================*/ /* Check for the correct number of arguments. */ /*============================================*/ if (EnvArgCountCheck(theEnv,"set-incremental-reset",EXACTLY,1) == -1) { return(oldValue); } /*=========================================*/ /* The incremental reset behavior can't be */ /* changed when rules are loaded. */ /*=========================================*/ if (EnvGetNextDefrule(theEnv,NULL) != NULL) { PrintErrorID(theEnv,"INCRRSET",1,FALSE); EnvPrintRouter(theEnv,WERROR,"The incremental reset behavior cannot be changed with rules loaded.\n"); SetEvaluationError(theEnv,TRUE); return(oldValue); } /*==================================================*/ /* The symbol FALSE disables incremental reset. Any */ /* other value enables incremental reset. */ /*==================================================*/ EnvRtnUnknown(theEnv,1,&argPtr); if ((argPtr.value == EnvFalseSymbol(theEnv)) && (argPtr.type == SYMBOL)) { EnvSetIncrementalReset(theEnv,FALSE); } else { EnvSetIncrementalReset(theEnv,TRUE); } /*=======================*/ /* Return the old value. */ /*=======================*/ return(oldValue); }
static struct joinNode *CreateNewJoin( void *theEnv, struct expr *joinTest, struct expr *secondaryJoinTest, struct joinNode *lhsEntryStruct, void *rhsEntryStruct, int joinFromTheRight, int negatedRHSPattern, int existsRHSPattern, struct expr *leftHash, struct expr *rightHash) { struct joinNode *newJoin; struct joinLink *theLink; /*===============================================*/ /* If compilations are being watch, print +j to */ /* indicate that a new join has been created for */ /* this pattern of the rule (i.e. a join could */ /* not be shared with another rule. */ /*===============================================*/ #if DEBUGGING_FUNCTIONS if ((EnvGetWatchItem(theEnv,(char*)"compilations") == TRUE) && GetPrintWhileLoading(theEnv)) { EnvPrintRouter(theEnv,WDIALOG,(char*)"+j"); } #endif /*======================*/ /* Create the new join. */ /*======================*/ newJoin = get_struct(theEnv,joinNode); /*======================================================*/ /* The first join of a rule does not have a beta memory */ /* unless the RHS pattern is an exists or not CE. */ /*======================================================*/ if ((lhsEntryStruct != NULL) || existsRHSPattern || negatedRHSPattern || joinFromTheRight) { if (leftHash == NULL) { newJoin->leftMemory = get_struct(theEnv,betaMemory); newJoin->leftMemory->beta = (struct partialMatch **) genalloc(theEnv,sizeof(struct partialMatch *)); newJoin->leftMemory->beta[0] = NULL; newJoin->leftMemory->last = NULL; newJoin->leftMemory->size = 1; newJoin->leftMemory->count = 0; } else { newJoin->leftMemory = get_struct(theEnv,betaMemory); newJoin->leftMemory->beta = (struct partialMatch **) genalloc(theEnv,sizeof(struct partialMatch *) * INITIAL_BETA_HASH_SIZE); memset(newJoin->leftMemory->beta,0,sizeof(struct partialMatch *) * INITIAL_BETA_HASH_SIZE); newJoin->leftMemory->last = NULL; newJoin->leftMemory->size = INITIAL_BETA_HASH_SIZE; newJoin->leftMemory->count = 0; } /*===========================================================*/ /* If the first join of a rule connects to an exists or not */ /* CE, then we create an empty partial match for the usually */ /* empty left beta memory so that we can track the current */ /* current right memory partial match satisfying the CE. */ /*===========================================================*/ if ((lhsEntryStruct == NULL) && (existsRHSPattern || negatedRHSPattern || joinFromTheRight)) { newJoin->leftMemory->beta[0] = CreateEmptyPartialMatch(theEnv); newJoin->leftMemory->beta[0]->owner = newJoin; newJoin->leftMemory->count = 1; } } else { newJoin->leftMemory = NULL; } if (joinFromTheRight) { if (leftHash == NULL) { newJoin->rightMemory = get_struct(theEnv,betaMemory); newJoin->rightMemory->beta = (struct partialMatch **) genalloc(theEnv,sizeof(struct partialMatch *)); newJoin->rightMemory->last = (struct partialMatch **) genalloc(theEnv,sizeof(struct partialMatch *)); newJoin->rightMemory->beta[0] = NULL; newJoin->rightMemory->last[0] = NULL; newJoin->rightMemory->size = 1; newJoin->rightMemory->count = 0; } else { newJoin->rightMemory = get_struct(theEnv,betaMemory); newJoin->rightMemory->beta = (struct partialMatch **) genalloc(theEnv,sizeof(struct partialMatch *) * INITIAL_BETA_HASH_SIZE); newJoin->rightMemory->last = (struct partialMatch **) genalloc(theEnv,sizeof(struct partialMatch *) * INITIAL_BETA_HASH_SIZE); memset(newJoin->rightMemory->beta,0,sizeof(struct partialMatch *) * INITIAL_BETA_HASH_SIZE); memset(newJoin->rightMemory->last,0,sizeof(struct partialMatch *) * INITIAL_BETA_HASH_SIZE); newJoin->rightMemory->size = INITIAL_BETA_HASH_SIZE; newJoin->rightMemory->count = 0; } } else if ((lhsEntryStruct == NULL) && (rhsEntryStruct == NULL)) { newJoin->rightMemory = get_struct(theEnv,betaMemory); newJoin->rightMemory->beta = (struct partialMatch **) genalloc(theEnv,sizeof(struct partialMatch *)); newJoin->rightMemory->last = (struct partialMatch **) genalloc(theEnv,sizeof(struct partialMatch *)); newJoin->rightMemory->beta[0] = CreateEmptyPartialMatch(theEnv); newJoin->rightMemory->beta[0]->owner = newJoin; newJoin->rightMemory->beta[0]->rhsMemory = TRUE; newJoin->rightMemory->last[0] = newJoin->rightMemory->beta[0]; newJoin->rightMemory->size = 1; newJoin->rightMemory->count = 1; } else { newJoin->rightMemory = NULL; } newJoin->nextLinks = NULL; newJoin->joinFromTheRight = joinFromTheRight; if (existsRHSPattern) { newJoin->patternIsNegated = FALSE; } else { newJoin->patternIsNegated = negatedRHSPattern; } newJoin->patternIsExists = existsRHSPattern; newJoin->marked = FALSE; newJoin->initialize = EnvGetIncrementalReset(theEnv); newJoin->logicalJoin = FALSE; newJoin->ruleToActivate = NULL; newJoin->memoryAdds = 0; newJoin->memoryDeletes = 0; newJoin->memoryCompares = 0; /*==============================================*/ /* Install the expressions used to determine */ /* if a partial match satisfies the constraints */ /* associated with this join. */ /*==============================================*/ newJoin->networkTest = AddHashedExpression(theEnv,joinTest); newJoin->secondaryNetworkTest = AddHashedExpression(theEnv,secondaryJoinTest); /*=====================================================*/ /* Install the expression used to hash the beta memory */ /* partial match to determine the location to search */ /* in the alpha memory. */ /*=====================================================*/ newJoin->leftHash = AddHashedExpression(theEnv,leftHash); newJoin->rightHash = AddHashedExpression(theEnv,rightHash); /*============================================================*/ /* Initialize the values associated with the LHS of the join. */ /*============================================================*/ newJoin->lastLevel = lhsEntryStruct; if (lhsEntryStruct == NULL) { newJoin->firstJoin = TRUE; newJoin->depth = 1; } else { newJoin->firstJoin = FALSE; newJoin->depth = lhsEntryStruct->depth; newJoin->depth++; /* To work around Sparcworks C compiler bug */ theLink = get_struct(theEnv,joinLink); theLink->join = newJoin; theLink->enterDirection = LHS; theLink->next = lhsEntryStruct->nextLinks; lhsEntryStruct->nextLinks = theLink; } /*=======================================================*/ /* Initialize the pointer values associated with the RHS */ /* of the join (both for the new join and the join or */ /* pattern which enters this join from the right. */ /*=======================================================*/ newJoin->rightSideEntryStructure = rhsEntryStruct; if (rhsEntryStruct == NULL) { if (newJoin->firstJoin) { theLink = get_struct(theEnv,joinLink); theLink->join = newJoin; theLink->enterDirection = RHS; theLink->next = DefruleData(theEnv)->RightPrimeJoins; DefruleData(theEnv)->RightPrimeJoins = theLink; } newJoin->rightMatchNode = NULL; return(newJoin); } /*===========================================================*/ /* If the first join of a rule is a not CE, then it needs to */ /* be "primed" under certain circumstances. This used to be */ /* handled by adding the (initial-fact) pattern to a rule */ /* with the not CE as its first pattern, but this alternate */ /* mechanism is now used so patterns don't have to be added. */ /*===========================================================*/ if (newJoin->firstJoin && (newJoin->patternIsNegated || newJoin->joinFromTheRight) && (! newJoin->patternIsExists)) { theLink = get_struct(theEnv,joinLink); theLink->join = newJoin; theLink->enterDirection = LHS; theLink->next = DefruleData(theEnv)->LeftPrimeJoins; DefruleData(theEnv)->LeftPrimeJoins = theLink; } if (joinFromTheRight) { theLink = get_struct(theEnv,joinLink); theLink->join = newJoin; theLink->enterDirection = RHS; theLink->next = ((struct joinNode *) rhsEntryStruct)->nextLinks; ((struct joinNode *) rhsEntryStruct)->nextLinks = theLink; newJoin->rightMatchNode = NULL; } else { newJoin->rightMatchNode = ((struct patternNodeHeader *) rhsEntryStruct)->entryJoin; ((struct patternNodeHeader *) rhsEntryStruct)->entryJoin = newJoin; } /*================================*/ /* Return the newly created join. */ /*================================*/ return(newJoin); }
globle void IncrementalReset( void *theEnv, struct defrule *tempRule) { #if (MAC_MCW || WIN_MCW) && (RUN_TIME || BLOAD_ONLY) #pragma unused(theEnv,tempRule) #endif #if (! RUN_TIME) && (! BLOAD_ONLY) struct defrule *tempPtr; struct patternParser *theParser; /*================================================*/ /* If incremental reset is disabled, then return. */ /*================================================*/ if (! EnvGetIncrementalReset(theEnv)) return; /*=====================================================*/ /* Mark the pattern and join network data structures */ /* associated with the rule being incrementally reset. */ /*=====================================================*/ MarkNetworkForIncrementalReset(theEnv,tempRule,TRUE); /*==========================*/ /* Begin incremental reset. */ /*==========================*/ EngineData(theEnv)->IncrementalResetInProgress = TRUE; /*============================================================*/ /* If the new rule shares patterns or joins with other rules, */ /* then it is necessary to update its join network based on */ /* existing partial matches it shares with other rules. */ /*============================================================*/ for (tempPtr = tempRule; tempPtr != NULL; tempPtr = tempPtr->disjunct) { CheckForPrimableJoins(theEnv,tempPtr,tempPtr->lastJoin); } /*===============================================*/ /* Filter existing data entities through the new */ /* portions of the pattern and join networks. */ /*===============================================*/ for (theParser = PatternData(theEnv)->ListOfPatternParsers; theParser != NULL; theParser = theParser->next) { if (theParser->incrementalResetFunction != NULL) { (*theParser->incrementalResetFunction)(theEnv); } } /*========================*/ /* End incremental reset. */ /*========================*/ EngineData(theEnv)->IncrementalResetInProgress = FALSE; /*====================================================*/ /* Remove the marks in the pattern and join networks. */ /*====================================================*/ MarkNetworkForIncrementalReset(theEnv,tempRule,FALSE); #endif }
globle intBool GetIncrementalReset() { return EnvGetIncrementalReset(GetCurrentEnvironment()); }
/******************************************************************************* Name: UpdateOptionsMenu Description: Set menu item mark on options selected Arguments: None Returns: None *******************************************************************************/ void UpdateOptionsMenu() { int i; unsigned n = 0; void *theEnv = GetCurrentEnvironment(); XtSetArg(TheArgs[n], XtNleftBitmap, None);n++; for(i = 0; i <= RANDOM_STRATEGY;i++) XtSetValues(strategy_widgets[i], TheArgs, n); for(i = 0; i <= EVERY_CYCLE;i++) XtSetValues(sal_opt_widgets[i],TheArgs,n); n = 0; XtSetArg(TheArgs[n], XtNleftBitmap, checker);n++; XtSetValues(strategy_widgets[EnvGetStrategy(theEnv)],TheArgs,n); XtSetValues(sal_opt_widgets[EnvGetSalienceEvaluation(theEnv)],TheArgs,n); n = 0; if (EnvGetFactDuplication(theEnv)) { XtSetArg(TheArgs[n], XtNstate,True);n++; XtSetValues(option_widgets[INT_FACT_DUPLICATION], TheArgs, n); } else { XtSetArg(TheArgs[n], XtNstate,False);n++; XtSetValues(option_widgets[INT_FACT_DUPLICATION], TheArgs, n); } n = 0; if (EnvGetDynamicConstraintChecking(theEnv)) { XtSetArg(TheArgs[n], XtNstate,True);n++; XtSetValues(option_widgets[INT_DYN_CONSTRAINT_CHK], TheArgs, n); } else { XtSetArg(TheArgs[n], XtNstate,False);n++; XtSetValues(option_widgets[INT_DYN_CONSTRAINT_CHK], TheArgs, n); } n = 0; if (EnvGetStaticConstraintChecking(theEnv)) { XtSetArg(TheArgs[n], XtNstate,True);n++; XtSetValues(option_widgets[INT_STA_CONSTRAINT_CHK], TheArgs, n); } else { XtSetArg(TheArgs[n], XtNstate,False);n++; XtSetValues(option_widgets[INT_STA_CONSTRAINT_CHK], TheArgs, n); } n = 0; if (EnvGetSequenceOperatorRecognition(theEnv)) { XtSetArg(TheArgs[n], XtNstate,True);n++; XtSetValues(option_widgets[INT_SEQUENCE_OPT_REG], TheArgs, n); } else { XtSetArg(TheArgs[n], XtNstate,False);n++; XtSetValues(option_widgets[INT_SEQUENCE_OPT_REG], TheArgs, n); } n = 0; if (EnvGetAutoFloatDividend(theEnv)) { XtSetArg(TheArgs[n], XtNstate,True);n++; XtSetValues(option_widgets[INT_AUTO_FLOAT_DIV], TheArgs, n); } else { XtSetArg(TheArgs[n], XtNstate,False);n++; XtSetValues(option_widgets[INT_AUTO_FLOAT_DIV], TheArgs, n); } n = 0; if (EnvGetIncrementalReset(theEnv)) { XtSetArg(TheArgs[n], XtNstate,True);n++; XtSetValues(option_widgets[INT_INCREMENTAL_RESET], TheArgs, n); } else { XtSetArg(TheArgs[n], XtNstate,False);n++; XtSetValues(option_widgets[INT_INCREMENTAL_RESET], TheArgs, n); } n = 0; if (EnvGetResetGlobals(theEnv)) { XtSetArg(TheArgs[n], XtNstate,True);n++; XtSetValues(option_widgets[INT_RESET_GLOBALS], TheArgs, n); } else { XtSetArg(TheArgs[n], XtNstate,False);n++; XtSetValues(option_widgets[INT_RESET_GLOBALS], TheArgs, n); } }