00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #define _DRIVE_SOURCE_
00040
00041 #include <stdio.h>
00042 #define _STDIO_INCLUDED_
00043 #include <stdlib.h>
00044
00045 #include "setup.h"
00046
00047 #if DEFRULE_CONSTRUCT
00048
00049 #include "agenda.h"
00050 #include "constant.h"
00051 #include "engine.h"
00052 #include "envrnmnt.h"
00053 #include "memalloc.h"
00054 #include "prntutil.h"
00055 #include "reteutil.h"
00056 #include "retract.h"
00057 #include "router.h"
00058 #include "lgcldpnd.h"
00059 #include "incrrset.h"
00060
00061 #include "drive.h"
00062
00063
00064
00065
00066
00067 static void EmptyDrive(void *,struct joinNode *,struct partialMatch *);
00068 static void JoinNetErrorMessage(void *,struct joinNode *);
00069
00070
00071
00072
00073
00074 globle void NetworkAssert(
00075 void *theEnv,
00076 struct partialMatch *binds,
00077 struct joinNode *join)
00078 {
00079
00080
00081
00082
00083
00084 #if (! BLOAD_ONLY) && (! RUN_TIME)
00085 if (EngineData(theEnv)->IncrementalResetInProgress && (join->initialize == FALSE)) return;
00086 #endif
00087
00088
00089
00090
00091
00092 if (join->firstJoin)
00093 {
00094 EmptyDrive(theEnv,join,binds);
00095 return;
00096 }
00097
00098
00099
00100
00101
00102 NetworkAssertRight(theEnv,binds,join);
00103
00104 return;
00105 }
00106
00107
00108
00109
00110
00111
00112 globle void NetworkAssertRight(
00113 void *theEnv,
00114 struct partialMatch *rhsBinds,
00115 struct joinNode *join)
00116 {
00117 struct partialMatch *lhsBinds, *nextBind;
00118 int exprResult, restore = FALSE;
00119 struct partialMatch *oldLHSBinds = NULL;
00120 struct partialMatch *oldRHSBinds = NULL;
00121 struct joinNode *oldJoin = NULL;
00122
00123
00124
00125
00126
00127
00128 #if (! BLOAD_ONLY) && (! RUN_TIME)
00129 if (EngineData(theEnv)->IncrementalResetInProgress && (join->initialize == FALSE)) return;
00130 #endif
00131
00132 if (join->firstJoin)
00133 {
00134 EmptyDrive(theEnv,join,rhsBinds);
00135 return;
00136 }
00137
00138
00139
00140
00141
00142
00143 lhsBinds = GetLeftBetaMemory(join,rhsBinds->hashValue);
00144
00145 #if DEVELOPER
00146 if (lhsBinds != NULL)
00147 { EngineData(theEnv)->rightToLeftLoops++; }
00148 #endif
00149
00150
00151
00152
00153
00154 if (lhsBinds != NULL)
00155 {
00156 oldLHSBinds = EngineData(theEnv)->GlobalLHSBinds;
00157 oldRHSBinds = EngineData(theEnv)->GlobalRHSBinds;
00158 oldJoin = EngineData(theEnv)->GlobalJoin;
00159 EngineData(theEnv)->GlobalRHSBinds = rhsBinds;
00160 EngineData(theEnv)->GlobalJoin = join;
00161 restore = TRUE;
00162 }
00163
00164
00165
00166
00167
00168
00169
00170
00171 while (lhsBinds != NULL)
00172 {
00173 nextBind = lhsBinds->nextInMemory;
00174 join->memoryCompares++;
00175
00176
00177
00178
00179
00180
00181 if (lhsBinds->hashValue != rhsBinds->hashValue)
00182 {
00183 #if DEVELOPER
00184 if (join->leftMemory->size == 1)
00185 { EngineData(theEnv)->betaHashListSkips++; }
00186 else
00187 { EngineData(theEnv)->betaHashHTSkips++; }
00188
00189 if (lhsBinds->marker != NULL)
00190 { EngineData(theEnv)->unneededMarkerCompare++; }
00191 #endif
00192 lhsBinds = nextBind;
00193 continue;
00194 }
00195
00196
00197
00198
00199
00200
00201
00202
00203 if (lhsBinds->marker != NULL)
00204 {
00205 #if DEVELOPER
00206 EngineData(theEnv)->unneededMarkerCompare++;
00207 #endif
00208 lhsBinds = nextBind;
00209 continue;
00210 }
00211
00212
00213
00214
00215
00216
00217
00218 if (join->networkTest == NULL)
00219 { exprResult = TRUE; }
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229 else
00230 {
00231 #if DEVELOPER
00232 EngineData(theEnv)->rightToLeftComparisons++;
00233 #endif
00234 EngineData(theEnv)->GlobalLHSBinds = lhsBinds;
00235 exprResult = EvaluateJoinExpression(theEnv,join->networkTest,join);
00236 if (EvaluationData(theEnv)->EvaluationError)
00237 {
00238 if (join->patternIsNegated) exprResult = TRUE;
00239 SetEvaluationError(theEnv,FALSE);
00240 }
00241
00242 #if DEVELOPER
00243 if (exprResult)
00244 { EngineData(theEnv)->rightToLeftSucceeds++; }
00245 #endif
00246 }
00247
00248 if ((join->secondaryNetworkTest != NULL) && exprResult)
00249 {
00250
00251
00252 exprResult = EvaluateJoinExpression(theEnv,join->secondaryNetworkTest,join);
00253 if (EvaluationData(theEnv)->EvaluationError)
00254 { SetEvaluationError(theEnv,FALSE); }
00255 }
00256
00257
00258
00259
00260
00261
00262
00263
00264 if (exprResult != FALSE)
00265 {
00266 if (join->patternIsExists)
00267 {
00268 AddBlockedLink(lhsBinds,rhsBinds);
00269 PPDrive(theEnv,lhsBinds,NULL,join);
00270 }
00271 else if (join->patternIsNegated || join->joinFromTheRight)
00272 {
00273 AddBlockedLink(lhsBinds,rhsBinds);
00274 if (lhsBinds->children != NULL)
00275 { PosEntryRetractBeta(theEnv,lhsBinds,lhsBinds->children); }
00276
00277
00278
00279
00280 }
00281 else
00282 { PPDrive(theEnv,lhsBinds,rhsBinds,join); }
00283 }
00284
00285
00286
00287
00288
00289 lhsBinds = nextBind;
00290 }
00291
00292
00293
00294
00295
00296 if (restore)
00297 {
00298 EngineData(theEnv)->GlobalLHSBinds = oldLHSBinds;
00299 EngineData(theEnv)->GlobalRHSBinds = oldRHSBinds;
00300 EngineData(theEnv)->GlobalJoin = oldJoin;
00301 }
00302
00303 return;
00304 }
00305
00306
00307
00308
00309
00310
00311 globle void NetworkAssertLeft(
00312 void *theEnv,
00313 struct partialMatch *lhsBinds,
00314 struct joinNode *join)
00315 {
00316 struct partialMatch *rhsBinds;
00317 int exprResult, restore = FALSE;
00318 unsigned long entryHashValue;
00319 struct partialMatch *oldLHSBinds = NULL;
00320 struct partialMatch *oldRHSBinds = NULL;
00321 struct joinNode *oldJoin = NULL;
00322
00323
00324
00325
00326
00327
00328 #if (! BLOAD_ONLY) && (! RUN_TIME)
00329 if (EngineData(theEnv)->IncrementalResetInProgress && (join->initialize == FALSE)) return;
00330 #endif
00331
00332
00333
00334
00335
00336
00337 if (join->ruleToActivate != NULL)
00338 {
00339 AddActivation(theEnv,join->ruleToActivate,lhsBinds);
00340 return;
00341 }
00342
00343
00344
00345
00346
00347
00348 entryHashValue = lhsBinds->hashValue;
00349 if (join->joinFromTheRight)
00350 { rhsBinds = GetRightBetaMemory(join,entryHashValue); }
00351 else
00352 { rhsBinds = GetAlphaMemory(theEnv,(struct patternNodeHeader *) join->rightSideEntryStructure,entryHashValue); }
00353
00354 #if DEVELOPER
00355 if (rhsBinds != NULL)
00356 { EngineData(theEnv)->leftToRightLoops++; }
00357 #endif
00358
00359
00360
00361
00362
00363 if ((rhsBinds != NULL) || (join->secondaryNetworkTest != NULL))
00364 {
00365 oldLHSBinds = EngineData(theEnv)->GlobalLHSBinds;
00366 oldRHSBinds = EngineData(theEnv)->GlobalRHSBinds;
00367 oldJoin = EngineData(theEnv)->GlobalJoin;
00368 EngineData(theEnv)->GlobalLHSBinds = lhsBinds;
00369 EngineData(theEnv)->GlobalJoin = join;
00370 restore = TRUE;
00371 }
00372
00373
00374
00375
00376
00377
00378
00379
00380 while (rhsBinds != NULL)
00381 {
00382 join->memoryCompares++;
00383
00384
00385
00386
00387
00388
00389
00390 if (join->networkTest == NULL)
00391 { exprResult = TRUE; }
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401 else
00402 {
00403 #if DEVELOPER
00404 EngineData(theEnv)->leftToRightComparisons++;
00405 #endif
00406 EngineData(theEnv)->GlobalRHSBinds = rhsBinds;
00407
00408 exprResult = EvaluateJoinExpression(theEnv,join->networkTest,join);
00409 if (EvaluationData(theEnv)->EvaluationError)
00410 {
00411 if (join->patternIsNegated) exprResult = TRUE;
00412 SetEvaluationError(theEnv,FALSE);
00413 }
00414
00415 #if DEVELOPER
00416 if (exprResult)
00417 { EngineData(theEnv)->leftToRightSucceeds++; }
00418 #endif
00419 }
00420
00421
00422
00423
00424
00425
00426
00427
00428 if (exprResult != FALSE)
00429 {
00430
00431
00432
00433
00434
00435
00436 if ((join->patternIsNegated == FALSE) &&
00437 (join->patternIsExists == FALSE) &&
00438 (join->joinFromTheRight == FALSE))
00439 { PPDrive(theEnv,lhsBinds,rhsBinds,join); }
00440
00441
00442
00443
00444
00445
00446 else if (join->patternIsExists)
00447 {
00448 AddBlockedLink(lhsBinds,rhsBinds);
00449 PPDrive(theEnv,lhsBinds,NULL,join);
00450 EngineData(theEnv)->GlobalLHSBinds = oldLHSBinds;
00451 EngineData(theEnv)->GlobalRHSBinds = oldRHSBinds;
00452 EngineData(theEnv)->GlobalJoin = oldJoin;
00453 return;
00454 }
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467 else
00468 {
00469 AddBlockedLink(lhsBinds,rhsBinds);
00470 break;
00471 }
00472 }
00473
00474
00475
00476
00477
00478 rhsBinds = rhsBinds->nextInMemory;
00479 }
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492 if ((join->patternIsNegated || join->joinFromTheRight) &&
00493 (! join->patternIsExists) &&
00494 (lhsBinds->marker == NULL))
00495 {
00496 if (join->secondaryNetworkTest != NULL)
00497 {
00498 EngineData(theEnv)->GlobalRHSBinds = NULL;
00499
00500 exprResult = EvaluateJoinExpression(theEnv,join->secondaryNetworkTest,join);
00501 if (EvaluationData(theEnv)->EvaluationError)
00502 { SetEvaluationError(theEnv,FALSE); }
00503
00504 if (exprResult)
00505 { PPDrive(theEnv,lhsBinds,NULL,join); }
00506 }
00507 else
00508 { PPDrive(theEnv,lhsBinds,NULL,join); }
00509 }
00510
00511
00512
00513
00514
00515 if (restore)
00516 {
00517 EngineData(theEnv)->GlobalLHSBinds = oldLHSBinds;
00518 EngineData(theEnv)->GlobalRHSBinds = oldRHSBinds;
00519 EngineData(theEnv)->GlobalJoin = oldJoin;
00520 }
00521
00522 return;
00523 }
00524
00525
00526
00527
00528
00529
00530 globle intBool EvaluateJoinExpression(
00531 void *theEnv,
00532 struct expr *joinExpr,
00533 struct joinNode *joinPtr)
00534 {
00535 DATA_OBJECT theResult;
00536 int andLogic, result = TRUE;
00537
00538
00539
00540
00541
00542 if (joinExpr == NULL) return(TRUE);
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553 if (joinExpr->value == ExpressionData(theEnv)->PTR_AND)
00554 {
00555 andLogic = TRUE;
00556 joinExpr = joinExpr->argList;
00557 }
00558 else if (joinExpr->value == ExpressionData(theEnv)->PTR_OR)
00559 {
00560 andLogic = FALSE;
00561 joinExpr = joinExpr->argList;
00562 }
00563 else
00564 { andLogic = TRUE; }
00565
00566
00567
00568
00569
00570
00571 while (joinExpr != NULL)
00572 {
00573
00574
00575
00576
00577 if ((EvaluationData(theEnv)->PrimitivesArray[joinExpr->type] == NULL) ?
00578 FALSE :
00579 EvaluationData(theEnv)->PrimitivesArray[joinExpr->type]->evaluateFunction != NULL)
00580 {
00581 struct expr *oldArgument;
00582
00583 oldArgument = EvaluationData(theEnv)->CurrentExpression;
00584 EvaluationData(theEnv)->CurrentExpression = joinExpr;
00585 result = (*EvaluationData(theEnv)->PrimitivesArray[joinExpr->type]->evaluateFunction)(theEnv,joinExpr->value,&theResult);
00586 EvaluationData(theEnv)->CurrentExpression = oldArgument;
00587 }
00588
00589
00590
00591
00592
00593 else if (joinExpr->value == ExpressionData(theEnv)->PTR_OR)
00594 {
00595 result = FALSE;
00596 if (EvaluateJoinExpression(theEnv,joinExpr,joinPtr) == TRUE)
00597 {
00598 if (EvaluationData(theEnv)->EvaluationError)
00599 { return(FALSE); }
00600 result = TRUE;
00601 }
00602 else if (EvaluationData(theEnv)->EvaluationError)
00603 { return(FALSE); }
00604 }
00605
00606
00607
00608
00609
00610 else if (joinExpr->value == ExpressionData(theEnv)->PTR_AND)
00611 {
00612 result = TRUE;
00613 if (EvaluateJoinExpression(theEnv,joinExpr,joinPtr) == FALSE)
00614 {
00615 if (EvaluationData(theEnv)->EvaluationError)
00616 { return(FALSE); }
00617 result = FALSE;
00618 }
00619 else if (EvaluationData(theEnv)->EvaluationError)
00620 { return(FALSE); }
00621 }
00622
00623
00624
00625
00626
00627 else
00628 {
00629 EvaluateExpression(theEnv,joinExpr,&theResult);
00630
00631 if (EvaluationData(theEnv)->EvaluationError)
00632 {
00633 JoinNetErrorMessage(theEnv,joinPtr);
00634 return(FALSE);
00635 }
00636
00637 if ((theResult.value == EnvFalseSymbol(theEnv)) && (theResult.type == SYMBOL))
00638 { result = FALSE; }
00639 else
00640 { result = TRUE; }
00641 }
00642
00643
00644
00645
00646
00647
00648 if ((andLogic == TRUE) && (result == FALSE))
00649 { return(FALSE); }
00650 else if ((andLogic == FALSE) && (result == TRUE))
00651 { return(TRUE); }
00652
00653
00654
00655
00656
00657 joinExpr = joinExpr->nextArg;
00658 }
00659
00660
00661
00662
00663
00664 return(result);
00665 }
00666
00667
00668
00669
00670 globle intBool EvaluateSecondaryNetworkTest(
00671 void *theEnv,
00672 struct partialMatch *leftMatch,
00673 struct joinNode *joinPtr)
00674 {
00675 int joinExpr;
00676 struct partialMatch *oldLHSBinds;
00677 struct partialMatch *oldRHSBinds;
00678 struct joinNode *oldJoin;
00679
00680 if (joinPtr->secondaryNetworkTest == NULL)
00681 { return(TRUE); }
00682
00683 #if DEVELOPER
00684 EngineData(theEnv)->rightToLeftComparisons++;
00685 #endif
00686 oldLHSBinds = EngineData(theEnv)->GlobalLHSBinds;
00687 oldRHSBinds = EngineData(theEnv)->GlobalRHSBinds;
00688 oldJoin = EngineData(theEnv)->GlobalJoin;
00689 EngineData(theEnv)->GlobalLHSBinds = leftMatch;
00690 EngineData(theEnv)->GlobalRHSBinds = NULL;
00691 EngineData(theEnv)->GlobalJoin = joinPtr;
00692
00693 joinExpr = EvaluateJoinExpression(theEnv,joinPtr->secondaryNetworkTest,joinPtr);
00694 EvaluationData(theEnv)->EvaluationError = FALSE;
00695
00696 EngineData(theEnv)->GlobalLHSBinds = oldLHSBinds;
00697 EngineData(theEnv)->GlobalRHSBinds = oldRHSBinds;
00698 EngineData(theEnv)->GlobalJoin = oldJoin;
00699
00700 return(joinExpr);
00701 }
00702
00703
00704
00705
00706 globle unsigned long BetaMemoryHashValue(
00707 void *theEnv,
00708 struct expr *hashExpr,
00709 struct partialMatch *lbinds,
00710 struct partialMatch *rbinds,
00711 struct joinNode *joinPtr)
00712 {
00713 DATA_OBJECT theResult;
00714 struct partialMatch *oldLHSBinds;
00715 struct partialMatch *oldRHSBinds;
00716 struct joinNode *oldJoin;
00717 unsigned long hashValue = 0;
00718 unsigned long multiplier = 1;
00719
00720
00721
00722
00723
00724 if (hashExpr == NULL) return(0);
00725
00726
00727
00728
00729
00730
00731 oldLHSBinds = EngineData(theEnv)->GlobalLHSBinds;
00732 oldRHSBinds = EngineData(theEnv)->GlobalRHSBinds;
00733 oldJoin = EngineData(theEnv)->GlobalJoin;
00734 EngineData(theEnv)->GlobalLHSBinds = lbinds;
00735 EngineData(theEnv)->GlobalRHSBinds = rbinds;
00736 EngineData(theEnv)->GlobalJoin = joinPtr;
00737
00738
00739
00740
00741
00742
00743 while (hashExpr != NULL)
00744 {
00745
00746
00747
00748
00749 if ((EvaluationData(theEnv)->PrimitivesArray[hashExpr->type] == NULL) ?
00750 FALSE :
00751 EvaluationData(theEnv)->PrimitivesArray[hashExpr->type]->evaluateFunction != NULL)
00752 {
00753 struct expr *oldArgument;
00754
00755 oldArgument = EvaluationData(theEnv)->CurrentExpression;
00756 EvaluationData(theEnv)->CurrentExpression = hashExpr;
00757 (*EvaluationData(theEnv)->PrimitivesArray[hashExpr->type]->evaluateFunction)(theEnv,hashExpr->value,&theResult);
00758 EvaluationData(theEnv)->CurrentExpression = oldArgument;
00759 }
00760
00761
00762
00763
00764
00765 else
00766 { EvaluateExpression(theEnv,hashExpr,&theResult); }
00767
00768 switch (theResult.type)
00769 {
00770 case STRING:
00771 case SYMBOL:
00772 case INSTANCE_NAME:
00773 hashValue += (((SYMBOL_HN *) theResult.value)->bucket * multiplier);
00774 break;
00775
00776 case INTEGER:
00777 hashValue += (((INTEGER_HN *) theResult.value)->bucket * multiplier);
00778 break;
00779
00780 case FLOAT:
00781 hashValue += (((FLOAT_HN *) theResult.value)->bucket * multiplier);
00782 break;
00783 }
00784
00785
00786
00787
00788
00789 hashExpr = hashExpr->nextArg;
00790 multiplier = multiplier * 509;
00791 }
00792
00793
00794
00795
00796
00797 EngineData(theEnv)->GlobalLHSBinds = oldLHSBinds;
00798 EngineData(theEnv)->GlobalRHSBinds = oldRHSBinds;
00799 EngineData(theEnv)->GlobalJoin = oldJoin;
00800
00801
00802
00803
00804
00805 return(hashValue);
00806 }
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817 globle void PPDrive(
00818 void *theEnv,
00819 struct partialMatch *lhsBinds,
00820 struct partialMatch *rhsBinds,
00821 struct joinNode *join)
00822 {
00823 struct partialMatch *linker;
00824 struct joinLink *listOfJoins;
00825 unsigned long hashValue;
00826
00827
00828
00829
00830
00831 listOfJoins = join->nextLinks;
00832 if (listOfJoins == NULL) return;
00833
00834
00835
00836
00837
00838
00839 while (listOfJoins != NULL)
00840 {
00841
00842
00843
00844
00845 linker = MergePartialMatches(theEnv,lhsBinds,rhsBinds);
00846
00847
00848
00849
00850
00851 if (listOfJoins->enterDirection == LHS)
00852 {
00853 if (listOfJoins->join->leftHash != NULL)
00854 { hashValue = BetaMemoryHashValue(theEnv,listOfJoins->join->leftHash,linker,NULL,listOfJoins->join); }
00855 else
00856 { hashValue = 0; }
00857 }
00858 else
00859 {
00860 if (listOfJoins->join->rightHash != NULL)
00861 { hashValue = BetaMemoryHashValue(theEnv,listOfJoins->join->rightHash,linker,NULL,listOfJoins->join); }
00862 else
00863 { hashValue = 0; }
00864 }
00865
00866
00867
00868
00869
00870 UpdateBetaPMLinks(theEnv,linker,lhsBinds,rhsBinds,listOfJoins->join,hashValue,listOfJoins->enterDirection);
00871
00872 if (listOfJoins->enterDirection == LHS)
00873 { NetworkAssertLeft(theEnv,linker,listOfJoins->join); }
00874 else
00875 { NetworkAssertRight(theEnv,linker,listOfJoins->join); }
00876
00877 listOfJoins = listOfJoins->next;
00878 }
00879
00880 return;
00881 }
00882
00883
00884
00885
00886
00887
00888 globle void EPMDrive(
00889 void *theEnv,
00890 struct partialMatch *parent,
00891 struct joinNode *join)
00892 {
00893 struct partialMatch *linker;
00894 struct joinLink *listOfJoins;
00895
00896 listOfJoins = join->nextLinks;
00897 if (listOfJoins == NULL) return;
00898
00899 while (listOfJoins != NULL)
00900 {
00901 linker = CreateEmptyPartialMatch(theEnv);
00902
00903 UpdateBetaPMLinks(theEnv,linker,parent,NULL,listOfJoins->join,0,listOfJoins->enterDirection);
00904
00905 if (listOfJoins->enterDirection == LHS)
00906 { NetworkAssertLeft(theEnv,linker,listOfJoins->join); }
00907 else
00908 { NetworkAssertRight(theEnv,linker,listOfJoins->join); }
00909
00910 listOfJoins = listOfJoins->next;
00911 }
00912 }
00913
00914
00915
00916
00917
00918
00919 static void EmptyDrive(
00920 void *theEnv,
00921 struct joinNode *join,
00922 struct partialMatch *rhsBinds)
00923 {
00924 struct partialMatch *linker, *existsParent = NULL, *notParent;
00925 struct joinLink *listOfJoins;
00926 int joinExpr;
00927 unsigned long hashValue;
00928 struct partialMatch *oldLHSBinds;
00929 struct partialMatch *oldRHSBinds;
00930 struct joinNode *oldJoin;
00931
00932
00933
00934
00935
00936
00937
00938 join->memoryCompares++;
00939
00940 if (join->networkTest != NULL)
00941 {
00942
00943 #if DEVELOPER
00944 if (join->networkTest)
00945 { EngineData(theEnv)->rightToLeftComparisons++; }
00946 #endif
00947 oldLHSBinds = EngineData(theEnv)->GlobalLHSBinds;
00948 oldRHSBinds = EngineData(theEnv)->GlobalRHSBinds;
00949 oldJoin = EngineData(theEnv)->GlobalJoin;
00950 EngineData(theEnv)->GlobalLHSBinds = NULL;
00951 EngineData(theEnv)->GlobalRHSBinds = rhsBinds;
00952 EngineData(theEnv)->GlobalJoin = join;
00953
00954 joinExpr = EvaluateJoinExpression(theEnv,join->networkTest,join);
00955 EvaluationData(theEnv)->EvaluationError = FALSE;
00956
00957 EngineData(theEnv)->GlobalLHSBinds = oldLHSBinds;
00958 EngineData(theEnv)->GlobalRHSBinds = oldRHSBinds;
00959 EngineData(theEnv)->GlobalJoin = oldJoin;
00960
00961 if (joinExpr == FALSE) return;
00962 }
00963
00964
00965
00966
00967
00968 if (join->patternIsNegated || (join->joinFromTheRight && (! join->patternIsExists)))
00969 {
00970 notParent = join->leftMemory->beta[0];
00971 if (notParent->marker != NULL)
00972 { return; }
00973
00974 AddBlockedLink(notParent,rhsBinds);
00975
00976 if (notParent->children != NULL)
00977 { PosEntryRetractBeta(theEnv,notParent,notParent->children); }
00978
00979
00980
00981
00982
00983 return;
00984 }
00985
00986
00987
00988
00989
00990
00991
00992
00993 if (join->patternIsExists)
00994 {
00995 existsParent = join->leftMemory->beta[0];
00996 if (existsParent->marker != NULL)
00997 { return; }
00998 AddBlockedLink(existsParent,rhsBinds);
00999 }
01000
01001
01002
01003
01004
01005 listOfJoins = join->nextLinks;
01006 if (listOfJoins == NULL) return;
01007
01008 while (listOfJoins != NULL)
01009 {
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021 if (join->patternIsExists)
01022 { linker = CreateEmptyPartialMatch(theEnv); }
01023
01024
01025
01026
01027
01028 else
01029 { linker = CopyPartialMatch(theEnv,rhsBinds); }
01030
01031
01032
01033
01034
01035 if (listOfJoins->enterDirection == LHS)
01036 {
01037 if (listOfJoins->join->leftHash != NULL)
01038 { hashValue = BetaMemoryHashValue(theEnv,listOfJoins->join->leftHash,linker,NULL,listOfJoins->join); }
01039 else
01040 { hashValue = 0; }
01041 }
01042 else
01043 {
01044 if (listOfJoins->join->rightHash != NULL)
01045 { hashValue = BetaMemoryHashValue(theEnv,listOfJoins->join->rightHash,linker,NULL,listOfJoins->join); }
01046 else
01047 { hashValue = 0; }
01048 }
01049
01050
01051
01052
01053
01054 if (join->patternIsExists)
01055 { UpdateBetaPMLinks(theEnv,linker,existsParent,NULL,listOfJoins->join,hashValue,listOfJoins->enterDirection); }
01056 else
01057 { UpdateBetaPMLinks(theEnv,linker,NULL,rhsBinds,listOfJoins->join,hashValue,listOfJoins->enterDirection); }
01058
01059 if (listOfJoins->enterDirection == LHS)
01060 { NetworkAssertLeft(theEnv,linker,listOfJoins->join); }
01061 else
01062 { NetworkAssertRight(theEnv,linker,listOfJoins->join); }
01063
01064 listOfJoins = listOfJoins->next;
01065 }
01066 }
01067
01068
01069
01070
01071
01072
01073 static void JoinNetErrorMessage(
01074 void *theEnv,
01075 struct joinNode *joinPtr)
01076 {
01077 PrintErrorID(theEnv,"DRIVE",1,TRUE);
01078 EnvPrintRouter(theEnv,WERROR,"This error occurred in the join network\n");
01079
01080 EnvPrintRouter(theEnv,WERROR," Problem resides in associated join\n");
01081
01082
01083
01084
01085 TraceErrorToRule(theEnv,joinPtr," ");
01086 EnvPrintRouter(theEnv,WERROR,"\n");
01087 }
01088
01089 #endif