clipsruby 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/clipsruby/agenda.c +1373 -0
- data/ext/clipsruby/agenda.h +169 -0
- data/ext/clipsruby/analysis.c +1142 -0
- data/ext/clipsruby/analysis.h +61 -0
- data/ext/clipsruby/argacces.c +526 -0
- data/ext/clipsruby/argacces.h +77 -0
- data/ext/clipsruby/bload.c +884 -0
- data/ext/clipsruby/bload.h +94 -0
- data/ext/clipsruby/bmathfun.c +557 -0
- data/ext/clipsruby/bmathfun.h +66 -0
- data/ext/clipsruby/bsave.c +634 -0
- data/ext/clipsruby/bsave.h +130 -0
- data/ext/clipsruby/classcom.c +976 -0
- data/ext/clipsruby/classcom.h +115 -0
- data/ext/clipsruby/classexm.c +1376 -0
- data/ext/clipsruby/classexm.h +97 -0
- data/ext/clipsruby/classfun.c +1392 -0
- data/ext/clipsruby/classfun.h +164 -0
- data/ext/clipsruby/classinf.c +1245 -0
- data/ext/clipsruby/classinf.h +94 -0
- data/ext/clipsruby/classini.c +843 -0
- data/ext/clipsruby/classini.h +75 -0
- data/ext/clipsruby/classpsr.c +957 -0
- data/ext/clipsruby/classpsr.h +73 -0
- data/ext/clipsruby/clips.h +133 -0
- data/ext/clipsruby/clipsruby.c +619 -0
- data/ext/clipsruby/clsltpsr.c +931 -0
- data/ext/clipsruby/clsltpsr.h +72 -0
- data/ext/clipsruby/commline.c +1217 -0
- data/ext/clipsruby/commline.h +131 -0
- data/ext/clipsruby/conscomp.c +1593 -0
- data/ext/clipsruby/conscomp.h +150 -0
- data/ext/clipsruby/constant.h +264 -0
- data/ext/clipsruby/constrct.c +1090 -0
- data/ext/clipsruby/constrct.h +216 -0
- data/ext/clipsruby/constrnt.c +554 -0
- data/ext/clipsruby/constrnt.h +132 -0
- data/ext/clipsruby/crstrtgy.c +1088 -0
- data/ext/clipsruby/crstrtgy.h +85 -0
- data/ext/clipsruby/cstrcbin.c +185 -0
- data/ext/clipsruby/cstrcbin.h +61 -0
- data/ext/clipsruby/cstrccmp.h +43 -0
- data/ext/clipsruby/cstrccom.c +1791 -0
- data/ext/clipsruby/cstrccom.h +115 -0
- data/ext/clipsruby/cstrcpsr.c +835 -0
- data/ext/clipsruby/cstrcpsr.h +97 -0
- data/ext/clipsruby/cstrnbin.c +282 -0
- data/ext/clipsruby/cstrnbin.h +55 -0
- data/ext/clipsruby/cstrnchk.c +826 -0
- data/ext/clipsruby/cstrnchk.h +91 -0
- data/ext/clipsruby/cstrncmp.c +238 -0
- data/ext/clipsruby/cstrncmp.h +57 -0
- data/ext/clipsruby/cstrnops.c +1176 -0
- data/ext/clipsruby/cstrnops.h +47 -0
- data/ext/clipsruby/cstrnpsr.c +1394 -0
- data/ext/clipsruby/cstrnpsr.h +88 -0
- data/ext/clipsruby/cstrnutl.c +564 -0
- data/ext/clipsruby/cstrnutl.h +54 -0
- data/ext/clipsruby/default.c +454 -0
- data/ext/clipsruby/default.h +57 -0
- data/ext/clipsruby/defins.c +971 -0
- data/ext/clipsruby/defins.h +127 -0
- data/ext/clipsruby/developr.c +677 -0
- data/ext/clipsruby/developr.h +69 -0
- data/ext/clipsruby/dffctbin.c +477 -0
- data/ext/clipsruby/dffctbin.h +76 -0
- data/ext/clipsruby/dffctbsc.c +308 -0
- data/ext/clipsruby/dffctbsc.h +72 -0
- data/ext/clipsruby/dffctcmp.c +297 -0
- data/ext/clipsruby/dffctcmp.h +44 -0
- data/ext/clipsruby/dffctdef.c +364 -0
- data/ext/clipsruby/dffctdef.h +104 -0
- data/ext/clipsruby/dffctpsr.c +179 -0
- data/ext/clipsruby/dffctpsr.h +49 -0
- data/ext/clipsruby/dffnxbin.c +520 -0
- data/ext/clipsruby/dffnxbin.h +67 -0
- data/ext/clipsruby/dffnxcmp.c +378 -0
- data/ext/clipsruby/dffnxcmp.h +54 -0
- data/ext/clipsruby/dffnxexe.c +241 -0
- data/ext/clipsruby/dffnxexe.h +58 -0
- data/ext/clipsruby/dffnxfun.c +1192 -0
- data/ext/clipsruby/dffnxfun.h +155 -0
- data/ext/clipsruby/dffnxpsr.c +514 -0
- data/ext/clipsruby/dffnxpsr.h +57 -0
- data/ext/clipsruby/dfinsbin.c +509 -0
- data/ext/clipsruby/dfinsbin.h +66 -0
- data/ext/clipsruby/dfinscmp.c +345 -0
- data/ext/clipsruby/dfinscmp.h +48 -0
- data/ext/clipsruby/drive.c +1191 -0
- data/ext/clipsruby/drive.h +65 -0
- data/ext/clipsruby/emathfun.c +1213 -0
- data/ext/clipsruby/emathfun.h +99 -0
- data/ext/clipsruby/engine.c +1568 -0
- data/ext/clipsruby/engine.h +203 -0
- data/ext/clipsruby/entities.h +276 -0
- data/ext/clipsruby/envrnbld.c +514 -0
- data/ext/clipsruby/envrnbld.h +40 -0
- data/ext/clipsruby/envrnmnt.c +257 -0
- data/ext/clipsruby/envrnmnt.h +112 -0
- data/ext/clipsruby/evaluatn.c +1736 -0
- data/ext/clipsruby/evaluatn.h +211 -0
- data/ext/clipsruby/expressn.c +494 -0
- data/ext/clipsruby/expressn.h +154 -0
- data/ext/clipsruby/exprnbin.c +538 -0
- data/ext/clipsruby/exprnbin.h +60 -0
- data/ext/clipsruby/exprnops.c +564 -0
- data/ext/clipsruby/exprnops.h +67 -0
- data/ext/clipsruby/exprnpsr.c +1112 -0
- data/ext/clipsruby/exprnpsr.h +98 -0
- data/ext/clipsruby/extconf.rb +2 -0
- data/ext/clipsruby/extnfunc.c +1015 -0
- data/ext/clipsruby/extnfunc.h +157 -0
- data/ext/clipsruby/factbin.c +447 -0
- data/ext/clipsruby/factbin.h +56 -0
- data/ext/clipsruby/factbld.c +1035 -0
- data/ext/clipsruby/factbld.h +63 -0
- data/ext/clipsruby/factcmp.c +386 -0
- data/ext/clipsruby/factcmp.h +46 -0
- data/ext/clipsruby/factcom.c +759 -0
- data/ext/clipsruby/factcom.h +80 -0
- data/ext/clipsruby/factfile.c +1761 -0
- data/ext/clipsruby/factfile.h +54 -0
- data/ext/clipsruby/factfun.c +682 -0
- data/ext/clipsruby/factfun.h +77 -0
- data/ext/clipsruby/factgen.c +1305 -0
- data/ext/clipsruby/factgen.h +229 -0
- data/ext/clipsruby/facthsh.c +438 -0
- data/ext/clipsruby/facthsh.h +81 -0
- data/ext/clipsruby/factlhs.c +250 -0
- data/ext/clipsruby/factlhs.h +54 -0
- data/ext/clipsruby/factmch.c +905 -0
- data/ext/clipsruby/factmch.h +68 -0
- data/ext/clipsruby/factmngr.c +3373 -0
- data/ext/clipsruby/factmngr.h +325 -0
- data/ext/clipsruby/factprt.c +498 -0
- data/ext/clipsruby/factprt.h +60 -0
- data/ext/clipsruby/factqpsr.c +796 -0
- data/ext/clipsruby/factqpsr.h +61 -0
- data/ext/clipsruby/factqury.c +1267 -0
- data/ext/clipsruby/factqury.h +112 -0
- data/ext/clipsruby/factrete.c +978 -0
- data/ext/clipsruby/factrete.h +70 -0
- data/ext/clipsruby/factrhs.c +667 -0
- data/ext/clipsruby/factrhs.h +55 -0
- data/ext/clipsruby/filecom.c +353 -0
- data/ext/clipsruby/filecom.h +137 -0
- data/ext/clipsruby/filertr.c +481 -0
- data/ext/clipsruby/filertr.h +94 -0
- data/ext/clipsruby/fileutil.c +1020 -0
- data/ext/clipsruby/fileutil.h +50 -0
- data/ext/clipsruby/generate.c +1079 -0
- data/ext/clipsruby/generate.h +57 -0
- data/ext/clipsruby/genrcbin.c +902 -0
- data/ext/clipsruby/genrcbin.h +69 -0
- data/ext/clipsruby/genrccmp.c +640 -0
- data/ext/clipsruby/genrccmp.h +59 -0
- data/ext/clipsruby/genrccom.c +2017 -0
- data/ext/clipsruby/genrccom.h +119 -0
- data/ext/clipsruby/genrcexe.c +737 -0
- data/ext/clipsruby/genrcexe.h +73 -0
- data/ext/clipsruby/genrcfun.c +890 -0
- data/ext/clipsruby/genrcfun.h +185 -0
- data/ext/clipsruby/genrcpsr.c +1618 -0
- data/ext/clipsruby/genrcpsr.h +80 -0
- data/ext/clipsruby/globlbin.c +458 -0
- data/ext/clipsruby/globlbin.h +71 -0
- data/ext/clipsruby/globlbsc.c +361 -0
- data/ext/clipsruby/globlbsc.h +83 -0
- data/ext/clipsruby/globlcmp.c +330 -0
- data/ext/clipsruby/globlcmp.h +52 -0
- data/ext/clipsruby/globlcom.c +289 -0
- data/ext/clipsruby/globlcom.h +63 -0
- data/ext/clipsruby/globldef.c +1087 -0
- data/ext/clipsruby/globldef.h +151 -0
- data/ext/clipsruby/globlpsr.c +530 -0
- data/ext/clipsruby/globlpsr.h +59 -0
- data/ext/clipsruby/immthpsr.c +431 -0
- data/ext/clipsruby/immthpsr.h +55 -0
- data/ext/clipsruby/incrrset.c +530 -0
- data/ext/clipsruby/incrrset.h +73 -0
- data/ext/clipsruby/inherpsr.c +850 -0
- data/ext/clipsruby/inherpsr.h +52 -0
- data/ext/clipsruby/inscom.c +2076 -0
- data/ext/clipsruby/inscom.h +182 -0
- data/ext/clipsruby/insfile.c +1764 -0
- data/ext/clipsruby/insfile.h +96 -0
- data/ext/clipsruby/insfun.c +1451 -0
- data/ext/clipsruby/insfun.h +134 -0
- data/ext/clipsruby/insmngr.c +2550 -0
- data/ext/clipsruby/insmngr.h +125 -0
- data/ext/clipsruby/insmoddp.c +1041 -0
- data/ext/clipsruby/insmoddp.h +91 -0
- data/ext/clipsruby/insmult.c +804 -0
- data/ext/clipsruby/insmult.h +62 -0
- data/ext/clipsruby/inspsr.c +602 -0
- data/ext/clipsruby/inspsr.h +60 -0
- data/ext/clipsruby/insquery.c +1278 -0
- data/ext/clipsruby/insquery.h +115 -0
- data/ext/clipsruby/insqypsr.c +729 -0
- data/ext/clipsruby/insqypsr.h +63 -0
- data/ext/clipsruby/iofun.c +2045 -0
- data/ext/clipsruby/iofun.h +116 -0
- data/ext/clipsruby/lgcldpnd.c +644 -0
- data/ext/clipsruby/lgcldpnd.h +75 -0
- data/ext/clipsruby/main.c +112 -0
- data/ext/clipsruby/match.h +142 -0
- data/ext/clipsruby/memalloc.c +481 -0
- data/ext/clipsruby/memalloc.h +197 -0
- data/ext/clipsruby/miscfun.c +1801 -0
- data/ext/clipsruby/miscfun.h +132 -0
- data/ext/clipsruby/modulbin.c +607 -0
- data/ext/clipsruby/modulbin.h +84 -0
- data/ext/clipsruby/modulbsc.c +347 -0
- data/ext/clipsruby/modulbsc.h +67 -0
- data/ext/clipsruby/modulcmp.c +499 -0
- data/ext/clipsruby/modulcmp.h +54 -0
- data/ext/clipsruby/moduldef.c +817 -0
- data/ext/clipsruby/moduldef.h +271 -0
- data/ext/clipsruby/modulpsr.c +1150 -0
- data/ext/clipsruby/modulpsr.h +69 -0
- data/ext/clipsruby/modulutl.c +1036 -0
- data/ext/clipsruby/modulutl.h +84 -0
- data/ext/clipsruby/msgcom.c +1221 -0
- data/ext/clipsruby/msgcom.h +125 -0
- data/ext/clipsruby/msgfun.c +1076 -0
- data/ext/clipsruby/msgfun.h +118 -0
- data/ext/clipsruby/msgpass.c +1441 -0
- data/ext/clipsruby/msgpass.h +103 -0
- data/ext/clipsruby/msgpsr.c +698 -0
- data/ext/clipsruby/msgpsr.h +73 -0
- data/ext/clipsruby/multifld.c +1404 -0
- data/ext/clipsruby/multifld.h +130 -0
- data/ext/clipsruby/multifun.c +2182 -0
- data/ext/clipsruby/multifun.h +102 -0
- data/ext/clipsruby/network.h +142 -0
- data/ext/clipsruby/objbin.c +1522 -0
- data/ext/clipsruby/objbin.h +79 -0
- data/ext/clipsruby/objcmp.c +1507 -0
- data/ext/clipsruby/objcmp.h +71 -0
- data/ext/clipsruby/object.h +260 -0
- data/ext/clipsruby/objrtbin.c +701 -0
- data/ext/clipsruby/objrtbin.h +79 -0
- data/ext/clipsruby/objrtbld.c +2393 -0
- data/ext/clipsruby/objrtbld.h +66 -0
- data/ext/clipsruby/objrtcmp.c +734 -0
- data/ext/clipsruby/objrtcmp.h +66 -0
- data/ext/clipsruby/objrtfnx.c +1330 -0
- data/ext/clipsruby/objrtfnx.h +222 -0
- data/ext/clipsruby/objrtgen.c +736 -0
- data/ext/clipsruby/objrtgen.h +63 -0
- data/ext/clipsruby/objrtmch.c +1524 -0
- data/ext/clipsruby/objrtmch.h +160 -0
- data/ext/clipsruby/parsefun.c +415 -0
- data/ext/clipsruby/parsefun.h +67 -0
- data/ext/clipsruby/pattern.c +1265 -0
- data/ext/clipsruby/pattern.h +163 -0
- data/ext/clipsruby/pprint.c +328 -0
- data/ext/clipsruby/pprint.h +79 -0
- data/ext/clipsruby/prccode.c +1478 -0
- data/ext/clipsruby/prccode.h +145 -0
- data/ext/clipsruby/prcdrfun.c +640 -0
- data/ext/clipsruby/prcdrfun.h +95 -0
- data/ext/clipsruby/prcdrpsr.c +1068 -0
- data/ext/clipsruby/prcdrpsr.h +79 -0
- data/ext/clipsruby/prdctfun.c +869 -0
- data/ext/clipsruby/prdctfun.h +77 -0
- data/ext/clipsruby/prntutil.c +878 -0
- data/ext/clipsruby/prntutil.h +125 -0
- data/ext/clipsruby/proflfun.c +827 -0
- data/ext/clipsruby/proflfun.h +118 -0
- data/ext/clipsruby/reorder.c +2082 -0
- data/ext/clipsruby/reorder.h +172 -0
- data/ext/clipsruby/reteutil.c +1732 -0
- data/ext/clipsruby/reteutil.h +111 -0
- data/ext/clipsruby/retract.c +710 -0
- data/ext/clipsruby/retract.h +74 -0
- data/ext/clipsruby/router.c +737 -0
- data/ext/clipsruby/router.h +147 -0
- data/ext/clipsruby/rulebin.c +1136 -0
- data/ext/clipsruby/rulebin.h +153 -0
- data/ext/clipsruby/rulebld.c +1328 -0
- data/ext/clipsruby/rulebld.h +62 -0
- data/ext/clipsruby/rulebsc.c +517 -0
- data/ext/clipsruby/rulebsc.h +91 -0
- data/ext/clipsruby/rulecmp.c +733 -0
- data/ext/clipsruby/rulecmp.h +63 -0
- data/ext/clipsruby/rulecom.c +1583 -0
- data/ext/clipsruby/rulecom.h +116 -0
- data/ext/clipsruby/rulecstr.c +892 -0
- data/ext/clipsruby/rulecstr.h +53 -0
- data/ext/clipsruby/ruledef.c +559 -0
- data/ext/clipsruby/ruledef.h +179 -0
- data/ext/clipsruby/ruledlt.c +599 -0
- data/ext/clipsruby/ruledlt.h +58 -0
- data/ext/clipsruby/rulelhs.c +1216 -0
- data/ext/clipsruby/rulelhs.h +52 -0
- data/ext/clipsruby/rulepsr.c +1073 -0
- data/ext/clipsruby/rulepsr.h +61 -0
- data/ext/clipsruby/scanner.c +856 -0
- data/ext/clipsruby/scanner.h +112 -0
- data/ext/clipsruby/setup.h +488 -0
- data/ext/clipsruby/sortfun.c +433 -0
- data/ext/clipsruby/sortfun.h +55 -0
- data/ext/clipsruby/strngfun.c +1173 -0
- data/ext/clipsruby/strngfun.h +96 -0
- data/ext/clipsruby/strngrtr.c +523 -0
- data/ext/clipsruby/strngrtr.h +97 -0
- data/ext/clipsruby/symblbin.c +648 -0
- data/ext/clipsruby/symblbin.h +64 -0
- data/ext/clipsruby/symblcmp.c +893 -0
- data/ext/clipsruby/symblcmp.h +61 -0
- data/ext/clipsruby/symbol.c +1961 -0
- data/ext/clipsruby/symbol.h +243 -0
- data/ext/clipsruby/sysdep.c +894 -0
- data/ext/clipsruby/sysdep.h +164 -0
- data/ext/clipsruby/textpro.c +1388 -0
- data/ext/clipsruby/textpro.h +77 -0
- data/ext/clipsruby/tmpltbin.c +609 -0
- data/ext/clipsruby/tmpltbin.h +108 -0
- data/ext/clipsruby/tmpltbsc.c +327 -0
- data/ext/clipsruby/tmpltbsc.h +87 -0
- data/ext/clipsruby/tmpltcmp.c +450 -0
- data/ext/clipsruby/tmpltcmp.h +57 -0
- data/ext/clipsruby/tmpltdef.c +584 -0
- data/ext/clipsruby/tmpltdef.h +155 -0
- data/ext/clipsruby/tmpltfun.c +2477 -0
- data/ext/clipsruby/tmpltfun.h +122 -0
- data/ext/clipsruby/tmpltlhs.c +379 -0
- data/ext/clipsruby/tmpltlhs.h +50 -0
- data/ext/clipsruby/tmpltpsr.c +819 -0
- data/ext/clipsruby/tmpltpsr.h +59 -0
- data/ext/clipsruby/tmpltrhs.c +595 -0
- data/ext/clipsruby/tmpltrhs.h +55 -0
- data/ext/clipsruby/tmpltutl.c +637 -0
- data/ext/clipsruby/tmpltutl.h +82 -0
- data/ext/clipsruby/userdata.c +156 -0
- data/ext/clipsruby/userdata.h +72 -0
- data/ext/clipsruby/userfunctions.c +70 -0
- data/ext/clipsruby/usrsetup.h +7 -0
- data/ext/clipsruby/utility.c +1594 -0
- data/ext/clipsruby/utility.h +250 -0
- data/ext/clipsruby/watch.c +865 -0
- data/ext/clipsruby/watch.h +124 -0
- data/lib/clipsruby.rb +1 -0
- metadata +388 -0
@@ -0,0 +1,710 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.40 08/28/17 */
|
5
|
+
/* */
|
6
|
+
/* RETRACT MODULE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: Handles join network activity associated with */
|
11
|
+
/* with the removal of a data entity such as a fact or */
|
12
|
+
/* instance. */
|
13
|
+
/* */
|
14
|
+
/* Principal Programmer(s): */
|
15
|
+
/* Gary D. Riley */
|
16
|
+
/* */
|
17
|
+
/* Contributing Programmer(s): */
|
18
|
+
/* */
|
19
|
+
/* Revision History: */
|
20
|
+
/* */
|
21
|
+
/* 6.24: Removed LOGICAL_DEPENDENCIES compilation flag. */
|
22
|
+
/* */
|
23
|
+
/* Renamed BOOLEAN macro type to intBool. */
|
24
|
+
/* */
|
25
|
+
/* Rule with exists CE has incorrect activation. */
|
26
|
+
/* DR0867 */
|
27
|
+
/* */
|
28
|
+
/* 6.30: Added support for hashed memories. */
|
29
|
+
/* */
|
30
|
+
/* Added additional developer statistics to help */
|
31
|
+
/* analyze join network performance. */
|
32
|
+
/* */
|
33
|
+
/* Removed pseudo-facts used in not CEs. */
|
34
|
+
/* */
|
35
|
+
/* 6.31: Bug fix to prevent rule activations for */
|
36
|
+
/* partial matches being deleted. */
|
37
|
+
/* */
|
38
|
+
/* 6.40: Pragma once and other inclusion changes. */
|
39
|
+
/* */
|
40
|
+
/* Added support for booleans with <stdbool.h>. */
|
41
|
+
/* */
|
42
|
+
/* Removed use of void pointers for specific */
|
43
|
+
/* data structures. */
|
44
|
+
/* */
|
45
|
+
/*************************************************************/
|
46
|
+
|
47
|
+
#include <stdio.h>
|
48
|
+
#include <stdlib.h>
|
49
|
+
|
50
|
+
#include "setup.h"
|
51
|
+
|
52
|
+
#if DEFRULE_CONSTRUCT
|
53
|
+
|
54
|
+
#include "agenda.h"
|
55
|
+
#include "argacces.h"
|
56
|
+
#include "constant.h"
|
57
|
+
#include "drive.h"
|
58
|
+
#include "engine.h"
|
59
|
+
#include "envrnmnt.h"
|
60
|
+
#include "lgcldpnd.h"
|
61
|
+
#include "match.h"
|
62
|
+
#include "memalloc.h"
|
63
|
+
#include "network.h"
|
64
|
+
#include "prntutil.h"
|
65
|
+
#include "reteutil.h"
|
66
|
+
#include "router.h"
|
67
|
+
#include "symbol.h"
|
68
|
+
|
69
|
+
#include "retract.h"
|
70
|
+
|
71
|
+
/***************************************/
|
72
|
+
/* LOCAL INTERNAL FUNCTION DEFINITIONS */
|
73
|
+
/***************************************/
|
74
|
+
|
75
|
+
static void ReturnMarkers(Environment *,struct multifieldMarker *);
|
76
|
+
static bool FindNextConflictingMatch(Environment *,struct partialMatch *,
|
77
|
+
struct partialMatch *,
|
78
|
+
struct joinNode *,struct partialMatch *,int);
|
79
|
+
static bool PartialMatchDefunct(Environment *,struct partialMatch *);
|
80
|
+
static void NegEntryRetractAlpha(Environment *,struct partialMatch *,int);
|
81
|
+
static void NegEntryRetractBeta(Environment *,struct joinNode *,struct partialMatch *,
|
82
|
+
struct partialMatch *,int);
|
83
|
+
|
84
|
+
/************************************************************/
|
85
|
+
/* NetworkRetract: Retracts a data entity (such as a fact */
|
86
|
+
/* or instance) from the pattern and join networks given */
|
87
|
+
/* a pointer to the list of patterns which the data */
|
88
|
+
/* entity matched. */
|
89
|
+
/************************************************************/
|
90
|
+
void NetworkRetract(
|
91
|
+
Environment *theEnv,
|
92
|
+
struct patternMatch *listOfMatchedPatterns)
|
93
|
+
{
|
94
|
+
struct patternMatch *tempMatch, *nextMatch;
|
95
|
+
|
96
|
+
tempMatch = listOfMatchedPatterns;
|
97
|
+
while (tempMatch != NULL)
|
98
|
+
{
|
99
|
+
nextMatch = tempMatch->next;
|
100
|
+
|
101
|
+
tempMatch->theMatch->deleting = true;
|
102
|
+
|
103
|
+
if (tempMatch->theMatch->children != NULL)
|
104
|
+
{ PosEntryRetractAlpha(theEnv,tempMatch->theMatch,NETWORK_RETRACT); }
|
105
|
+
|
106
|
+
if (tempMatch->theMatch->blockList != NULL)
|
107
|
+
{ NegEntryRetractAlpha(theEnv,tempMatch->theMatch,NETWORK_RETRACT); }
|
108
|
+
|
109
|
+
/*===================================================*/
|
110
|
+
/* Remove from the alpha memory of the pattern node. */
|
111
|
+
/*===================================================*/
|
112
|
+
|
113
|
+
RemoveAlphaMemoryMatches(theEnv,tempMatch->matchingPattern,
|
114
|
+
tempMatch->theMatch,
|
115
|
+
tempMatch->theMatch->binds[0].gm.theMatch);
|
116
|
+
|
117
|
+
rtn_struct(theEnv,patternMatch,tempMatch);
|
118
|
+
|
119
|
+
tempMatch = nextMatch;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
/*************************/
|
124
|
+
/* PosEntryRetractAlpha: */
|
125
|
+
/*************************/
|
126
|
+
void PosEntryRetractAlpha(
|
127
|
+
Environment *theEnv,
|
128
|
+
struct partialMatch *alphaMatch,
|
129
|
+
int operation)
|
130
|
+
{
|
131
|
+
struct partialMatch *betaMatch, *tempMatch;
|
132
|
+
struct joinNode *joinPtr;
|
133
|
+
|
134
|
+
betaMatch = alphaMatch->children;
|
135
|
+
while (betaMatch != NULL)
|
136
|
+
{
|
137
|
+
joinPtr = (struct joinNode *) betaMatch->owner;
|
138
|
+
|
139
|
+
if (betaMatch->children != NULL)
|
140
|
+
{ PosEntryRetractBeta(theEnv,betaMatch,betaMatch->children,operation); }
|
141
|
+
|
142
|
+
if (betaMatch->rhsMemory)
|
143
|
+
{ NegEntryRetractAlpha(theEnv,betaMatch,operation); }
|
144
|
+
|
145
|
+
/* Remove the beta match. */
|
146
|
+
|
147
|
+
if ((joinPtr->ruleToActivate != NULL) ?
|
148
|
+
(betaMatch->marker != NULL) : false)
|
149
|
+
{ RemoveActivation(theEnv,(struct activation *) betaMatch->marker,true,true); }
|
150
|
+
|
151
|
+
tempMatch = betaMatch->nextRightChild;
|
152
|
+
|
153
|
+
if (betaMatch->rhsMemory)
|
154
|
+
{ UnlinkBetaPMFromNodeAndLineage(theEnv,joinPtr,betaMatch,RHS); }
|
155
|
+
else
|
156
|
+
{ UnlinkBetaPMFromNodeAndLineage(theEnv,joinPtr,betaMatch,LHS); }
|
157
|
+
|
158
|
+
DeletePartialMatches(theEnv,betaMatch);
|
159
|
+
|
160
|
+
betaMatch = tempMatch;
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
/*************************/
|
165
|
+
/* NegEntryRetractAlpha: */
|
166
|
+
/*************************/
|
167
|
+
static void NegEntryRetractAlpha(
|
168
|
+
Environment *theEnv,
|
169
|
+
struct partialMatch *alphaMatch,
|
170
|
+
int operation)
|
171
|
+
{
|
172
|
+
struct partialMatch *betaMatch;
|
173
|
+
struct joinNode *joinPtr;
|
174
|
+
|
175
|
+
betaMatch = alphaMatch->blockList;
|
176
|
+
while (betaMatch != NULL)
|
177
|
+
{
|
178
|
+
joinPtr = (struct joinNode *) betaMatch->owner;
|
179
|
+
|
180
|
+
if ((! joinPtr->patternIsNegated) &&
|
181
|
+
(! joinPtr->patternIsExists) &&
|
182
|
+
(! joinPtr->joinFromTheRight))
|
183
|
+
{
|
184
|
+
SystemError(theEnv,"RETRACT",117);
|
185
|
+
betaMatch = betaMatch->nextBlocked;
|
186
|
+
continue;
|
187
|
+
}
|
188
|
+
|
189
|
+
NegEntryRetractBeta(theEnv,joinPtr,alphaMatch,betaMatch,operation);
|
190
|
+
betaMatch = alphaMatch->blockList;
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
/************************/
|
195
|
+
/* NegEntryRetractBeta: */
|
196
|
+
/************************/
|
197
|
+
static void NegEntryRetractBeta(
|
198
|
+
Environment *theEnv,
|
199
|
+
struct joinNode *joinPtr,
|
200
|
+
struct partialMatch *alphaMatch,
|
201
|
+
struct partialMatch *betaMatch,
|
202
|
+
int operation)
|
203
|
+
{
|
204
|
+
/*======================================================*/
|
205
|
+
/* Try to find another RHS partial match which prevents */
|
206
|
+
/* the LHS partial match from being satisifed. */
|
207
|
+
/*======================================================*/
|
208
|
+
|
209
|
+
RemoveBlockedLink(betaMatch);
|
210
|
+
|
211
|
+
if (FindNextConflictingMatch(theEnv,betaMatch,alphaMatch->nextInMemory,joinPtr,alphaMatch,operation))
|
212
|
+
{ return; }
|
213
|
+
else if (joinPtr->patternIsExists)
|
214
|
+
{
|
215
|
+
if (betaMatch->children != NULL)
|
216
|
+
{ PosEntryRetractBeta(theEnv,betaMatch,betaMatch->children,operation); }
|
217
|
+
return;
|
218
|
+
}
|
219
|
+
else if (joinPtr->firstJoin && (joinPtr->patternIsNegated || joinPtr->joinFromTheRight) && (! joinPtr->patternIsExists))
|
220
|
+
{
|
221
|
+
if (joinPtr->secondaryNetworkTest != NULL)
|
222
|
+
{
|
223
|
+
if (EvaluateSecondaryNetworkTest(theEnv,betaMatch,joinPtr) == false)
|
224
|
+
{ return; }
|
225
|
+
}
|
226
|
+
|
227
|
+
EPMDrive(theEnv,betaMatch,joinPtr,operation);
|
228
|
+
|
229
|
+
return;
|
230
|
+
}
|
231
|
+
|
232
|
+
if (joinPtr->secondaryNetworkTest != NULL)
|
233
|
+
{
|
234
|
+
if (EvaluateSecondaryNetworkTest(theEnv,betaMatch,joinPtr) == false)
|
235
|
+
{ return; }
|
236
|
+
}
|
237
|
+
|
238
|
+
/*=========================================================*/
|
239
|
+
/* If the LHS partial match now has no RHS partial matches */
|
240
|
+
/* that conflict with it, then it satisfies the conditions */
|
241
|
+
/* of the RHS not CE. Create a partial match and send it */
|
242
|
+
/* to the joins below. */
|
243
|
+
/*=========================================================*/
|
244
|
+
|
245
|
+
/*===============================*/
|
246
|
+
/* Create the new partial match. */
|
247
|
+
/*===============================*/
|
248
|
+
|
249
|
+
if ((operation == NETWORK_RETRACT) && PartialMatchWillBeDeleted(theEnv,betaMatch))
|
250
|
+
{ return; }
|
251
|
+
|
252
|
+
PPDrive(theEnv,betaMatch,NULL,joinPtr,operation);
|
253
|
+
}
|
254
|
+
|
255
|
+
/************************/
|
256
|
+
/* PosEntryRetractBeta: */
|
257
|
+
/************************/
|
258
|
+
void PosEntryRetractBeta(
|
259
|
+
Environment *theEnv,
|
260
|
+
struct partialMatch *parentMatch,
|
261
|
+
struct partialMatch *betaMatch,
|
262
|
+
int operation)
|
263
|
+
{
|
264
|
+
struct partialMatch *tempMatch;
|
265
|
+
|
266
|
+
while (betaMatch != NULL)
|
267
|
+
{
|
268
|
+
if (betaMatch->children != NULL)
|
269
|
+
{
|
270
|
+
betaMatch = betaMatch->children;
|
271
|
+
continue;
|
272
|
+
}
|
273
|
+
|
274
|
+
if (betaMatch->nextLeftChild != NULL)
|
275
|
+
{ tempMatch = betaMatch->nextLeftChild; }
|
276
|
+
else
|
277
|
+
{
|
278
|
+
tempMatch = betaMatch->leftParent;
|
279
|
+
betaMatch->leftParent->children = NULL;
|
280
|
+
}
|
281
|
+
|
282
|
+
if (betaMatch->blockList != NULL)
|
283
|
+
{ NegEntryRetractAlpha(theEnv,betaMatch,operation); }
|
284
|
+
else if ((((struct joinNode *) betaMatch->owner)->ruleToActivate != NULL) ?
|
285
|
+
(betaMatch->marker != NULL) : false)
|
286
|
+
{ RemoveActivation(theEnv,(struct activation *) betaMatch->marker,true,true); }
|
287
|
+
|
288
|
+
if (betaMatch->rhsMemory)
|
289
|
+
{ UnlinkNonLeftLineage(theEnv,(struct joinNode *) betaMatch->owner,betaMatch,RHS); }
|
290
|
+
else
|
291
|
+
{ UnlinkNonLeftLineage(theEnv,(struct joinNode *) betaMatch->owner,betaMatch,LHS); }
|
292
|
+
|
293
|
+
if (betaMatch->dependents != NULL) RemoveLogicalSupport(theEnv,betaMatch);
|
294
|
+
ReturnPartialMatch(theEnv,betaMatch);
|
295
|
+
|
296
|
+
if (tempMatch == parentMatch) return;
|
297
|
+
betaMatch = tempMatch;
|
298
|
+
}
|
299
|
+
}
|
300
|
+
|
301
|
+
/******************************************************************/
|
302
|
+
/* FindNextConflictingMatch: Finds the next conflicting partial */
|
303
|
+
/* match in the right memory of a join that prevents a partial */
|
304
|
+
/* match in the beta memory of the join from being satisfied. */
|
305
|
+
/******************************************************************/
|
306
|
+
static bool FindNextConflictingMatch(
|
307
|
+
Environment *theEnv,
|
308
|
+
struct partialMatch *theBind,
|
309
|
+
struct partialMatch *possibleConflicts,
|
310
|
+
struct joinNode *theJoin,
|
311
|
+
struct partialMatch *skipMatch,
|
312
|
+
int operation)
|
313
|
+
{
|
314
|
+
bool result, restore = false;
|
315
|
+
struct partialMatch *oldLHSBinds = NULL;
|
316
|
+
struct partialMatch *oldRHSBinds = NULL;
|
317
|
+
struct joinNode *oldJoin = NULL;
|
318
|
+
|
319
|
+
/*====================================*/
|
320
|
+
/* Check each of the possible partial */
|
321
|
+
/* matches which could conflict. */
|
322
|
+
/*====================================*/
|
323
|
+
|
324
|
+
#if DEVELOPER
|
325
|
+
if (possibleConflicts != NULL)
|
326
|
+
{ EngineData(theEnv)->leftToRightLoops++; }
|
327
|
+
#endif
|
328
|
+
/*====================================*/
|
329
|
+
/* Set up the evaluation environment. */
|
330
|
+
/*====================================*/
|
331
|
+
|
332
|
+
if (possibleConflicts != NULL)
|
333
|
+
{
|
334
|
+
oldLHSBinds = EngineData(theEnv)->GlobalLHSBinds;
|
335
|
+
oldRHSBinds = EngineData(theEnv)->GlobalRHSBinds;
|
336
|
+
oldJoin = EngineData(theEnv)->GlobalJoin;
|
337
|
+
EngineData(theEnv)->GlobalLHSBinds = theBind;
|
338
|
+
EngineData(theEnv)->GlobalJoin = theJoin;
|
339
|
+
restore = true;
|
340
|
+
}
|
341
|
+
|
342
|
+
for (;
|
343
|
+
possibleConflicts != NULL;
|
344
|
+
possibleConflicts = possibleConflicts->nextInMemory)
|
345
|
+
{
|
346
|
+
theJoin->memoryCompares++;
|
347
|
+
|
348
|
+
/*=====================================*/
|
349
|
+
/* Initially indicate that the partial */
|
350
|
+
/* match doesn't conflict. */
|
351
|
+
/*=====================================*/
|
352
|
+
|
353
|
+
result = false;
|
354
|
+
|
355
|
+
if (skipMatch == possibleConflicts)
|
356
|
+
{ /* Do Nothing */ }
|
357
|
+
|
358
|
+
/*======================================================*/
|
359
|
+
/* 6.05 Bug Fix. It is possible that a pattern entity */
|
360
|
+
/* (e.g. instance) in a partial match is 'out of date' */
|
361
|
+
/* with respect to the lazy evaluation scheme use by */
|
362
|
+
/* negated patterns. In other words, the object may */
|
363
|
+
/* have changed since it was last pushed through the */
|
364
|
+
/* network, and thus the partial match may be invalid. */
|
365
|
+
/* If so, the partial match must be ignored here. */
|
366
|
+
/*======================================================*/
|
367
|
+
|
368
|
+
else if (PartialMatchDefunct(theEnv,possibleConflicts))
|
369
|
+
{ /* Do Nothing */ }
|
370
|
+
|
371
|
+
else if ((operation == NETWORK_RETRACT) && PartialMatchWillBeDeleted(theEnv,possibleConflicts))
|
372
|
+
{ /* Do Nothing */ }
|
373
|
+
|
374
|
+
/*================================================*/
|
375
|
+
/* If the join doesn't have a network expression */
|
376
|
+
/* to be evaluated, then partial match conflicts. */
|
377
|
+
/*================================================*/
|
378
|
+
|
379
|
+
else if (theJoin->networkTest == NULL)
|
380
|
+
{ result = true; }
|
381
|
+
|
382
|
+
/*=================================================*/
|
383
|
+
/* Otherwise, if the join has a network expression */
|
384
|
+
/* to evaluate, then evaluate it. */
|
385
|
+
/*=================================================*/
|
386
|
+
|
387
|
+
else
|
388
|
+
{
|
389
|
+
#if DEVELOPER
|
390
|
+
if (theJoin->networkTest)
|
391
|
+
{
|
392
|
+
EngineData(theEnv)->leftToRightComparisons++;
|
393
|
+
EngineData(theEnv)->findNextConflictingComparisons++;
|
394
|
+
}
|
395
|
+
#endif
|
396
|
+
EngineData(theEnv)->GlobalRHSBinds = possibleConflicts;
|
397
|
+
|
398
|
+
result = EvaluateJoinExpression(theEnv,theJoin->networkTest,theJoin);
|
399
|
+
if (EvaluationData(theEnv)->EvaluationError)
|
400
|
+
{
|
401
|
+
result = true;
|
402
|
+
EvaluationData(theEnv)->EvaluationError = false;
|
403
|
+
}
|
404
|
+
|
405
|
+
#if DEVELOPER
|
406
|
+
if (result != false)
|
407
|
+
{ EngineData(theEnv)->leftToRightSucceeds++; }
|
408
|
+
#endif
|
409
|
+
}
|
410
|
+
|
411
|
+
/*==============================================*/
|
412
|
+
/* If the network expression evaluated to true, */
|
413
|
+
/* then partial match being examined conflicts. */
|
414
|
+
/* Point the beta memory partial match to the */
|
415
|
+
/* conflicting partial match and return true to */
|
416
|
+
/* indicate a conflict was found. */
|
417
|
+
/*==============================================*/
|
418
|
+
|
419
|
+
if (result != false)
|
420
|
+
{
|
421
|
+
AddBlockedLink(theBind,possibleConflicts);
|
422
|
+
EngineData(theEnv)->GlobalLHSBinds = oldLHSBinds;
|
423
|
+
EngineData(theEnv)->GlobalRHSBinds = oldRHSBinds;
|
424
|
+
EngineData(theEnv)->GlobalJoin = oldJoin;
|
425
|
+
return true;
|
426
|
+
}
|
427
|
+
}
|
428
|
+
|
429
|
+
if (restore)
|
430
|
+
{
|
431
|
+
EngineData(theEnv)->GlobalLHSBinds = oldLHSBinds;
|
432
|
+
EngineData(theEnv)->GlobalRHSBinds = oldRHSBinds;
|
433
|
+
EngineData(theEnv)->GlobalJoin = oldJoin;
|
434
|
+
}
|
435
|
+
|
436
|
+
/*========================*/
|
437
|
+
/* No conflict was found. */
|
438
|
+
/*========================*/
|
439
|
+
|
440
|
+
return false;
|
441
|
+
}
|
442
|
+
|
443
|
+
/***********************************************************/
|
444
|
+
/* PartialMatchDefunct: Determines if any pattern entities */
|
445
|
+
/* contained within the partial match have changed since */
|
446
|
+
/* this partial match was generated. Assumes counterf is */
|
447
|
+
/* false. */
|
448
|
+
/***********************************************************/
|
449
|
+
static bool PartialMatchDefunct(
|
450
|
+
Environment *theEnv,
|
451
|
+
struct partialMatch *thePM)
|
452
|
+
{
|
453
|
+
unsigned short i;
|
454
|
+
struct patternEntity * thePE;
|
455
|
+
|
456
|
+
if (thePM->deleting) return true;
|
457
|
+
|
458
|
+
for (i = 0 ; i < thePM->bcount ; i++)
|
459
|
+
{
|
460
|
+
if (thePM->binds[i].gm.theMatch == NULL) continue;
|
461
|
+
thePE = thePM->binds[i].gm.theMatch->matchingItem;
|
462
|
+
if (thePE && thePE->theInfo->synchronized &&
|
463
|
+
!(*thePE->theInfo->synchronized)(theEnv,thePE))
|
464
|
+
return true;
|
465
|
+
}
|
466
|
+
return false;
|
467
|
+
}
|
468
|
+
|
469
|
+
/*****************************************************************/
|
470
|
+
/* PartialMatchWillBeDeleted: Determines if any pattern entities */
|
471
|
+
/* contained within the partial match were deleted as part of */
|
472
|
+
/* a retraction/deletion. When rules have multiple patterns */
|
473
|
+
/* that can be matched by the same fact it's possible that a */
|
474
|
+
/* partial match encountered in the join network has not yet */
|
475
|
+
/* deleted and so should not be considered as valid. */
|
476
|
+
/*****************************************************************/
|
477
|
+
bool PartialMatchWillBeDeleted(
|
478
|
+
Environment *theEnv,
|
479
|
+
struct partialMatch *thePM)
|
480
|
+
{
|
481
|
+
unsigned short i;
|
482
|
+
struct patternEntity * thePE;
|
483
|
+
|
484
|
+
if (thePM == NULL) return false;
|
485
|
+
|
486
|
+
if (thePM->deleting) return true;
|
487
|
+
|
488
|
+
for (i = 0 ; i < thePM->bcount ; i++)
|
489
|
+
{
|
490
|
+
if (thePM->binds[i].gm.theMatch == NULL) continue;
|
491
|
+
thePE = thePM->binds[i].gm.theMatch->matchingItem;
|
492
|
+
if (thePE && thePE->theInfo->isDeleted &&
|
493
|
+
(*thePE->theInfo->isDeleted)(theEnv,thePE))
|
494
|
+
return true;
|
495
|
+
}
|
496
|
+
|
497
|
+
return false;
|
498
|
+
}
|
499
|
+
|
500
|
+
/***************************************************/
|
501
|
+
/* DeletePartialMatches: Returns a list of partial */
|
502
|
+
/* matches to the pool of free memory. */
|
503
|
+
/***************************************************/
|
504
|
+
void DeletePartialMatches(
|
505
|
+
Environment *theEnv,
|
506
|
+
struct partialMatch *listOfPMs)
|
507
|
+
{
|
508
|
+
struct partialMatch *nextPM;
|
509
|
+
|
510
|
+
while (listOfPMs != NULL)
|
511
|
+
{
|
512
|
+
/*============================================*/
|
513
|
+
/* Remember the next partial match to delete. */
|
514
|
+
/*============================================*/
|
515
|
+
|
516
|
+
nextPM = listOfPMs->nextInMemory;
|
517
|
+
|
518
|
+
/*================================================*/
|
519
|
+
/* Remove the links between the partial match and */
|
520
|
+
/* any data entities that it is attached to as a */
|
521
|
+
/* result of a logical CE. */
|
522
|
+
/*================================================*/
|
523
|
+
|
524
|
+
if (listOfPMs->dependents != NULL) RemoveLogicalSupport(theEnv,listOfPMs);
|
525
|
+
|
526
|
+
/*==========================================================*/
|
527
|
+
/* If the partial match is being deleted from a beta memory */
|
528
|
+
/* and the partial match isn't associated with a satisfied */
|
529
|
+
/* not CE, then it can be immediately returned to the pool */
|
530
|
+
/* of free memory. Otherwise, it's could be in use (either */
|
531
|
+
/* to retrieve variables from the LHS or by the activation */
|
532
|
+
/* of the rule). Since a not CE creates a "pseudo" data */
|
533
|
+
/* entity, the beta partial match which stores this pseudo */
|
534
|
+
/* data entity can not be deleted immediately (for the same */
|
535
|
+
/* reason an alpha memory partial match can't be deleted */
|
536
|
+
/* immediately). */
|
537
|
+
/*==========================================================*/
|
538
|
+
|
539
|
+
ReturnPartialMatch(theEnv,listOfPMs);
|
540
|
+
|
541
|
+
/*====================================*/
|
542
|
+
/* Move on to the next partial match. */
|
543
|
+
/*====================================*/
|
544
|
+
|
545
|
+
listOfPMs = nextPM;
|
546
|
+
}
|
547
|
+
}
|
548
|
+
|
549
|
+
/**************************************************************/
|
550
|
+
/* ReturnPartialMatch: Returns the data structures associated */
|
551
|
+
/* with a partial match to the pool of free memory. */
|
552
|
+
/**************************************************************/
|
553
|
+
void ReturnPartialMatch(
|
554
|
+
Environment *theEnv,
|
555
|
+
struct partialMatch *waste)
|
556
|
+
{
|
557
|
+
/*==============================================*/
|
558
|
+
/* If the partial match is in use, then put it */
|
559
|
+
/* on a garbage list to be processed later when */
|
560
|
+
/* the partial match is not in use. */
|
561
|
+
/*==============================================*/
|
562
|
+
|
563
|
+
if (waste->busy)
|
564
|
+
{
|
565
|
+
waste->nextInMemory = EngineData(theEnv)->GarbagePartialMatches;
|
566
|
+
EngineData(theEnv)->GarbagePartialMatches = waste;
|
567
|
+
return;
|
568
|
+
}
|
569
|
+
|
570
|
+
/*======================================================*/
|
571
|
+
/* If we're dealing with an alpha memory partial match, */
|
572
|
+
/* then return the multifield markers associated with */
|
573
|
+
/* the partial match (if any) along with the alphaMatch */
|
574
|
+
/* data structure. */
|
575
|
+
/*======================================================*/
|
576
|
+
|
577
|
+
if (waste->betaMemory == false)
|
578
|
+
{
|
579
|
+
if (waste->binds[0].gm.theMatch->markers != NULL)
|
580
|
+
{ ReturnMarkers(theEnv,waste->binds[0].gm.theMatch->markers); }
|
581
|
+
rm(theEnv,waste->binds[0].gm.theMatch,sizeof(struct alphaMatch));
|
582
|
+
}
|
583
|
+
|
584
|
+
/*=================================================*/
|
585
|
+
/* Remove any links between the partial match and */
|
586
|
+
/* a data entity that were created with the use of */
|
587
|
+
/* the logical CE. */
|
588
|
+
/*=================================================*/
|
589
|
+
|
590
|
+
if (waste->dependents != NULL) RemovePMDependencies(theEnv,waste);
|
591
|
+
|
592
|
+
/*======================================================*/
|
593
|
+
/* Return the partial match to the pool of free memory. */
|
594
|
+
/*======================================================*/
|
595
|
+
|
596
|
+
rtn_var_struct(theEnv,partialMatch,sizeof(struct genericMatch *) *
|
597
|
+
(waste->bcount - 1),
|
598
|
+
waste);
|
599
|
+
}
|
600
|
+
|
601
|
+
/***************************************************************/
|
602
|
+
/* DestroyPartialMatch: Returns the data structures associated */
|
603
|
+
/* with a partial match to the pool of free memory. */
|
604
|
+
/***************************************************************/
|
605
|
+
void DestroyPartialMatch(
|
606
|
+
Environment *theEnv,
|
607
|
+
struct partialMatch *waste)
|
608
|
+
{
|
609
|
+
/*======================================================*/
|
610
|
+
/* If we're dealing with an alpha memory partial match, */
|
611
|
+
/* then return the multifield markers associated with */
|
612
|
+
/* the partial match (if any) along with the alphaMatch */
|
613
|
+
/* data structure. */
|
614
|
+
/*======================================================*/
|
615
|
+
|
616
|
+
if (waste->betaMemory == false)
|
617
|
+
{
|
618
|
+
if (waste->binds[0].gm.theMatch->markers != NULL)
|
619
|
+
{ ReturnMarkers(theEnv,waste->binds[0].gm.theMatch->markers); }
|
620
|
+
rm(theEnv,waste->binds[0].gm.theMatch,sizeof(struct alphaMatch));
|
621
|
+
}
|
622
|
+
|
623
|
+
/*=================================================*/
|
624
|
+
/* Remove any links between the partial match and */
|
625
|
+
/* a data entity that were created with the use of */
|
626
|
+
/* the logical CE. */
|
627
|
+
/*=================================================*/
|
628
|
+
|
629
|
+
if (waste->dependents != NULL) DestroyPMDependencies(theEnv,waste);
|
630
|
+
|
631
|
+
/*======================================================*/
|
632
|
+
/* Return the partial match to the pool of free memory. */
|
633
|
+
/*======================================================*/
|
634
|
+
|
635
|
+
rtn_var_struct(theEnv,partialMatch,sizeof(struct genericMatch *) *
|
636
|
+
(waste->bcount - 1),
|
637
|
+
waste);
|
638
|
+
}
|
639
|
+
|
640
|
+
/******************************************************/
|
641
|
+
/* ReturnMarkers: Returns a linked list of multifield */
|
642
|
+
/* markers associated with a data entity matching a */
|
643
|
+
/* pattern to the pool of free memory. */
|
644
|
+
/******************************************************/
|
645
|
+
static void ReturnMarkers(
|
646
|
+
Environment *theEnv,
|
647
|
+
struct multifieldMarker *waste)
|
648
|
+
{
|
649
|
+
struct multifieldMarker *temp;
|
650
|
+
|
651
|
+
while (waste != NULL)
|
652
|
+
{
|
653
|
+
temp = waste->next;
|
654
|
+
rtn_struct(theEnv,multifieldMarker,waste);
|
655
|
+
waste = temp;
|
656
|
+
}
|
657
|
+
}
|
658
|
+
|
659
|
+
/*************************************************************/
|
660
|
+
/* FlushGarbagePartialMatches: Returns partial matches and */
|
661
|
+
/* associated structures that were removed as part of a */
|
662
|
+
/* retraction. It is necessary to postpone returning these */
|
663
|
+
/* structures to memory because RHS actions retrieve their */
|
664
|
+
/* variable bindings directly from the fact and instance */
|
665
|
+
/* data structures through the alpha memory bindings. */
|
666
|
+
/*************************************************************/
|
667
|
+
void FlushGarbagePartialMatches(
|
668
|
+
Environment *theEnv)
|
669
|
+
{
|
670
|
+
struct partialMatch *pmPtr;
|
671
|
+
struct alphaMatch *amPtr;
|
672
|
+
|
673
|
+
/*===================================================*/
|
674
|
+
/* Return the garbage partial matches collected from */
|
675
|
+
/* the alpha memories of the pattern networks. */
|
676
|
+
/*===================================================*/
|
677
|
+
|
678
|
+
while (EngineData(theEnv)->GarbageAlphaMatches != NULL)
|
679
|
+
{
|
680
|
+
amPtr = EngineData(theEnv)->GarbageAlphaMatches->next;
|
681
|
+
rtn_struct(theEnv,alphaMatch,EngineData(theEnv)->GarbageAlphaMatches);
|
682
|
+
EngineData(theEnv)->GarbageAlphaMatches = amPtr;
|
683
|
+
}
|
684
|
+
|
685
|
+
/*==============================================*/
|
686
|
+
/* Return the garbage partial matches collected */
|
687
|
+
/* from the beta memories of the join networks. */
|
688
|
+
/*==============================================*/
|
689
|
+
|
690
|
+
while (EngineData(theEnv)->GarbagePartialMatches != NULL)
|
691
|
+
{
|
692
|
+
/*=====================================================*/
|
693
|
+
/* Remember the next garbage partial match to process. */
|
694
|
+
/*=====================================================*/
|
695
|
+
|
696
|
+
pmPtr = EngineData(theEnv)->GarbagePartialMatches->nextInMemory;
|
697
|
+
|
698
|
+
/*============================================*/
|
699
|
+
/* Dispose of the garbage partial match being */
|
700
|
+
/* examined and move on to the next one. */
|
701
|
+
/*============================================*/
|
702
|
+
|
703
|
+
EngineData(theEnv)->GarbagePartialMatches->busy = false;
|
704
|
+
ReturnPartialMatch(theEnv,EngineData(theEnv)->GarbagePartialMatches);
|
705
|
+
EngineData(theEnv)->GarbagePartialMatches = pmPtr;
|
706
|
+
}
|
707
|
+
}
|
708
|
+
|
709
|
+
#endif /* DEFRULE_CONSTRUCT */
|
710
|
+
|