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,1330 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.41 07/27/21 */
|
5
|
+
/* */
|
6
|
+
/* INFERENCE ENGINE OBJECT ACCESS ROUTINES MODULE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: RETE Network Interface for Objects */
|
11
|
+
/* */
|
12
|
+
/* Principal Programmer(s): */
|
13
|
+
/* Brian L. Dantes */
|
14
|
+
/* */
|
15
|
+
/* Contributing Programmer(s): */
|
16
|
+
/* */
|
17
|
+
/* Revision History: */
|
18
|
+
/* */
|
19
|
+
/* 6.23: Correction for FalseSymbol/TrueSymbol. DR0859 */
|
20
|
+
/* */
|
21
|
+
/* 6.24: Converted INSTANCE_PATTERN_MATCHING to */
|
22
|
+
/* DEFRULE_CONSTRUCT. */
|
23
|
+
/* */
|
24
|
+
/* Renamed BOOLEAN macro type to intBool. */
|
25
|
+
/* */
|
26
|
+
/* 6.30: Support for long long integers. */
|
27
|
+
/* */
|
28
|
+
/* Removed conditional code for unsupported */
|
29
|
+
/* compilers/operating systems (IBM_MCW, */
|
30
|
+
/* MAC_MCW, and IBM_TBC). */
|
31
|
+
/* */
|
32
|
+
/* Added support for hashed alpha memories. */
|
33
|
+
/* */
|
34
|
+
/* Added const qualifiers to remove C++ */
|
35
|
+
/* deprecation warnings. */
|
36
|
+
/* */
|
37
|
+
/* 6.32: Fixed issue with optimized join network */
|
38
|
+
/* expression evaluation. */
|
39
|
+
/* */
|
40
|
+
/* 6.40: Pragma once and other inclusion changes. */
|
41
|
+
/* */
|
42
|
+
/* Added support for booleans with <stdbool.h>. */
|
43
|
+
/* */
|
44
|
+
/* Removed use of void pointers for specific */
|
45
|
+
/* data structures. */
|
46
|
+
/* */
|
47
|
+
/* UDF redesign. */
|
48
|
+
/* */
|
49
|
+
/*************************************************************/
|
50
|
+
/* =========================================
|
51
|
+
*****************************************
|
52
|
+
EXTERNAL DEFINITIONS
|
53
|
+
=========================================
|
54
|
+
***************************************** */
|
55
|
+
#include "setup.h"
|
56
|
+
|
57
|
+
#if DEFRULE_CONSTRUCT && OBJECT_SYSTEM
|
58
|
+
|
59
|
+
#include <stdio.h>
|
60
|
+
#include <string.h>
|
61
|
+
|
62
|
+
#include "classcom.h"
|
63
|
+
#include "classfun.h"
|
64
|
+
|
65
|
+
#if DEVELOPER
|
66
|
+
#include "exprnops.h"
|
67
|
+
#endif
|
68
|
+
#if BLOAD || BLOAD_AND_BSAVE
|
69
|
+
#include "bload.h"
|
70
|
+
#endif
|
71
|
+
#include "constant.h"
|
72
|
+
#include "drive.h"
|
73
|
+
#include "engine.h"
|
74
|
+
#include "envrnmnt.h"
|
75
|
+
#include "memalloc.h"
|
76
|
+
#include "multifld.h"
|
77
|
+
#include "objrtmch.h"
|
78
|
+
#include "prntutil.h"
|
79
|
+
#include "reteutil.h"
|
80
|
+
#include "router.h"
|
81
|
+
|
82
|
+
#include "objrtfnx.h"
|
83
|
+
|
84
|
+
/* =========================================
|
85
|
+
*****************************************
|
86
|
+
MACROS AND TYPES
|
87
|
+
=========================================
|
88
|
+
***************************************** */
|
89
|
+
|
90
|
+
#define GetInsSlot(ins,si) ins->slotAddresses[ins->cls->slotNameMap[si]-1]
|
91
|
+
|
92
|
+
/***************************************/
|
93
|
+
/* LOCAL INTERNAL FUNCTION DEFINITIONS */
|
94
|
+
/***************************************/
|
95
|
+
|
96
|
+
static void PrintObjectGetVarJN1(Environment *,const char *,void *);
|
97
|
+
static bool ObjectGetVarJNFunction1(Environment *,void *,UDFValue *);
|
98
|
+
static void PrintObjectGetVarJN2(Environment *,const char *,void *);
|
99
|
+
static bool ObjectGetVarJNFunction2(Environment *,void *,UDFValue *);
|
100
|
+
static void PrintObjectGetVarPN1(Environment *,const char *,void *);
|
101
|
+
static bool ObjectGetVarPNFunction1(Environment *,void *,UDFValue *);
|
102
|
+
static void PrintObjectGetVarPN2(Environment *,const char *,void *);
|
103
|
+
static bool ObjectGetVarPNFunction2(Environment *,void *,UDFValue *);
|
104
|
+
static void PrintObjectCmpConstant(Environment *,const char *,void *);
|
105
|
+
static void PrintSlotLengthTest(Environment *,const char *,void *);
|
106
|
+
static bool SlotLengthTestFunction(Environment *,void *,UDFValue *);
|
107
|
+
static void PrintPNSimpleCompareFunction1(Environment *,const char *,void *);
|
108
|
+
static bool PNSimpleCompareFunction1(Environment *,void *,UDFValue *);
|
109
|
+
static void PrintPNSimpleCompareFunction2(Environment *,const char *,void *);
|
110
|
+
static bool PNSimpleCompareFunction2(Environment *,void *,UDFValue *);
|
111
|
+
static void PrintPNSimpleCompareFunction3(Environment *,const char *,void *);
|
112
|
+
static bool PNSimpleCompareFunction3(Environment *,void *,UDFValue *);
|
113
|
+
static void PrintJNSimpleCompareFunction1(Environment *,const char *,void *);
|
114
|
+
static bool JNSimpleCompareFunction1(Environment *,void *,UDFValue *);
|
115
|
+
static void PrintJNSimpleCompareFunction2(Environment *,const char *,void *);
|
116
|
+
static bool JNSimpleCompareFunction2(Environment *,void *,UDFValue *);
|
117
|
+
static void PrintJNSimpleCompareFunction3(Environment *,const char *,void *);
|
118
|
+
static bool JNSimpleCompareFunction3(Environment *,void *,UDFValue *);
|
119
|
+
static void GetPatternObjectAndMarks(Environment *,unsigned short,bool,bool,Instance **,struct multifieldMarker **);
|
120
|
+
static void GetObjectValueGeneral(Environment *,UDFValue *,Instance *,
|
121
|
+
struct multifieldMarker *,const struct ObjectMatchVar1 *);
|
122
|
+
static void GetObjectValueSimple(Environment *,UDFValue *,Instance *,const struct ObjectMatchVar2 *);
|
123
|
+
static size_t CalculateSlotField(struct multifieldMarker *,InstanceSlot *,size_t,size_t *);
|
124
|
+
static void GetInsMultiSlotField(CLIPSValue *,Instance *,unsigned,unsigned,unsigned);
|
125
|
+
static void DeallocateObjectReteData(Environment *);
|
126
|
+
static void DestroyObjectPatternNetwork(Environment *,OBJECT_PATTERN_NODE *);
|
127
|
+
static void DestroyObjectAlphaNodes(Environment *,OBJECT_ALPHA_NODE *);
|
128
|
+
|
129
|
+
/* =========================================
|
130
|
+
*****************************************
|
131
|
+
EXTERNALLY VISIBLE FUNCTIONS
|
132
|
+
=========================================
|
133
|
+
***************************************** */
|
134
|
+
|
135
|
+
/***************************************************
|
136
|
+
NAME : InstallObjectPrimitives
|
137
|
+
DESCRIPTION : Installs all the entity records
|
138
|
+
associated with object pattern
|
139
|
+
matching operations
|
140
|
+
INPUTS : None
|
141
|
+
RETURNS : Nothing useful
|
142
|
+
SIDE EFFECTS : Primitive operations installed
|
143
|
+
NOTES : None
|
144
|
+
***************************************************/
|
145
|
+
void InstallObjectPrimitives(
|
146
|
+
Environment *theEnv)
|
147
|
+
{
|
148
|
+
struct entityRecord objectGVInfo1 = { "OBJ_GET_SLOT_JNVAR1", OBJ_GET_SLOT_JNVAR1,0,1,0,
|
149
|
+
PrintObjectGetVarJN1,
|
150
|
+
PrintObjectGetVarJN1,NULL,
|
151
|
+
ObjectGetVarJNFunction1,
|
152
|
+
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
|
153
|
+
|
154
|
+
struct entityRecord objectGVInfo2 = { "OBJ_GET_SLOT_JNVAR2", OBJ_GET_SLOT_JNVAR2,0,1,0,
|
155
|
+
PrintObjectGetVarJN2,
|
156
|
+
PrintObjectGetVarJN2,NULL,
|
157
|
+
ObjectGetVarJNFunction2,
|
158
|
+
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
|
159
|
+
|
160
|
+
struct entityRecord objectGVPNInfo1 = { "OBJ_GET_SLOT_PNVAR1", OBJ_GET_SLOT_PNVAR1,0,1,0,
|
161
|
+
PrintObjectGetVarPN1,
|
162
|
+
PrintObjectGetVarPN1,NULL,
|
163
|
+
ObjectGetVarPNFunction1,
|
164
|
+
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
|
165
|
+
|
166
|
+
struct entityRecord objectGVPNInfo2 = { "OBJ_GET_SLOT_PNVAR2", OBJ_GET_SLOT_PNVAR2,0,1,0,
|
167
|
+
PrintObjectGetVarPN2,
|
168
|
+
PrintObjectGetVarPN2,NULL,
|
169
|
+
ObjectGetVarPNFunction2,
|
170
|
+
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
|
171
|
+
|
172
|
+
struct entityRecord objectCmpConstantInfo = { "OBJ_PN_CONSTANT", OBJ_PN_CONSTANT,0,1,1,
|
173
|
+
PrintObjectCmpConstant,
|
174
|
+
PrintObjectCmpConstant,NULL,
|
175
|
+
ObjectCmpConstantFunction,
|
176
|
+
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
|
177
|
+
|
178
|
+
struct entityRecord lengthTestInfo = { "OBJ_SLOT_LENGTH", OBJ_SLOT_LENGTH,0,1,0,
|
179
|
+
PrintSlotLengthTest,
|
180
|
+
PrintSlotLengthTest,NULL,
|
181
|
+
SlotLengthTestFunction,
|
182
|
+
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
|
183
|
+
|
184
|
+
struct entityRecord pNSimpleCompareInfo1 = { "OBJ_PN_CMP1", OBJ_PN_CMP1,0,1,1,
|
185
|
+
PrintPNSimpleCompareFunction1,
|
186
|
+
PrintPNSimpleCompareFunction1,NULL,
|
187
|
+
PNSimpleCompareFunction1,
|
188
|
+
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
|
189
|
+
|
190
|
+
struct entityRecord pNSimpleCompareInfo2 = { "OBJ_PN_CMP2", OBJ_PN_CMP2,0,1,1,
|
191
|
+
PrintPNSimpleCompareFunction2,
|
192
|
+
PrintPNSimpleCompareFunction2,NULL,
|
193
|
+
PNSimpleCompareFunction2,
|
194
|
+
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
|
195
|
+
|
196
|
+
struct entityRecord pNSimpleCompareInfo3 = { "OBJ_PN_CMP3", OBJ_PN_CMP3,0,1,1,
|
197
|
+
PrintPNSimpleCompareFunction3,
|
198
|
+
PrintPNSimpleCompareFunction3,NULL,
|
199
|
+
PNSimpleCompareFunction3,
|
200
|
+
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
|
201
|
+
|
202
|
+
struct entityRecord jNSimpleCompareInfo1 = { "OBJ_JN_CMP1", OBJ_JN_CMP1,0,1,1,
|
203
|
+
PrintJNSimpleCompareFunction1,
|
204
|
+
PrintJNSimpleCompareFunction1,NULL,
|
205
|
+
JNSimpleCompareFunction1,
|
206
|
+
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
|
207
|
+
|
208
|
+
struct entityRecord jNSimpleCompareInfo2 = { "OBJ_JN_CMP2", OBJ_JN_CMP2,0,1,1,
|
209
|
+
PrintJNSimpleCompareFunction2,
|
210
|
+
PrintJNSimpleCompareFunction2,NULL,
|
211
|
+
JNSimpleCompareFunction2,
|
212
|
+
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
|
213
|
+
|
214
|
+
struct entityRecord jNSimpleCompareInfo3 = { "OBJ_JN_CMP3", OBJ_JN_CMP3,0,1,1,
|
215
|
+
PrintJNSimpleCompareFunction3,
|
216
|
+
PrintJNSimpleCompareFunction3,NULL,
|
217
|
+
JNSimpleCompareFunction3,
|
218
|
+
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
|
219
|
+
|
220
|
+
AllocateEnvironmentData(theEnv,OBJECT_RETE_DATA,sizeof(struct objectReteData),DeallocateObjectReteData);
|
221
|
+
ObjectReteData(theEnv)->CurrentObjectSlotLength = 1;
|
222
|
+
|
223
|
+
memcpy(&ObjectReteData(theEnv)->ObjectGVInfo1,&objectGVInfo1,sizeof(struct entityRecord));
|
224
|
+
memcpy(&ObjectReteData(theEnv)->ObjectGVInfo2,&objectGVInfo2,sizeof(struct entityRecord));
|
225
|
+
memcpy(&ObjectReteData(theEnv)->ObjectGVPNInfo1,&objectGVPNInfo1,sizeof(struct entityRecord));
|
226
|
+
memcpy(&ObjectReteData(theEnv)->ObjectGVPNInfo2,&objectGVPNInfo2,sizeof(struct entityRecord));
|
227
|
+
memcpy(&ObjectReteData(theEnv)->ObjectCmpConstantInfo,&objectCmpConstantInfo,sizeof(struct entityRecord));
|
228
|
+
memcpy(&ObjectReteData(theEnv)->LengthTestInfo,&lengthTestInfo,sizeof(struct entityRecord));
|
229
|
+
memcpy(&ObjectReteData(theEnv)->PNSimpleCompareInfo1,&pNSimpleCompareInfo1,sizeof(struct entityRecord));
|
230
|
+
memcpy(&ObjectReteData(theEnv)->PNSimpleCompareInfo2,&pNSimpleCompareInfo2,sizeof(struct entityRecord));
|
231
|
+
memcpy(&ObjectReteData(theEnv)->PNSimpleCompareInfo3,&pNSimpleCompareInfo3,sizeof(struct entityRecord));
|
232
|
+
memcpy(&ObjectReteData(theEnv)->JNSimpleCompareInfo1,&jNSimpleCompareInfo1,sizeof(struct entityRecord));
|
233
|
+
memcpy(&ObjectReteData(theEnv)->JNSimpleCompareInfo2,&jNSimpleCompareInfo2,sizeof(struct entityRecord));
|
234
|
+
memcpy(&ObjectReteData(theEnv)->JNSimpleCompareInfo3,&jNSimpleCompareInfo3,sizeof(struct entityRecord));
|
235
|
+
|
236
|
+
InstallPrimitive(theEnv,&ObjectReteData(theEnv)->ObjectGVInfo1,OBJ_GET_SLOT_JNVAR1);
|
237
|
+
InstallPrimitive(theEnv,&ObjectReteData(theEnv)->ObjectGVInfo2,OBJ_GET_SLOT_JNVAR2);
|
238
|
+
InstallPrimitive(theEnv,&ObjectReteData(theEnv)->ObjectGVPNInfo1,OBJ_GET_SLOT_PNVAR1);
|
239
|
+
InstallPrimitive(theEnv,&ObjectReteData(theEnv)->ObjectGVPNInfo2,OBJ_GET_SLOT_PNVAR2);
|
240
|
+
InstallPrimitive(theEnv,&ObjectReteData(theEnv)->ObjectCmpConstantInfo,OBJ_PN_CONSTANT);
|
241
|
+
InstallPrimitive(theEnv,&ObjectReteData(theEnv)->LengthTestInfo,OBJ_SLOT_LENGTH);
|
242
|
+
InstallPrimitive(theEnv,&ObjectReteData(theEnv)->PNSimpleCompareInfo1,OBJ_PN_CMP1);
|
243
|
+
InstallPrimitive(theEnv,&ObjectReteData(theEnv)->PNSimpleCompareInfo2,OBJ_PN_CMP2);
|
244
|
+
InstallPrimitive(theEnv,&ObjectReteData(theEnv)->PNSimpleCompareInfo3,OBJ_PN_CMP3);
|
245
|
+
InstallPrimitive(theEnv,&ObjectReteData(theEnv)->JNSimpleCompareInfo1,OBJ_JN_CMP1);
|
246
|
+
InstallPrimitive(theEnv,&ObjectReteData(theEnv)->JNSimpleCompareInfo2,OBJ_JN_CMP2);
|
247
|
+
InstallPrimitive(theEnv,&ObjectReteData(theEnv)->JNSimpleCompareInfo3,OBJ_JN_CMP3);
|
248
|
+
}
|
249
|
+
|
250
|
+
/*****************************************************/
|
251
|
+
/* DeallocateObjectReteData: Deallocates environment */
|
252
|
+
/* data for the object rete network. */
|
253
|
+
/*****************************************************/
|
254
|
+
static void DeallocateObjectReteData(
|
255
|
+
Environment *theEnv)
|
256
|
+
{
|
257
|
+
OBJECT_PATTERN_NODE *theNetwork;
|
258
|
+
|
259
|
+
#if BLOAD || BLOAD_AND_BSAVE
|
260
|
+
if (Bloaded(theEnv)) return;
|
261
|
+
#endif
|
262
|
+
|
263
|
+
theNetwork = ObjectReteData(theEnv)->ObjectPatternNetworkPointer;
|
264
|
+
DestroyObjectPatternNetwork(theEnv,theNetwork);
|
265
|
+
}
|
266
|
+
|
267
|
+
/****************************************************************/
|
268
|
+
/* DestroyObjectPatternNetwork: Deallocates the data structures */
|
269
|
+
/* associated with the object pattern network. */
|
270
|
+
/****************************************************************/
|
271
|
+
static void DestroyObjectPatternNetwork(
|
272
|
+
Environment *theEnv,
|
273
|
+
OBJECT_PATTERN_NODE *thePattern)
|
274
|
+
{
|
275
|
+
OBJECT_PATTERN_NODE *patternPtr;
|
276
|
+
|
277
|
+
if (thePattern == NULL) return;
|
278
|
+
|
279
|
+
while (thePattern != NULL)
|
280
|
+
{
|
281
|
+
patternPtr = thePattern->rightNode;
|
282
|
+
|
283
|
+
DestroyObjectPatternNetwork(theEnv,thePattern->nextLevel);
|
284
|
+
DestroyObjectAlphaNodes(theEnv,thePattern->alphaNode);
|
285
|
+
#if ! RUN_TIME
|
286
|
+
rtn_struct(theEnv,objectPatternNode,thePattern);
|
287
|
+
#endif
|
288
|
+
thePattern = patternPtr;
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
/************************************************************/
|
293
|
+
/* DestroyObjectAlphaNodes: Deallocates the data structures */
|
294
|
+
/* associated with the object alpha nodes. */
|
295
|
+
/************************************************************/
|
296
|
+
static void DestroyObjectAlphaNodes(
|
297
|
+
Environment *theEnv,
|
298
|
+
OBJECT_ALPHA_NODE *theNode)
|
299
|
+
{
|
300
|
+
OBJECT_ALPHA_NODE *nodePtr;
|
301
|
+
|
302
|
+
if (theNode == NULL) return;
|
303
|
+
|
304
|
+
while (theNode != NULL)
|
305
|
+
{
|
306
|
+
nodePtr = theNode->nxtInGroup;
|
307
|
+
|
308
|
+
DestroyAlphaMemory(theEnv,&theNode->header,false);
|
309
|
+
|
310
|
+
#if ! RUN_TIME
|
311
|
+
rtn_struct(theEnv,objectAlphaNode,theNode);
|
312
|
+
#endif
|
313
|
+
|
314
|
+
theNode = nodePtr;
|
315
|
+
}
|
316
|
+
}
|
317
|
+
|
318
|
+
/*****************************************************
|
319
|
+
NAME : ObjectCmpConstantFunction
|
320
|
+
DESCRIPTION : Used to compare object slot values
|
321
|
+
against a constant
|
322
|
+
INPUTS : 1) The constant test bitmap
|
323
|
+
2) Data object buffer to hold result
|
324
|
+
RETURNS : True if test successful,
|
325
|
+
false otherwise
|
326
|
+
SIDE EFFECTS : Buffer set to symbol TRUE if test
|
327
|
+
successful, false otherwise
|
328
|
+
NOTES : Called directly by
|
329
|
+
EvaluatePatternExpression()
|
330
|
+
*****************************************************/
|
331
|
+
bool ObjectCmpConstantFunction(
|
332
|
+
Environment *theEnv,
|
333
|
+
void *theValue,
|
334
|
+
UDFValue *theResult)
|
335
|
+
{
|
336
|
+
const struct ObjectCmpPNConstant *hack;
|
337
|
+
UDFValue theVar;
|
338
|
+
Expression *constantExp;
|
339
|
+
bool rv;
|
340
|
+
Multifield *theSegment;
|
341
|
+
|
342
|
+
hack = (const struct ObjectCmpPNConstant *) ((CLIPSBitMap *) theValue)->contents;
|
343
|
+
if (hack->general)
|
344
|
+
{
|
345
|
+
EvaluateExpression(theEnv,GetFirstArgument(),&theVar);
|
346
|
+
constantExp = GetFirstArgument()->nextArg;
|
347
|
+
}
|
348
|
+
else
|
349
|
+
{
|
350
|
+
constantExp = GetFirstArgument();
|
351
|
+
if (ObjectReteData(theEnv)->CurrentPatternObjectSlot->type == MULTIFIELD_TYPE)
|
352
|
+
{
|
353
|
+
theSegment = ObjectReteData(theEnv)->CurrentPatternObjectSlot->multifieldValue;
|
354
|
+
if (hack->fromBeginning)
|
355
|
+
{
|
356
|
+
theVar.value = theSegment->contents[hack->offset].value;
|
357
|
+
}
|
358
|
+
else
|
359
|
+
{
|
360
|
+
theVar.value = theSegment->contents[theSegment->length -
|
361
|
+
(hack->offset + 1)].value;
|
362
|
+
}
|
363
|
+
}
|
364
|
+
else
|
365
|
+
{
|
366
|
+
theVar.value = ObjectReteData(theEnv)->CurrentPatternObjectSlot->value;
|
367
|
+
}
|
368
|
+
}
|
369
|
+
if (theVar.header->type != constantExp->type)
|
370
|
+
rv = hack->fail ? true : false;
|
371
|
+
else if (theVar.value != constantExp->value)
|
372
|
+
rv = hack->fail ? true : false;
|
373
|
+
else
|
374
|
+
rv = hack->pass ? true : false;
|
375
|
+
theResult->value = rv ? TrueSymbol(theEnv) : FalseSymbol(theEnv);
|
376
|
+
return rv;
|
377
|
+
}
|
378
|
+
|
379
|
+
/* =========================================
|
380
|
+
*****************************************
|
381
|
+
INTERNALLY VISIBLE FUNCTIONS
|
382
|
+
=========================================
|
383
|
+
***************************************** */
|
384
|
+
|
385
|
+
static void PrintObjectGetVarJN1(
|
386
|
+
Environment *theEnv,
|
387
|
+
const char *logicalName,
|
388
|
+
void *theValue)
|
389
|
+
{
|
390
|
+
#if DEVELOPER
|
391
|
+
struct ObjectMatchVar1 *hack;
|
392
|
+
|
393
|
+
hack = (struct ObjectMatchVar1 *) ((CLIPSBitMap *) theValue)->contents;
|
394
|
+
|
395
|
+
if (hack->objectAddress)
|
396
|
+
{
|
397
|
+
WriteString(theEnv,logicalName,"(obj-ptr ");
|
398
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->whichPattern);
|
399
|
+
}
|
400
|
+
else if (hack->allFields)
|
401
|
+
{
|
402
|
+
WriteString(theEnv,logicalName,"(obj-slot-contents ");
|
403
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->whichPattern);
|
404
|
+
WriteString(theEnv,logicalName," ");
|
405
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->whichSlot)->contents);
|
406
|
+
}
|
407
|
+
else
|
408
|
+
{
|
409
|
+
WriteString(theEnv,logicalName,"(obj-slot-var ");
|
410
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->whichPattern);
|
411
|
+
WriteString(theEnv,logicalName," ");
|
412
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->whichSlot)->contents);
|
413
|
+
WriteString(theEnv,logicalName," ");
|
414
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->whichField);
|
415
|
+
}
|
416
|
+
WriteString(theEnv,logicalName,")");
|
417
|
+
#else
|
418
|
+
#if MAC_XCD
|
419
|
+
#pragma unused(theEnv)
|
420
|
+
#pragma unused(logicalName)
|
421
|
+
#pragma unused(theValue)
|
422
|
+
#endif
|
423
|
+
#endif
|
424
|
+
}
|
425
|
+
|
426
|
+
static bool ObjectGetVarJNFunction1(
|
427
|
+
Environment *theEnv,
|
428
|
+
void *theValue,
|
429
|
+
UDFValue *theResult)
|
430
|
+
{
|
431
|
+
const struct ObjectMatchVar1 *hack;
|
432
|
+
Instance *theInstance;
|
433
|
+
struct multifieldMarker *theMarks;
|
434
|
+
|
435
|
+
hack = (const struct ObjectMatchVar1 *) ((CLIPSBitMap *) theValue)->contents;
|
436
|
+
GetPatternObjectAndMarks(theEnv,hack->whichPattern,hack->lhs,hack->rhs,&theInstance,&theMarks);
|
437
|
+
GetObjectValueGeneral(theEnv,theResult,theInstance,theMarks,hack);
|
438
|
+
|
439
|
+
if (theResult->value == FalseSymbol(theEnv))
|
440
|
+
{ return false; }
|
441
|
+
|
442
|
+
return true;
|
443
|
+
}
|
444
|
+
|
445
|
+
static void PrintObjectGetVarJN2(
|
446
|
+
Environment *theEnv,
|
447
|
+
const char *logicalName,
|
448
|
+
void *theValue)
|
449
|
+
{
|
450
|
+
#if DEVELOPER
|
451
|
+
struct ObjectMatchVar2 *hack;
|
452
|
+
|
453
|
+
hack = (struct ObjectMatchVar2 *) ((CLIPSBitMap *) theValue)->contents;
|
454
|
+
WriteString(theEnv,logicalName,"(obj-slot-quick-var ");
|
455
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->whichPattern);
|
456
|
+
WriteString(theEnv,logicalName," ");
|
457
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->whichSlot)->contents);
|
458
|
+
if (hack->fromBeginning)
|
459
|
+
{
|
460
|
+
WriteString(theEnv,logicalName," B");
|
461
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->beginningOffset + 1);
|
462
|
+
}
|
463
|
+
if (hack->fromEnd)
|
464
|
+
{
|
465
|
+
WriteString(theEnv,logicalName," E");
|
466
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->endOffset + 1);
|
467
|
+
}
|
468
|
+
WriteString(theEnv,logicalName,")");
|
469
|
+
#else
|
470
|
+
#if MAC_XCD
|
471
|
+
#pragma unused(theEnv)
|
472
|
+
#pragma unused(logicalName)
|
473
|
+
#pragma unused(theValue)
|
474
|
+
#endif
|
475
|
+
#endif
|
476
|
+
}
|
477
|
+
|
478
|
+
static bool ObjectGetVarJNFunction2(
|
479
|
+
Environment *theEnv,
|
480
|
+
void *theValue,
|
481
|
+
UDFValue *theResult)
|
482
|
+
{
|
483
|
+
const struct ObjectMatchVar2 *hack;
|
484
|
+
Instance *theInstance;
|
485
|
+
struct multifieldMarker *theMarks;
|
486
|
+
|
487
|
+
hack = (const struct ObjectMatchVar2 *) ((CLIPSBitMap *) theValue)->contents;
|
488
|
+
GetPatternObjectAndMarks(theEnv,hack->whichPattern,hack->lhs,hack->rhs,&theInstance,&theMarks);
|
489
|
+
GetObjectValueSimple(theEnv,theResult,theInstance,hack);
|
490
|
+
|
491
|
+
if (theResult->value == FalseSymbol(theEnv))
|
492
|
+
{ return false; }
|
493
|
+
|
494
|
+
return true;
|
495
|
+
}
|
496
|
+
|
497
|
+
static void PrintObjectGetVarPN1(
|
498
|
+
Environment *theEnv,
|
499
|
+
const char *logicalName,
|
500
|
+
void *theValue)
|
501
|
+
{
|
502
|
+
#if DEVELOPER
|
503
|
+
struct ObjectMatchVar1 *hack;
|
504
|
+
|
505
|
+
hack = (struct ObjectMatchVar1 *) ((CLIPSBitMap *) theValue)->contents;
|
506
|
+
|
507
|
+
if (hack->objectAddress)
|
508
|
+
WriteString(theEnv,logicalName,"(ptn-obj-ptr ");
|
509
|
+
else if (hack->allFields)
|
510
|
+
{
|
511
|
+
WriteString(theEnv,logicalName,"(ptn-obj-slot-contents ");
|
512
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->whichSlot)->contents);
|
513
|
+
}
|
514
|
+
else
|
515
|
+
{
|
516
|
+
WriteString(theEnv,logicalName,"(ptn-obj-slot-var ");
|
517
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->whichSlot)->contents);
|
518
|
+
WriteString(theEnv,logicalName," ");
|
519
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->whichField);
|
520
|
+
}
|
521
|
+
WriteString(theEnv,logicalName,")");
|
522
|
+
#else
|
523
|
+
#if MAC_XCD
|
524
|
+
#pragma unused(theEnv)
|
525
|
+
#pragma unused(logicalName)
|
526
|
+
#pragma unused(theValue)
|
527
|
+
#endif
|
528
|
+
#endif
|
529
|
+
}
|
530
|
+
|
531
|
+
static bool ObjectGetVarPNFunction1(
|
532
|
+
Environment *theEnv,
|
533
|
+
void *theValue,
|
534
|
+
UDFValue *theResult)
|
535
|
+
{
|
536
|
+
const struct ObjectMatchVar1 *hack;
|
537
|
+
|
538
|
+
hack = (const struct ObjectMatchVar1 *) ((CLIPSBitMap *) theValue)->contents;
|
539
|
+
GetObjectValueGeneral(theEnv,theResult,ObjectReteData(theEnv)->CurrentPatternObject,ObjectReteData(theEnv)->CurrentPatternObjectMarks,hack);
|
540
|
+
|
541
|
+
if (theResult->value == FalseSymbol(theEnv))
|
542
|
+
{ return false; }
|
543
|
+
return true;
|
544
|
+
}
|
545
|
+
|
546
|
+
static void PrintObjectGetVarPN2(
|
547
|
+
Environment *theEnv,
|
548
|
+
const char *logicalName,
|
549
|
+
void *theValue)
|
550
|
+
{
|
551
|
+
#if DEVELOPER
|
552
|
+
struct ObjectMatchVar2 *hack;
|
553
|
+
|
554
|
+
hack = (struct ObjectMatchVar2 *) ((CLIPSBitMap *) theValue)->contents;
|
555
|
+
WriteString(theEnv,logicalName,"(ptn-obj-slot-quick-var ");
|
556
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->whichSlot)->contents);
|
557
|
+
if (hack->fromBeginning)
|
558
|
+
{
|
559
|
+
WriteString(theEnv,logicalName," B");
|
560
|
+
PrintUnsignedInteger(theEnv,logicalName,(hack->beginningOffset + 1));
|
561
|
+
}
|
562
|
+
if (hack->fromEnd)
|
563
|
+
{
|
564
|
+
WriteString(theEnv,logicalName," E");
|
565
|
+
PrintUnsignedInteger(theEnv,logicalName,(hack->endOffset + 1));
|
566
|
+
}
|
567
|
+
WriteString(theEnv,logicalName,")");
|
568
|
+
#else
|
569
|
+
#if MAC_XCD
|
570
|
+
#pragma unused(theEnv)
|
571
|
+
#pragma unused(logicalName)
|
572
|
+
#pragma unused(theValue)
|
573
|
+
#endif
|
574
|
+
#endif
|
575
|
+
}
|
576
|
+
|
577
|
+
static bool ObjectGetVarPNFunction2(
|
578
|
+
Environment *theEnv,
|
579
|
+
void *theValue,
|
580
|
+
UDFValue *theResult)
|
581
|
+
{
|
582
|
+
const struct ObjectMatchVar2 *hack;
|
583
|
+
|
584
|
+
hack = (const struct ObjectMatchVar2 *) ((CLIPSBitMap *) theValue)->contents;
|
585
|
+
GetObjectValueSimple(theEnv,theResult,ObjectReteData(theEnv)->CurrentPatternObject,hack);
|
586
|
+
|
587
|
+
if (theResult->value == FalseSymbol(theEnv))
|
588
|
+
{ return false; }
|
589
|
+
|
590
|
+
return true;
|
591
|
+
}
|
592
|
+
|
593
|
+
static void PrintObjectCmpConstant(
|
594
|
+
Environment *theEnv,
|
595
|
+
const char *logicalName,
|
596
|
+
void *theValue)
|
597
|
+
{
|
598
|
+
#if DEVELOPER
|
599
|
+
struct ObjectCmpPNConstant *hack;
|
600
|
+
|
601
|
+
hack = (struct ObjectCmpPNConstant *) ((CLIPSBitMap *) theValue)->contents;
|
602
|
+
|
603
|
+
WriteString(theEnv,logicalName,"(obj-const ");
|
604
|
+
WriteString(theEnv,logicalName,hack->pass ? "p " : "n ");
|
605
|
+
if (hack->general)
|
606
|
+
PrintExpression(theEnv,logicalName,GetFirstArgument());
|
607
|
+
else
|
608
|
+
{
|
609
|
+
WriteString(theEnv,logicalName,hack->fromBeginning ? "B" : "E");
|
610
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->offset);
|
611
|
+
WriteString(theEnv,logicalName," ");
|
612
|
+
PrintExpression(theEnv,logicalName,GetFirstArgument());
|
613
|
+
}
|
614
|
+
WriteString(theEnv,logicalName,")");
|
615
|
+
#else
|
616
|
+
#if MAC_XCD
|
617
|
+
#pragma unused(theEnv)
|
618
|
+
#pragma unused(logicalName)
|
619
|
+
#pragma unused(theValue)
|
620
|
+
#endif
|
621
|
+
#endif
|
622
|
+
}
|
623
|
+
|
624
|
+
static void PrintSlotLengthTest(
|
625
|
+
Environment *theEnv,
|
626
|
+
const char *logicalName,
|
627
|
+
void *theValue)
|
628
|
+
{
|
629
|
+
#if DEVELOPER
|
630
|
+
struct ObjectMatchLength *hack;
|
631
|
+
|
632
|
+
hack = (struct ObjectMatchLength *) ((CLIPSBitMap *) theValue)->contents;
|
633
|
+
|
634
|
+
WriteString(theEnv,logicalName,"(obj-slot-len ");
|
635
|
+
if (hack->exactly)
|
636
|
+
WriteString(theEnv,logicalName,"= ");
|
637
|
+
else
|
638
|
+
WriteString(theEnv,logicalName,">= ");
|
639
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->minLength);
|
640
|
+
WriteString(theEnv,logicalName,")");
|
641
|
+
#else
|
642
|
+
#if MAC_XCD
|
643
|
+
#pragma unused(theEnv)
|
644
|
+
#pragma unused(logicalName)
|
645
|
+
#pragma unused(theValue)
|
646
|
+
#endif
|
647
|
+
#endif
|
648
|
+
}
|
649
|
+
|
650
|
+
static bool SlotLengthTestFunction(
|
651
|
+
Environment *theEnv,
|
652
|
+
void *theValue,
|
653
|
+
UDFValue *theResult)
|
654
|
+
{
|
655
|
+
const struct ObjectMatchLength *hack;
|
656
|
+
|
657
|
+
theResult->value = FalseSymbol(theEnv);
|
658
|
+
hack = (const struct ObjectMatchLength *) ((CLIPSBitMap *) theValue)->contents;
|
659
|
+
if (ObjectReteData(theEnv)->CurrentObjectSlotLength < hack->minLength)
|
660
|
+
return false;
|
661
|
+
if (hack->exactly && (ObjectReteData(theEnv)->CurrentObjectSlotLength > hack->minLength))
|
662
|
+
return false;
|
663
|
+
theResult->value = TrueSymbol(theEnv);
|
664
|
+
return true;
|
665
|
+
}
|
666
|
+
|
667
|
+
static void PrintPNSimpleCompareFunction1(
|
668
|
+
Environment *theEnv,
|
669
|
+
const char *logicalName,
|
670
|
+
void *theValue)
|
671
|
+
{
|
672
|
+
#if DEVELOPER
|
673
|
+
struct ObjectCmpPNSingleSlotVars1 *hack;
|
674
|
+
|
675
|
+
hack = (struct ObjectCmpPNSingleSlotVars1 *) ((CLIPSBitMap *) theValue)->contents;
|
676
|
+
|
677
|
+
WriteString(theEnv,logicalName,"(pslot-cmp1 ");
|
678
|
+
WriteString(theEnv,logicalName,hack->pass ? "p " : "n ");
|
679
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->firstSlot)->contents);
|
680
|
+
WriteString(theEnv,logicalName," ");
|
681
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->secondSlot)->contents);
|
682
|
+
WriteString(theEnv,logicalName,")");
|
683
|
+
#else
|
684
|
+
#if MAC_XCD
|
685
|
+
#pragma unused(theEnv)
|
686
|
+
#pragma unused(logicalName)
|
687
|
+
#pragma unused(theValue)
|
688
|
+
#endif
|
689
|
+
#endif
|
690
|
+
}
|
691
|
+
|
692
|
+
static bool PNSimpleCompareFunction1(
|
693
|
+
Environment *theEnv,
|
694
|
+
void *theValue,
|
695
|
+
UDFValue *theResult)
|
696
|
+
{
|
697
|
+
const struct ObjectCmpPNSingleSlotVars1 *hack;
|
698
|
+
InstanceSlot *is1,*is2;
|
699
|
+
bool rv;
|
700
|
+
|
701
|
+
hack = (const struct ObjectCmpPNSingleSlotVars1 *) ((CLIPSBitMap *) theValue)->contents;
|
702
|
+
is1 = GetInsSlot(ObjectReteData(theEnv)->CurrentPatternObject,hack->firstSlot);
|
703
|
+
is2 = GetInsSlot(ObjectReteData(theEnv)->CurrentPatternObject,hack->secondSlot);
|
704
|
+
if (is1->type != is2->type)
|
705
|
+
rv = hack->fail;
|
706
|
+
else if (is1->value != is2->value)
|
707
|
+
rv = hack->fail ? true : false;
|
708
|
+
else
|
709
|
+
rv = hack->pass ? true : false;
|
710
|
+
theResult->value = rv ? TrueSymbol(theEnv) : FalseSymbol(theEnv);
|
711
|
+
return rv;
|
712
|
+
}
|
713
|
+
|
714
|
+
static void PrintPNSimpleCompareFunction2(
|
715
|
+
Environment *theEnv,
|
716
|
+
const char *logicalName,
|
717
|
+
void *theValue)
|
718
|
+
{
|
719
|
+
#if DEVELOPER
|
720
|
+
struct ObjectCmpPNSingleSlotVars2 *hack;
|
721
|
+
|
722
|
+
hack = (struct ObjectCmpPNSingleSlotVars2 *) ((CLIPSBitMap *) theValue)->contents;
|
723
|
+
|
724
|
+
WriteString(theEnv,logicalName,"(pslot-cmp2 ");
|
725
|
+
WriteString(theEnv,logicalName,hack->pass ? "p " : "n ");
|
726
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->firstSlot)->contents);
|
727
|
+
WriteString(theEnv,logicalName,hack->fromBeginning ? " B" : " E");
|
728
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->offset);
|
729
|
+
WriteString(theEnv,logicalName," ");
|
730
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->secondSlot)->contents);
|
731
|
+
WriteString(theEnv,logicalName,")");
|
732
|
+
#else
|
733
|
+
#if MAC_XCD
|
734
|
+
#pragma unused(theEnv)
|
735
|
+
#pragma unused(logicalName)
|
736
|
+
#pragma unused(theValue)
|
737
|
+
#endif
|
738
|
+
#endif
|
739
|
+
}
|
740
|
+
|
741
|
+
static bool PNSimpleCompareFunction2(
|
742
|
+
Environment *theEnv,
|
743
|
+
void *theValue,
|
744
|
+
UDFValue *theResult)
|
745
|
+
{
|
746
|
+
const struct ObjectCmpPNSingleSlotVars2 *hack;
|
747
|
+
bool rv;
|
748
|
+
CLIPSValue f1;
|
749
|
+
InstanceSlot *is2;
|
750
|
+
|
751
|
+
hack = (const struct ObjectCmpPNSingleSlotVars2 *) ((CLIPSBitMap *) theValue)->contents;
|
752
|
+
GetInsMultiSlotField(&f1,ObjectReteData(theEnv)->CurrentPatternObject,hack->firstSlot,
|
753
|
+
hack->fromBeginning,hack->offset);
|
754
|
+
is2 = GetInsSlot(ObjectReteData(theEnv)->CurrentPatternObject,hack->secondSlot);
|
755
|
+
if (f1.value != is2->value)
|
756
|
+
rv = hack->fail ? true : false;
|
757
|
+
else
|
758
|
+
rv = hack->pass ? true : false;
|
759
|
+
theResult->value = rv ? TrueSymbol(theEnv) : FalseSymbol(theEnv);
|
760
|
+
return rv;
|
761
|
+
}
|
762
|
+
|
763
|
+
static void PrintPNSimpleCompareFunction3(
|
764
|
+
Environment*theEnv,
|
765
|
+
const char *logicalName,
|
766
|
+
void *theValue)
|
767
|
+
{
|
768
|
+
#if DEVELOPER
|
769
|
+
struct ObjectCmpPNSingleSlotVars3 *hack;
|
770
|
+
|
771
|
+
hack = (struct ObjectCmpPNSingleSlotVars3 *) ((CLIPSBitMap *) theValue)->contents;
|
772
|
+
|
773
|
+
WriteString(theEnv,logicalName,"(pslot-cmp3 ");
|
774
|
+
WriteString(theEnv,logicalName,hack->pass ? "p " : "n ");
|
775
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->firstSlot)->contents);
|
776
|
+
WriteString(theEnv,logicalName,hack->firstFromBeginning ? " B" : " E");
|
777
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->firstOffset);
|
778
|
+
WriteString(theEnv,logicalName," ");
|
779
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->secondSlot)->contents);
|
780
|
+
WriteString(theEnv,logicalName,hack->secondFromBeginning ? " B" : " E");
|
781
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->secondOffset);
|
782
|
+
WriteString(theEnv,logicalName,")");
|
783
|
+
#else
|
784
|
+
#if MAC_XCD
|
785
|
+
#pragma unused(theEnv)
|
786
|
+
#pragma unused(logicalName)
|
787
|
+
#pragma unused(theValue)
|
788
|
+
#endif
|
789
|
+
#endif
|
790
|
+
}
|
791
|
+
|
792
|
+
static bool PNSimpleCompareFunction3(
|
793
|
+
Environment *theEnv,
|
794
|
+
void *theValue,
|
795
|
+
UDFValue *theResult)
|
796
|
+
{
|
797
|
+
const struct ObjectCmpPNSingleSlotVars3 *hack;
|
798
|
+
bool rv;
|
799
|
+
CLIPSValue f1, f2;
|
800
|
+
|
801
|
+
hack = (const struct ObjectCmpPNSingleSlotVars3 *) ((CLIPSBitMap *) theValue)->contents;
|
802
|
+
GetInsMultiSlotField(&f1,ObjectReteData(theEnv)->CurrentPatternObject,hack->firstSlot,
|
803
|
+
hack->firstFromBeginning,hack->firstOffset);
|
804
|
+
GetInsMultiSlotField(&f2,ObjectReteData(theEnv)->CurrentPatternObject,hack->secondSlot,
|
805
|
+
hack->secondFromBeginning,hack->secondOffset);
|
806
|
+
if (f1.value != f2.value)
|
807
|
+
rv = hack->fail ? true : false;
|
808
|
+
else
|
809
|
+
rv = hack->pass ? true : false;
|
810
|
+
theResult->value = rv ? TrueSymbol(theEnv) : FalseSymbol(theEnv);
|
811
|
+
return rv;
|
812
|
+
}
|
813
|
+
|
814
|
+
static void PrintJNSimpleCompareFunction1(
|
815
|
+
Environment *theEnv,
|
816
|
+
const char *logicalName,
|
817
|
+
void *theValue)
|
818
|
+
{
|
819
|
+
#if DEVELOPER
|
820
|
+
struct ObjectCmpJoinSingleSlotVars1 *hack;
|
821
|
+
|
822
|
+
hack = (struct ObjectCmpJoinSingleSlotVars1 *) ((CLIPSBitMap *) theValue)->contents;
|
823
|
+
|
824
|
+
WriteString(theEnv,logicalName,"(jslot-cmp1 ");
|
825
|
+
WriteString(theEnv,logicalName,hack->pass ? "p " : "n ");
|
826
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->firstPattern);
|
827
|
+
WriteString(theEnv,logicalName," ");
|
828
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->firstSlot)->contents);
|
829
|
+
WriteString(theEnv,logicalName," ");
|
830
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->secondPattern);
|
831
|
+
WriteString(theEnv,logicalName," ");
|
832
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->secondSlot)->contents);
|
833
|
+
WriteString(theEnv,logicalName,")");
|
834
|
+
#else
|
835
|
+
#if MAC_XCD
|
836
|
+
#pragma unused(theEnv)
|
837
|
+
#pragma unused(logicalName)
|
838
|
+
#pragma unused(theValue)
|
839
|
+
#endif
|
840
|
+
#endif
|
841
|
+
}
|
842
|
+
|
843
|
+
static bool JNSimpleCompareFunction1(
|
844
|
+
Environment *theEnv,
|
845
|
+
void *theValue,
|
846
|
+
UDFValue *theResult)
|
847
|
+
{
|
848
|
+
Instance *ins1,*ins2;
|
849
|
+
struct multifieldMarker *theMarks;
|
850
|
+
const struct ObjectCmpJoinSingleSlotVars1 *hack;
|
851
|
+
bool rv;
|
852
|
+
InstanceSlot *is1,*is2;
|
853
|
+
|
854
|
+
hack = (const struct ObjectCmpJoinSingleSlotVars1 *) ((CLIPSBitMap *) theValue)->contents;
|
855
|
+
GetPatternObjectAndMarks(theEnv,hack->firstPattern,hack->firstPatternLHS,hack->firstPatternRHS,&ins1,&theMarks);
|
856
|
+
is1 = GetInsSlot(ins1,hack->firstSlot);
|
857
|
+
GetPatternObjectAndMarks(theEnv,hack->secondPattern,hack->secondPatternLHS,hack->secondPatternRHS,&ins2,&theMarks);
|
858
|
+
is2 = GetInsSlot(ins2,hack->secondSlot);
|
859
|
+
if (is1->type != is2->type)
|
860
|
+
rv = hack->fail;
|
861
|
+
else if (is1->value != is2->value)
|
862
|
+
rv = hack->fail ? true : false;
|
863
|
+
else
|
864
|
+
rv = hack->pass ? true : false;
|
865
|
+
theResult->value = rv ? TrueSymbol(theEnv) : FalseSymbol(theEnv);
|
866
|
+
return rv;
|
867
|
+
}
|
868
|
+
|
869
|
+
static void PrintJNSimpleCompareFunction2(
|
870
|
+
Environment *theEnv,
|
871
|
+
const char *logicalName,
|
872
|
+
void *theValue)
|
873
|
+
{
|
874
|
+
#if DEVELOPER
|
875
|
+
struct ObjectCmpJoinSingleSlotVars2 *hack;
|
876
|
+
|
877
|
+
hack = (struct ObjectCmpJoinSingleSlotVars2 *) ((CLIPSBitMap *) theValue)->contents;
|
878
|
+
|
879
|
+
WriteString(theEnv,logicalName,"(jslot-cmp2 ");
|
880
|
+
WriteString(theEnv,logicalName,hack->pass ? "p " : "n ");
|
881
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->firstPattern);
|
882
|
+
WriteString(theEnv,logicalName," ");
|
883
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->firstSlot)->contents);
|
884
|
+
WriteString(theEnv,logicalName,hack->fromBeginning ? " B" : " E");
|
885
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->offset);
|
886
|
+
WriteString(theEnv,logicalName," ");
|
887
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->secondPattern);
|
888
|
+
WriteString(theEnv,logicalName," ");
|
889
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->secondSlot)->contents);
|
890
|
+
WriteString(theEnv,logicalName,")");
|
891
|
+
#else
|
892
|
+
#if MAC_XCD
|
893
|
+
#pragma unused(theEnv)
|
894
|
+
#pragma unused(logicalName)
|
895
|
+
#pragma unused(theValue)
|
896
|
+
#endif
|
897
|
+
#endif
|
898
|
+
}
|
899
|
+
|
900
|
+
static bool JNSimpleCompareFunction2(
|
901
|
+
Environment *theEnv,
|
902
|
+
void *theValue,
|
903
|
+
UDFValue *theResult)
|
904
|
+
{
|
905
|
+
Instance *ins1,*ins2;
|
906
|
+
struct multifieldMarker *theMarks;
|
907
|
+
const struct ObjectCmpJoinSingleSlotVars2 *hack;
|
908
|
+
bool rv;
|
909
|
+
CLIPSValue f1;
|
910
|
+
InstanceSlot *is2;
|
911
|
+
|
912
|
+
hack = (const struct ObjectCmpJoinSingleSlotVars2 *) ((CLIPSBitMap *) theValue)->contents;
|
913
|
+
GetPatternObjectAndMarks(theEnv,hack->firstPattern,hack->firstPatternLHS,hack->firstPatternRHS,&ins1,&theMarks);
|
914
|
+
GetInsMultiSlotField(&f1,ins1,hack->firstSlot,
|
915
|
+
hack->fromBeginning,hack->offset);
|
916
|
+
GetPatternObjectAndMarks(theEnv,hack->secondPattern,hack->secondPatternLHS,hack->secondPatternRHS,&ins2,&theMarks);
|
917
|
+
is2 = GetInsSlot(ins2,hack->secondSlot);
|
918
|
+
if (f1.value != is2->value)
|
919
|
+
rv = hack->fail ? true : false;
|
920
|
+
else
|
921
|
+
rv = hack->pass ? true : false;
|
922
|
+
theResult->value = rv ? TrueSymbol(theEnv) : FalseSymbol(theEnv);
|
923
|
+
return rv;
|
924
|
+
}
|
925
|
+
|
926
|
+
static void PrintJNSimpleCompareFunction3(
|
927
|
+
Environment *theEnv,
|
928
|
+
const char *logicalName,
|
929
|
+
void *theValue)
|
930
|
+
{
|
931
|
+
#if DEVELOPER
|
932
|
+
struct ObjectCmpJoinSingleSlotVars3 *hack;
|
933
|
+
|
934
|
+
hack = (struct ObjectCmpJoinSingleSlotVars3 *) ((CLIPSBitMap *) theValue)->contents;
|
935
|
+
|
936
|
+
WriteString(theEnv,logicalName,"(jslot-cmp3 ");
|
937
|
+
WriteString(theEnv,logicalName,hack->pass ? "p " : "n ");
|
938
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->firstPattern);
|
939
|
+
WriteString(theEnv,logicalName," ");
|
940
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->firstSlot)->contents);
|
941
|
+
WriteString(theEnv,logicalName,hack->firstFromBeginning ? " B" : " E");
|
942
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->firstOffset);
|
943
|
+
WriteString(theEnv,logicalName," ");
|
944
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->secondPattern);
|
945
|
+
WriteString(theEnv,logicalName," ");
|
946
|
+
WriteString(theEnv,logicalName,FindIDSlotName(theEnv,hack->secondSlot)->contents);
|
947
|
+
WriteString(theEnv,logicalName,hack->secondFromBeginning ? " B" : " E");
|
948
|
+
PrintUnsignedInteger(theEnv,logicalName,hack->secondOffset);
|
949
|
+
WriteString(theEnv,logicalName,")");
|
950
|
+
#else
|
951
|
+
#if MAC_XCD
|
952
|
+
#pragma unused(theEnv)
|
953
|
+
#pragma unused(logicalName)
|
954
|
+
#pragma unused(theValue)
|
955
|
+
#endif
|
956
|
+
#endif
|
957
|
+
}
|
958
|
+
|
959
|
+
static bool JNSimpleCompareFunction3(
|
960
|
+
Environment *theEnv,
|
961
|
+
void *theValue,
|
962
|
+
UDFValue *theResult)
|
963
|
+
{
|
964
|
+
Instance *ins1,*ins2;
|
965
|
+
struct multifieldMarker *theMarks;
|
966
|
+
const struct ObjectCmpJoinSingleSlotVars3 *hack;
|
967
|
+
bool rv;
|
968
|
+
CLIPSValue f1,f2;
|
969
|
+
|
970
|
+
hack = (const struct ObjectCmpJoinSingleSlotVars3 *) ((CLIPSBitMap *) theValue)->contents;
|
971
|
+
GetPatternObjectAndMarks(theEnv,hack->firstPattern,hack->firstPatternLHS,hack->firstPatternRHS,&ins1,&theMarks);
|
972
|
+
GetInsMultiSlotField(&f1,ins1,hack->firstSlot,
|
973
|
+
hack->firstFromBeginning,
|
974
|
+
hack->firstOffset);
|
975
|
+
GetPatternObjectAndMarks(theEnv,hack->secondPattern,hack->secondPatternLHS,hack->secondPatternRHS,&ins2,&theMarks);
|
976
|
+
GetInsMultiSlotField(&f2,ins2,hack->secondSlot,
|
977
|
+
hack->secondFromBeginning,
|
978
|
+
hack->secondOffset);
|
979
|
+
if (f1.value != f2.value)
|
980
|
+
rv = hack->fail ? true : false;
|
981
|
+
else
|
982
|
+
rv = hack->pass ? true : false;
|
983
|
+
theResult->value = rv ? TrueSymbol(theEnv) : FalseSymbol(theEnv);
|
984
|
+
return rv;
|
985
|
+
}
|
986
|
+
|
987
|
+
/****************************************************
|
988
|
+
NAME : GetPatternObjectAndMarks
|
989
|
+
DESCRIPTION : Finds the instance and multfiield
|
990
|
+
markers corresponding to a specified
|
991
|
+
pattern in the join network
|
992
|
+
INPUTS : 1) The index of the desired pattern
|
993
|
+
2) A buffer to hold the instance
|
994
|
+
address
|
995
|
+
3) A buffer to hold the list of
|
996
|
+
multifield markers
|
997
|
+
RETURNS : Nothing useful
|
998
|
+
SIDE EFFECTS : Buffers set
|
999
|
+
NOTES : None
|
1000
|
+
****************************************************/
|
1001
|
+
static void GetPatternObjectAndMarks(
|
1002
|
+
Environment *theEnv,
|
1003
|
+
unsigned short pattern,
|
1004
|
+
bool lhs,
|
1005
|
+
bool rhs,
|
1006
|
+
Instance **theInstance,
|
1007
|
+
struct multifieldMarker **theMarkers)
|
1008
|
+
{
|
1009
|
+
if (lhs)
|
1010
|
+
{
|
1011
|
+
*theInstance = (Instance *)
|
1012
|
+
get_nth_pm_match(EngineData(theEnv)->GlobalLHSBinds,pattern)->matchingItem;
|
1013
|
+
*theMarkers =
|
1014
|
+
get_nth_pm_match(EngineData(theEnv)->GlobalLHSBinds,pattern)->markers;
|
1015
|
+
}
|
1016
|
+
else if (rhs)
|
1017
|
+
{
|
1018
|
+
*theInstance = (Instance *)
|
1019
|
+
get_nth_pm_match(EngineData(theEnv)->GlobalRHSBinds,pattern)->matchingItem;
|
1020
|
+
*theMarkers =
|
1021
|
+
get_nth_pm_match(EngineData(theEnv)->GlobalRHSBinds,pattern)->markers;
|
1022
|
+
}
|
1023
|
+
else if (EngineData(theEnv)->GlobalRHSBinds == NULL)
|
1024
|
+
{
|
1025
|
+
*theInstance = (Instance *)
|
1026
|
+
get_nth_pm_match(EngineData(theEnv)->GlobalLHSBinds,pattern)->matchingItem;
|
1027
|
+
*theMarkers =
|
1028
|
+
get_nth_pm_match(EngineData(theEnv)->GlobalLHSBinds,pattern)->markers;
|
1029
|
+
}
|
1030
|
+
else if ((EngineData(theEnv)->GlobalJoin->depth - 1) == pattern)
|
1031
|
+
{
|
1032
|
+
*theInstance = (Instance *)
|
1033
|
+
get_nth_pm_match(EngineData(theEnv)->GlobalRHSBinds,0)->matchingItem;
|
1034
|
+
*theMarkers = get_nth_pm_match(EngineData(theEnv)->GlobalRHSBinds,0)->markers;
|
1035
|
+
}
|
1036
|
+
else
|
1037
|
+
{
|
1038
|
+
*theInstance = (Instance *)
|
1039
|
+
get_nth_pm_match(EngineData(theEnv)->GlobalLHSBinds,pattern)->matchingItem;
|
1040
|
+
*theMarkers =
|
1041
|
+
get_nth_pm_match(EngineData(theEnv)->GlobalLHSBinds,pattern)->markers;
|
1042
|
+
}
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
/***************************************************
|
1046
|
+
NAME : GetObjectValueGeneral
|
1047
|
+
DESCRIPTION : Access function for getting
|
1048
|
+
pattern variable values within the
|
1049
|
+
object pattern and join networks
|
1050
|
+
INPUTS : 1) The result data object buffer
|
1051
|
+
2) The instance to access
|
1052
|
+
3) The list of multifield markers
|
1053
|
+
for the pattern
|
1054
|
+
4) Data for variable reference
|
1055
|
+
RETURNS : Nothing useful
|
1056
|
+
SIDE EFFECTS : Data object is filled with the
|
1057
|
+
values of the pattern variable
|
1058
|
+
NOTES : None
|
1059
|
+
***************************************************/
|
1060
|
+
static void GetObjectValueGeneral(
|
1061
|
+
Environment *theEnv,
|
1062
|
+
UDFValue *returnValue,
|
1063
|
+
Instance *theInstance,
|
1064
|
+
struct multifieldMarker *theMarks,
|
1065
|
+
const struct ObjectMatchVar1 *matchVar)
|
1066
|
+
{
|
1067
|
+
size_t field;
|
1068
|
+
size_t extent;
|
1069
|
+
InstanceSlot **insSlot,*basisSlot;
|
1070
|
+
|
1071
|
+
if (matchVar->objectAddress)
|
1072
|
+
{
|
1073
|
+
returnValue->value = theInstance;
|
1074
|
+
return;
|
1075
|
+
}
|
1076
|
+
if (matchVar->whichSlot == ISA_ID)
|
1077
|
+
{
|
1078
|
+
returnValue->value = GetDefclassNamePointer(theInstance->cls);
|
1079
|
+
return;
|
1080
|
+
}
|
1081
|
+
if (matchVar->whichSlot == NAME_ID)
|
1082
|
+
{
|
1083
|
+
returnValue->value = theInstance->name;
|
1084
|
+
return;
|
1085
|
+
}
|
1086
|
+
insSlot =
|
1087
|
+
&theInstance->slotAddresses
|
1088
|
+
[theInstance->cls->slotNameMap[matchVar->whichSlot] - 1];
|
1089
|
+
|
1090
|
+
/* =========================================
|
1091
|
+
We need to reference the basis slots if
|
1092
|
+
the slot of this object has changed while
|
1093
|
+
the RHS was executing
|
1094
|
+
|
1095
|
+
However, if the reference is being done
|
1096
|
+
by the LHS of a rule (as a consequence of
|
1097
|
+
an RHS action), give the pattern matcher
|
1098
|
+
the real value of the slot
|
1099
|
+
========================================= */
|
1100
|
+
if ((theInstance->basisSlots != NULL) &&
|
1101
|
+
(! EngineData(theEnv)->JoinOperationInProgress))
|
1102
|
+
{
|
1103
|
+
basisSlot = theInstance->basisSlots + (insSlot - theInstance->slotAddresses);
|
1104
|
+
if (basisSlot->value != NULL)
|
1105
|
+
insSlot = &basisSlot;
|
1106
|
+
}
|
1107
|
+
|
1108
|
+
/* ==================================================
|
1109
|
+
If we know we are accessing the entire slot,
|
1110
|
+
the don't bother with searching multifield markers
|
1111
|
+
or calculating offsets
|
1112
|
+
================================================== */
|
1113
|
+
if (matchVar->allFields)
|
1114
|
+
{
|
1115
|
+
returnValue->value = (*insSlot)->value;
|
1116
|
+
if (returnValue->header->type == MULTIFIELD_TYPE)
|
1117
|
+
{
|
1118
|
+
returnValue->begin = 0;
|
1119
|
+
returnValue->range = (*insSlot)->multifieldValue->length;
|
1120
|
+
}
|
1121
|
+
return;
|
1122
|
+
}
|
1123
|
+
|
1124
|
+
/* =============================================
|
1125
|
+
Access a general field in a slot pattern with
|
1126
|
+
two or more multifield variables
|
1127
|
+
============================================= */
|
1128
|
+
|
1129
|
+
extent = SIZE_MAX;
|
1130
|
+
field = CalculateSlotField(theMarks,*insSlot,matchVar->whichField,&extent);
|
1131
|
+
if (extent == SIZE_MAX)
|
1132
|
+
{
|
1133
|
+
if ((*insSlot)->desc->multiple)
|
1134
|
+
{ returnValue->value = (*insSlot)->multifieldValue->contents[field-1].value; }
|
1135
|
+
else
|
1136
|
+
{ returnValue->value = (*insSlot)->value; }
|
1137
|
+
}
|
1138
|
+
else
|
1139
|
+
{
|
1140
|
+
returnValue->value = (*insSlot)->value;
|
1141
|
+
returnValue->begin = field - 1;
|
1142
|
+
returnValue->range = extent;
|
1143
|
+
}
|
1144
|
+
}
|
1145
|
+
|
1146
|
+
/***************************************************
|
1147
|
+
NAME : GetObjectValueSimple
|
1148
|
+
DESCRIPTION : Access function for getting
|
1149
|
+
pattern variable values within the
|
1150
|
+
object pattern and join networks
|
1151
|
+
INPUTS : 1) The result data object buffer
|
1152
|
+
2) The instance to access
|
1153
|
+
3) Data for variable reference
|
1154
|
+
RETURNS : Nothing useful
|
1155
|
+
SIDE EFFECTS : Data object is filled with the
|
1156
|
+
values of the pattern variable
|
1157
|
+
NOTES : None
|
1158
|
+
***************************************************/
|
1159
|
+
static void GetObjectValueSimple(
|
1160
|
+
Environment *theEnv,
|
1161
|
+
UDFValue *returnValue,
|
1162
|
+
Instance *theInstance,
|
1163
|
+
const struct ObjectMatchVar2 *matchVar)
|
1164
|
+
{
|
1165
|
+
InstanceSlot **insSlot,*basisSlot;
|
1166
|
+
Multifield *segmentPtr;
|
1167
|
+
CLIPSValue *fieldPtr;
|
1168
|
+
|
1169
|
+
insSlot =
|
1170
|
+
&theInstance->slotAddresses
|
1171
|
+
[theInstance->cls->slotNameMap[matchVar->whichSlot] - 1];
|
1172
|
+
|
1173
|
+
/* =========================================
|
1174
|
+
We need to reference the basis slots if
|
1175
|
+
the slot of this object has changed while
|
1176
|
+
the RHS was executing
|
1177
|
+
|
1178
|
+
However, if the reference is being done
|
1179
|
+
by the LHS of a rule (as a consequence of
|
1180
|
+
an RHS action), give the pattern matcher
|
1181
|
+
the real value of the slot
|
1182
|
+
========================================= */
|
1183
|
+
if ((theInstance->basisSlots != NULL) &&
|
1184
|
+
(! EngineData(theEnv)->JoinOperationInProgress))
|
1185
|
+
{
|
1186
|
+
basisSlot = theInstance->basisSlots + (insSlot - theInstance->slotAddresses);
|
1187
|
+
if (basisSlot->value != NULL)
|
1188
|
+
insSlot = &basisSlot;
|
1189
|
+
}
|
1190
|
+
|
1191
|
+
if ((*insSlot)->desc->multiple)
|
1192
|
+
{
|
1193
|
+
segmentPtr = (*insSlot)->multifieldValue;
|
1194
|
+
if (matchVar->fromBeginning)
|
1195
|
+
{
|
1196
|
+
if (matchVar->fromEnd)
|
1197
|
+
{
|
1198
|
+
returnValue->value = segmentPtr;
|
1199
|
+
returnValue->begin = matchVar->beginningOffset;
|
1200
|
+
returnValue->range = segmentPtr->length - (matchVar->endOffset + matchVar->beginningOffset);
|
1201
|
+
}
|
1202
|
+
else
|
1203
|
+
{
|
1204
|
+
fieldPtr = &segmentPtr->contents[matchVar->beginningOffset];
|
1205
|
+
returnValue->value = fieldPtr->value;
|
1206
|
+
}
|
1207
|
+
}
|
1208
|
+
else
|
1209
|
+
{
|
1210
|
+
fieldPtr = &segmentPtr->contents[segmentPtr->length -
|
1211
|
+
(matchVar->endOffset + 1)];
|
1212
|
+
returnValue->value = fieldPtr->value;
|
1213
|
+
}
|
1214
|
+
}
|
1215
|
+
else
|
1216
|
+
{
|
1217
|
+
returnValue->value = (*insSlot)->value;
|
1218
|
+
}
|
1219
|
+
}
|
1220
|
+
|
1221
|
+
/****************************************************
|
1222
|
+
NAME : CalculateSlotField
|
1223
|
+
DESCRIPTION : Determines the actual index into the
|
1224
|
+
an object slot for a given pattern
|
1225
|
+
variable
|
1226
|
+
INPUTS : 1) The list of markers to examine
|
1227
|
+
2) The instance slot (can be NULL)
|
1228
|
+
3) The pattern index of the variable
|
1229
|
+
4) A buffer in which to store the
|
1230
|
+
extent of the pattern variable
|
1231
|
+
(-1 for single-field vars)
|
1232
|
+
RETURNS : The actual index
|
1233
|
+
SIDE EFFECTS : None
|
1234
|
+
NOTES : None
|
1235
|
+
****************************************************/
|
1236
|
+
static size_t CalculateSlotField(
|
1237
|
+
struct multifieldMarker *theMarkers,
|
1238
|
+
InstanceSlot *theSlot,
|
1239
|
+
size_t theIndex,
|
1240
|
+
size_t *extent)
|
1241
|
+
{
|
1242
|
+
size_t actualIndex;
|
1243
|
+
void *theSlotName;
|
1244
|
+
|
1245
|
+
actualIndex = theIndex;
|
1246
|
+
*extent = SIZE_MAX;
|
1247
|
+
|
1248
|
+
if (theSlot == NULL)
|
1249
|
+
{ return actualIndex; }
|
1250
|
+
|
1251
|
+
theSlotName = theSlot->desc->slotName->name;
|
1252
|
+
while (theMarkers != NULL)
|
1253
|
+
{
|
1254
|
+
if (theMarkers->where.whichSlot == theSlotName)
|
1255
|
+
break;
|
1256
|
+
theMarkers = theMarkers->next;
|
1257
|
+
}
|
1258
|
+
|
1259
|
+
while ((theMarkers != NULL) ? (theMarkers->where.whichSlot == theSlotName) : false)
|
1260
|
+
{
|
1261
|
+
if (theMarkers->whichField == theIndex)
|
1262
|
+
{
|
1263
|
+
*extent = theMarkers->range;
|
1264
|
+
|
1265
|
+
return actualIndex;
|
1266
|
+
}
|
1267
|
+
|
1268
|
+
if (theMarkers->whichField > theIndex)
|
1269
|
+
{ return actualIndex; }
|
1270
|
+
|
1271
|
+
actualIndex = actualIndex + theMarkers->range - 1;
|
1272
|
+
theMarkers = theMarkers->next;
|
1273
|
+
}
|
1274
|
+
|
1275
|
+
return actualIndex;
|
1276
|
+
}
|
1277
|
+
|
1278
|
+
/****************************************************
|
1279
|
+
NAME : GetInsMultiSlotField
|
1280
|
+
DESCRIPTION : Gets the values of simple single
|
1281
|
+
field references in multifield
|
1282
|
+
slots for Rete comparisons
|
1283
|
+
INPUTS : 1) A multifield field structure
|
1284
|
+
to store the type and value in
|
1285
|
+
2) The instance
|
1286
|
+
3) The id of the slot
|
1287
|
+
4) A flag indicating if offset is
|
1288
|
+
from beginning or end of
|
1289
|
+
multifield slot
|
1290
|
+
5) The offset
|
1291
|
+
RETURNS : The multifield field
|
1292
|
+
SIDE EFFECTS : None
|
1293
|
+
NOTES : Should only be used to access
|
1294
|
+
single-field reference in multifield
|
1295
|
+
slots for pattern and join network
|
1296
|
+
comparisons
|
1297
|
+
****************************************************/
|
1298
|
+
static void GetInsMultiSlotField(
|
1299
|
+
CLIPSValue *theField,
|
1300
|
+
Instance *theInstance,
|
1301
|
+
unsigned theSlotID,
|
1302
|
+
unsigned fromBeginning,
|
1303
|
+
unsigned offset)
|
1304
|
+
{
|
1305
|
+
InstanceSlot * insSlot;
|
1306
|
+
Multifield *theSegment;
|
1307
|
+
CLIPSValue *tmpField;
|
1308
|
+
|
1309
|
+
insSlot = theInstance->slotAddresses
|
1310
|
+
[theInstance->cls->slotNameMap[theSlotID] - 1];
|
1311
|
+
|
1312
|
+
/* Bug fix for 6.05 */
|
1313
|
+
|
1314
|
+
if (insSlot->desc->multiple)
|
1315
|
+
{
|
1316
|
+
theSegment = insSlot->multifieldValue;
|
1317
|
+
if (fromBeginning)
|
1318
|
+
tmpField = &theSegment->contents[offset];
|
1319
|
+
else
|
1320
|
+
tmpField = &theSegment->contents[theSegment->length - offset - 1];
|
1321
|
+
theField->value = tmpField->value;
|
1322
|
+
}
|
1323
|
+
else
|
1324
|
+
{
|
1325
|
+
theField->value = insSlot->value;
|
1326
|
+
}
|
1327
|
+
}
|
1328
|
+
|
1329
|
+
#endif
|
1330
|
+
|