static void DeletePartialMatches( void *theEnv, struct partialMatch *listOfPMs, int betaDelete) { struct partialMatch *nextPM; while (listOfPMs != NULL) { /*============================================*/ /* Remember the next partial match to delete. */ /*============================================*/ nextPM = listOfPMs->next; /*================================================*/ /* Remove the links between the partial match and */ /* any data entities that it is attached to as a */ /* result of a logical CE. */ /*================================================*/ #if LOGICAL_DEPENDENCIES if (listOfPMs->dependentsf) RemoveLogicalSupport(theEnv,listOfPMs); #endif /*==========================================================*/ /* If the partial match is being deleted from a beta memory */ /* and the partial match isn't associated with a satisfied */ /* not CE, then it can be immediately returned to the pool */ /* of free memory. Otherwise, it's could be in use (either */ /* to retrieve variables from the LHS or by the activation */ /* of the rule). Since a not CE creates a "pseudo" data */ /* entity, the beta partial match which stores this pseudo */ /* data entity can not be deleted immediately (for the same */ /* reason an alpha memory partial match can't be deleted */ /* immediately). */ /*==========================================================*/ if (betaDelete && ((listOfPMs->notOriginf == FALSE) || (listOfPMs->counterf))) { ReturnPartialMatch(theEnv,listOfPMs); } else { listOfPMs->next = EngineData(theEnv)->GarbagePartialMatches; EngineData(theEnv)->GarbagePartialMatches = listOfPMs; } /*====================================*/ /* Move on to the next partial match. */ /*====================================*/ listOfPMs = nextPM; } }
static void PNRDrive( struct joinNode *join, struct partialMatch *lhsBinds, struct partialMatch *rhsBinds) { struct joinNode *listOfJoins; /*==================================================*/ /* If the partial match already has a partial match */ /* in the alpha memory which prevents it from being */ /* satisfied, then don't do anything. */ /*==================================================*/ if (lhsBinds->counterf == TRUE) return; /*=================================================*/ /* Set the counterf flag to indicate that an alpha */ /* memory partial match is preventing the beta */ /* memory partial match from being satisfied. */ /*=================================================*/ lhsBinds->counterf = TRUE; /*===================================================================*/ /* If the partial match caused an activation, remove the activation. */ /*===================================================================*/ if ((lhsBinds->activationf) ? (lhsBinds->binds[lhsBinds->bcount].gm.theValue != NULL) : FALSE) { RemoveActivation((struct activation *) lhsBinds->binds[lhsBinds->bcount].gm.theValue,TRUE,TRUE); } /*===========================================================*/ /* The counterf flag was FALSE. This means that a pointer to */ /* the pseudo-fact matching the not CE is stored directly in */ /* the partial match. Determine the ID of this pseudo-fact */ /* and remove all partial matches from descendent joins that */ /* contain the ID. */ /*===========================================================*/ if (join->joinFromTheRight) /* DR0834 */ { RetractCheckDriveRetractions(lhsBinds->binds[lhsBinds->bcount - 1].gm.theMatch, (int) join->depth-1); } listOfJoins = join->nextLevel; if (listOfJoins != NULL) { if (((struct joinNode *) (listOfJoins->rightSideEntryStructure)) == join) { NegEntryRetract(listOfJoins,lhsBinds,FALSE); } else while (listOfJoins != NULL) { PosEntryRetract(listOfJoins, lhsBinds->binds[lhsBinds->bcount - 1].gm.theMatch, lhsBinds,(int) join->depth-1,FALSE); listOfJoins = listOfJoins->rightDriveNode; } } /*=========================================================================*/ /* Remove any logical dependency links associated with this partial match. */ /*=========================================================================*/ #if LOGICAL_DEPENDENCIES if (lhsBinds->dependentsf) RemoveLogicalSupport(lhsBinds); #endif /*========================================*/ /* Put the pseudo-fact on a garbage list. */ /*========================================*/ lhsBinds->binds[lhsBinds->bcount - 1].gm.theMatch->next = GarbageAlphaMatches; GarbageAlphaMatches = lhsBinds->binds[lhsBinds->bcount - 1].gm.theMatch; /*========================================================*/ /* Store the partial match from the alpha memory that is */ /* preventing the LHS partial match from being satisfied. */ /*========================================================*/ lhsBinds->binds[lhsBinds->bcount - 1].gm.theValue = (void *) rhsBinds; }