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,971 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.40 07/02/18 */
|
5
|
+
/* */
|
6
|
+
/* DEFINSTANCES MODULE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: Kernel definstances interface commands */
|
11
|
+
/* and routines */
|
12
|
+
/* */
|
13
|
+
/* Principal Programmer(s): */
|
14
|
+
/* Brian L. Dantes */
|
15
|
+
/* */
|
16
|
+
/* Contributing Programmer(s): */
|
17
|
+
/* */
|
18
|
+
/* */
|
19
|
+
/* Revision History: */
|
20
|
+
/* */
|
21
|
+
/* 6.23: Correction for FalseSymbol/TrueSymbol. DR0859 */
|
22
|
+
/* */
|
23
|
+
/* Corrected compilation errors for files */
|
24
|
+
/* generated by constructs-to-c. DR0861 */
|
25
|
+
/* */
|
26
|
+
/* Changed name of variable exp to theExp */
|
27
|
+
/* because of Unix compiler warnings of shadowed */
|
28
|
+
/* definitions. */
|
29
|
+
/* */
|
30
|
+
/* 6.24: Converted INSTANCE_PATTERN_MATCHING to */
|
31
|
+
/* DEFRULE_CONSTRUCT. */
|
32
|
+
/* */
|
33
|
+
/* Renamed BOOLEAN macro type to intBool. */
|
34
|
+
/* */
|
35
|
+
/* 6.30: Removed conditional code for unsupported */
|
36
|
+
/* compilers/operating systems (IBM_MCW, */
|
37
|
+
/* MAC_MCW, and IBM_TBC). */
|
38
|
+
/* */
|
39
|
+
/* GetConstructNameAndComment API change. */
|
40
|
+
/* */
|
41
|
+
/* Added const qualifiers to remove C++ */
|
42
|
+
/* deprecation warnings. */
|
43
|
+
/* */
|
44
|
+
/* Converted API macros to function calls. */
|
45
|
+
/* */
|
46
|
+
/* Changed find construct functionality so that */
|
47
|
+
/* imported modules are search when locating a */
|
48
|
+
/* named construct. */
|
49
|
+
/* */
|
50
|
+
/* 6.40: Pragma once and other inclusion changes. */
|
51
|
+
/* */
|
52
|
+
/* Added support for booleans with <stdbool.h>. */
|
53
|
+
/* */
|
54
|
+
/* Removed use of void pointers for specific */
|
55
|
+
/* data structures. */
|
56
|
+
/* */
|
57
|
+
/* ALLOW_ENVIRONMENT_GLOBALS no longer supported. */
|
58
|
+
/* */
|
59
|
+
/* UDF redesign. */
|
60
|
+
/* */
|
61
|
+
/* Removed initial-object support. */
|
62
|
+
/* */
|
63
|
+
/* Pretty print functions accept optional logical */
|
64
|
+
/* name argument. */
|
65
|
+
/* */
|
66
|
+
/*************************************************************/
|
67
|
+
|
68
|
+
/* =========================================
|
69
|
+
*****************************************
|
70
|
+
EXTERNAL DEFINITIONS
|
71
|
+
=========================================
|
72
|
+
***************************************** */
|
73
|
+
#include "setup.h"
|
74
|
+
|
75
|
+
#if DEFINSTANCES_CONSTRUCT
|
76
|
+
|
77
|
+
#if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE
|
78
|
+
#include "bload.h"
|
79
|
+
#include "dfinsbin.h"
|
80
|
+
#endif
|
81
|
+
|
82
|
+
#if CONSTRUCT_COMPILER && (! RUN_TIME)
|
83
|
+
#include "dfinscmp.h"
|
84
|
+
#endif
|
85
|
+
|
86
|
+
#include "argacces.h"
|
87
|
+
#include "classcom.h"
|
88
|
+
#include "classfun.h"
|
89
|
+
#include "cstrccom.h"
|
90
|
+
#include "cstrcpsr.h"
|
91
|
+
#include "constant.h"
|
92
|
+
#include "constrct.h"
|
93
|
+
#include "envrnmnt.h"
|
94
|
+
#include "evaluatn.h"
|
95
|
+
#include "extnfunc.h"
|
96
|
+
#include "insfun.h"
|
97
|
+
#include "inspsr.h"
|
98
|
+
#include "memalloc.h"
|
99
|
+
#include "modulpsr.h"
|
100
|
+
#include "modulutl.h"
|
101
|
+
#include "pprint.h"
|
102
|
+
#include "prntutil.h"
|
103
|
+
#include "router.h"
|
104
|
+
#include "scanner.h"
|
105
|
+
#include "symbol.h"
|
106
|
+
#include "utility.h"
|
107
|
+
|
108
|
+
#include "defins.h"
|
109
|
+
|
110
|
+
/* =========================================
|
111
|
+
*****************************************
|
112
|
+
CONSTANTS
|
113
|
+
=========================================
|
114
|
+
***************************************** */
|
115
|
+
#define ACTIVE_RLN "active"
|
116
|
+
|
117
|
+
/* =========================================
|
118
|
+
*****************************************
|
119
|
+
INTERNALLY VISIBLE FUNCTION HEADERS
|
120
|
+
=========================================
|
121
|
+
***************************************** */
|
122
|
+
|
123
|
+
#if (! BLOAD_ONLY) && (! RUN_TIME)
|
124
|
+
static bool ParseDefinstances(Environment *,const char *);
|
125
|
+
static CLIPSLexeme *ParseDefinstancesName(Environment *,const char *,bool *);
|
126
|
+
static void RemoveDefinstances(Environment *,Definstances *);
|
127
|
+
static void SaveDefinstances(Environment *,Defmodule *,const char *,void *);
|
128
|
+
#endif
|
129
|
+
|
130
|
+
#if ! RUN_TIME
|
131
|
+
static void *AllocateModule(Environment *);
|
132
|
+
static void ReturnModule(Environment *,void *);
|
133
|
+
static bool ClearDefinstancesReady(Environment *,void *);
|
134
|
+
static void CheckDefinstancesBusy(Environment *,ConstructHeader *,void *);
|
135
|
+
static void DestroyDefinstancesAction(Environment *,ConstructHeader *,void *);
|
136
|
+
#else
|
137
|
+
static void RuntimeDefinstancesAction(Environment *,ConstructHeader *,void *);
|
138
|
+
#endif
|
139
|
+
|
140
|
+
static void ResetDefinstances(Environment *,void *);
|
141
|
+
static void ResetDefinstancesAction(Environment *,ConstructHeader *,void *);
|
142
|
+
static void DeallocateDefinstancesData(Environment *);
|
143
|
+
|
144
|
+
/* =========================================
|
145
|
+
*****************************************
|
146
|
+
EXTERNALLY VISIBLE FUNCTIONS
|
147
|
+
=========================================
|
148
|
+
***************************************** */
|
149
|
+
|
150
|
+
/***************************************************
|
151
|
+
NAME : SetupDefinstances
|
152
|
+
DESCRIPTION : Adds the definstance support routines
|
153
|
+
to the Kernel
|
154
|
+
INPUTS : None
|
155
|
+
RETURNS : Nothing useful
|
156
|
+
SIDE EFFECTS : Appropriate function lists modified
|
157
|
+
NOTES : None
|
158
|
+
***************************************************/
|
159
|
+
void SetupDefinstances(
|
160
|
+
Environment *theEnv)
|
161
|
+
{
|
162
|
+
AllocateEnvironmentData(theEnv,DEFINSTANCES_DATA,sizeof(struct definstancesData),DeallocateDefinstancesData);
|
163
|
+
|
164
|
+
DefinstancesData(theEnv)->DefinstancesModuleIndex =
|
165
|
+
RegisterModuleItem(theEnv,"definstances",
|
166
|
+
#if (! RUN_TIME)
|
167
|
+
AllocateModule,
|
168
|
+
ReturnModule,
|
169
|
+
#else
|
170
|
+
NULL,NULL,
|
171
|
+
#endif
|
172
|
+
#if BLOAD_AND_BSAVE || BLOAD || BLOAD_ONLY
|
173
|
+
BloadDefinstancesModuleRef,
|
174
|
+
#else
|
175
|
+
NULL,
|
176
|
+
#endif
|
177
|
+
#if CONSTRUCT_COMPILER && (! RUN_TIME)
|
178
|
+
DefinstancesCModuleReference,
|
179
|
+
#else
|
180
|
+
NULL,
|
181
|
+
#endif
|
182
|
+
(FindConstructFunction *) FindDefinstancesInModule);
|
183
|
+
|
184
|
+
DefinstancesData(theEnv)->DefinstancesConstruct =
|
185
|
+
AddConstruct(theEnv,"definstances","definstances",
|
186
|
+
#if (! BLOAD_ONLY) && (! RUN_TIME)
|
187
|
+
ParseDefinstances,
|
188
|
+
#else
|
189
|
+
NULL,
|
190
|
+
#endif
|
191
|
+
(FindConstructFunction *) FindDefinstances,
|
192
|
+
GetConstructNamePointer,GetConstructPPForm,
|
193
|
+
GetConstructModuleItem,
|
194
|
+
(GetNextConstructFunction *) GetNextDefinstances,
|
195
|
+
SetNextConstruct,
|
196
|
+
(IsConstructDeletableFunction *) DefinstancesIsDeletable,
|
197
|
+
(DeleteConstructFunction *) Undefinstances,
|
198
|
+
#if (! BLOAD_ONLY) && (! RUN_TIME)
|
199
|
+
(FreeConstructFunction *) RemoveDefinstances
|
200
|
+
#else
|
201
|
+
NULL
|
202
|
+
#endif
|
203
|
+
);
|
204
|
+
|
205
|
+
#if ! RUN_TIME
|
206
|
+
AddClearReadyFunction(theEnv,"definstances",ClearDefinstancesReady,0,NULL);
|
207
|
+
|
208
|
+
#if ! BLOAD_ONLY
|
209
|
+
AddUDF(theEnv,"undefinstances","v",1,1,"y",UndefinstancesCommand,"UndefinstancesCommand",NULL);
|
210
|
+
AddSaveFunction(theEnv,"definstances",SaveDefinstances,0,NULL);
|
211
|
+
#endif
|
212
|
+
|
213
|
+
#if DEBUGGING_FUNCTIONS
|
214
|
+
AddUDF(theEnv,"ppdefinstances","vs",1,2,";y;ldsyn",PPDefinstancesCommand,"PPDefinstancesCommand",NULL);
|
215
|
+
AddUDF(theEnv,"list-definstances","v",0,1,"y",ListDefinstancesCommand,"ListDefinstancesCommand",NULL);
|
216
|
+
#endif
|
217
|
+
|
218
|
+
AddUDF(theEnv,"get-definstances-list","m",0,1,"y",GetDefinstancesListFunction,"GetDefinstancesListFunction",NULL);
|
219
|
+
AddUDF(theEnv,"definstances-module","y",1,1,"y",GetDefinstancesModuleCommand,"GetDefinstancesModuleCommand",NULL);
|
220
|
+
|
221
|
+
#endif
|
222
|
+
AddResetFunction(theEnv,"definstances",ResetDefinstances,0,NULL);
|
223
|
+
|
224
|
+
#if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE
|
225
|
+
SetupDefinstancesBload(theEnv);
|
226
|
+
#endif
|
227
|
+
|
228
|
+
#if CONSTRUCT_COMPILER && (! RUN_TIME)
|
229
|
+
SetupDefinstancesCompiler(theEnv);
|
230
|
+
#endif
|
231
|
+
}
|
232
|
+
|
233
|
+
/*******************************************************/
|
234
|
+
/* DeallocateDefinstancesData: Deallocates environment */
|
235
|
+
/* data for the definstances construct. */
|
236
|
+
/*******************************************************/
|
237
|
+
static void DeallocateDefinstancesData(
|
238
|
+
Environment *theEnv)
|
239
|
+
{
|
240
|
+
#if ! RUN_TIME
|
241
|
+
struct definstancesModule *theModuleItem;
|
242
|
+
Defmodule *theModule;
|
243
|
+
|
244
|
+
#if BLOAD || BLOAD_AND_BSAVE
|
245
|
+
if (Bloaded(theEnv)) return;
|
246
|
+
#endif
|
247
|
+
|
248
|
+
DoForAllConstructs(theEnv,DestroyDefinstancesAction,DefinstancesData(theEnv)->DefinstancesModuleIndex,false,NULL);
|
249
|
+
|
250
|
+
for (theModule = GetNextDefmodule(theEnv,NULL);
|
251
|
+
theModule != NULL;
|
252
|
+
theModule = GetNextDefmodule(theEnv,theModule))
|
253
|
+
{
|
254
|
+
theModuleItem = (struct definstancesModule *)
|
255
|
+
GetModuleItem(theEnv,theModule,
|
256
|
+
DefinstancesData(theEnv)->DefinstancesModuleIndex);
|
257
|
+
rtn_struct(theEnv,definstancesModule,theModuleItem);
|
258
|
+
}
|
259
|
+
#else
|
260
|
+
#if MAC_XCD
|
261
|
+
#pragma unused(theEnv)
|
262
|
+
#endif
|
263
|
+
#endif
|
264
|
+
}
|
265
|
+
|
266
|
+
#if ! RUN_TIME
|
267
|
+
/*****************************************************/
|
268
|
+
/* DestroyDefinstancesAction: Action used to remove */
|
269
|
+
/* definstances as a result of DestroyEnvironment. */
|
270
|
+
/*****************************************************/
|
271
|
+
static void DestroyDefinstancesAction(
|
272
|
+
Environment *theEnv,
|
273
|
+
ConstructHeader *theConstruct,
|
274
|
+
void *buffer)
|
275
|
+
{
|
276
|
+
#if MAC_XCD
|
277
|
+
#pragma unused(buffer)
|
278
|
+
#endif
|
279
|
+
#if (! BLOAD_ONLY) && (! RUN_TIME)
|
280
|
+
struct definstances *theDefinstances = (struct definstances *) theConstruct;
|
281
|
+
|
282
|
+
if (theDefinstances == NULL) return;
|
283
|
+
|
284
|
+
ReturnPackedExpression(theEnv,theDefinstances->mkinstance);
|
285
|
+
|
286
|
+
DestroyConstructHeader(theEnv,&theDefinstances->header);
|
287
|
+
|
288
|
+
rtn_struct(theEnv,definstances,theDefinstances);
|
289
|
+
#else
|
290
|
+
#if MAC_XCD
|
291
|
+
#pragma unused(theConstruct,theEnv)
|
292
|
+
#endif
|
293
|
+
#endif
|
294
|
+
}
|
295
|
+
#endif
|
296
|
+
|
297
|
+
#if RUN_TIME
|
298
|
+
|
299
|
+
/***************************************************/
|
300
|
+
/* RuntimeDefinstancesAction: Action to be applied */
|
301
|
+
/* to each definstances construct when a runtime */
|
302
|
+
/* initialization occurs. */
|
303
|
+
/***************************************************/
|
304
|
+
static void RuntimeDefinstancesAction(
|
305
|
+
Environment *theEnv,
|
306
|
+
ConstructHeader *theConstruct,
|
307
|
+
void *buffer)
|
308
|
+
{
|
309
|
+
#if MAC_XCD
|
310
|
+
#pragma unused(buffer)
|
311
|
+
#endif
|
312
|
+
Definstances *theDefinstances = (Definstances *) theConstruct;
|
313
|
+
|
314
|
+
theDefinstances->header.env = theEnv;
|
315
|
+
}
|
316
|
+
|
317
|
+
/**********************************/
|
318
|
+
/* DefinstancesRunTimeInitialize: */
|
319
|
+
/**********************************/
|
320
|
+
void DefinstancesRunTimeInitialize(
|
321
|
+
Environment *theEnv)
|
322
|
+
{
|
323
|
+
DoForAllConstructs(theEnv,RuntimeDefinstancesAction,DefinstancesData(theEnv)->DefinstancesModuleIndex,true,NULL);
|
324
|
+
}
|
325
|
+
|
326
|
+
#endif
|
327
|
+
|
328
|
+
/***********************************************************
|
329
|
+
NAME : GetNextDefinstances
|
330
|
+
DESCRIPTION : Finds first or next definstances
|
331
|
+
INPUTS : The address of the current definstances
|
332
|
+
RETURNS : The address of the next definstances
|
333
|
+
(NULL if none)
|
334
|
+
SIDE EFFECTS : None
|
335
|
+
NOTES : If ptr == NULL, the first definstances
|
336
|
+
is returned.
|
337
|
+
***********************************************************/
|
338
|
+
Definstances *GetNextDefinstances(
|
339
|
+
Environment *theEnv,
|
340
|
+
Definstances *theDefinstances)
|
341
|
+
{
|
342
|
+
return (Definstances *) GetNextConstructItem(theEnv,&theDefinstances->header,
|
343
|
+
DefinstancesData(theEnv)->DefinstancesModuleIndex);
|
344
|
+
}
|
345
|
+
|
346
|
+
/***************************************************
|
347
|
+
NAME : FindDefinstances
|
348
|
+
DESCRIPTION : Looks up a definstance construct
|
349
|
+
by name-string
|
350
|
+
INPUTS : The symbolic name
|
351
|
+
RETURNS : The definstance address, or NULL
|
352
|
+
if not found
|
353
|
+
SIDE EFFECTS : None
|
354
|
+
NOTES : None
|
355
|
+
***************************************************/
|
356
|
+
Definstances *FindDefinstances(
|
357
|
+
Environment *theEnv,
|
358
|
+
const char *name)
|
359
|
+
{
|
360
|
+
return (Definstances *) FindNamedConstructInModuleOrImports(theEnv,name,DefinstancesData(theEnv)->DefinstancesConstruct);
|
361
|
+
}
|
362
|
+
|
363
|
+
/***************************************************
|
364
|
+
NAME : FindDefinstancesInModule
|
365
|
+
DESCRIPTION : Looks up a definstance construct
|
366
|
+
by name-string
|
367
|
+
INPUTS : The symbolic name
|
368
|
+
RETURNS : The definstance address, or NULL
|
369
|
+
if not found
|
370
|
+
SIDE EFFECTS : None
|
371
|
+
NOTES : None
|
372
|
+
***************************************************/
|
373
|
+
Definstances *FindDefinstancesInModule(
|
374
|
+
Environment *theEnv,
|
375
|
+
const char *name)
|
376
|
+
{
|
377
|
+
return (Definstances *) FindNamedConstructInModule(theEnv,name,DefinstancesData(theEnv)->DefinstancesConstruct);
|
378
|
+
}
|
379
|
+
|
380
|
+
/***************************************************
|
381
|
+
NAME : DefinstancesIsDeletable
|
382
|
+
DESCRIPTION : Determines if a definstances
|
383
|
+
can be deleted
|
384
|
+
INPUTS : Address of the definstances
|
385
|
+
RETURNS : True if deletable, false otherwise
|
386
|
+
SIDE EFFECTS : None
|
387
|
+
NOTES : None
|
388
|
+
***************************************************/
|
389
|
+
bool DefinstancesIsDeletable(
|
390
|
+
Definstances *theDefinstances)
|
391
|
+
{
|
392
|
+
Environment *theEnv = theDefinstances->header.env;
|
393
|
+
|
394
|
+
if (! ConstructsDeletable(theEnv))
|
395
|
+
{ return false; }
|
396
|
+
|
397
|
+
return (theDefinstances->busy == 0) ? true : false;
|
398
|
+
}
|
399
|
+
|
400
|
+
/***********************************************************
|
401
|
+
NAME : UndefinstancesCommand
|
402
|
+
DESCRIPTION : Removes a definstance
|
403
|
+
INPUTS : None
|
404
|
+
RETURNS : Nothing useful
|
405
|
+
SIDE EFFECTS : Definstance deallocated
|
406
|
+
NOTES : H/L Syntax : (undefinstances <name> | *)
|
407
|
+
***********************************************************/
|
408
|
+
void UndefinstancesCommand(
|
409
|
+
Environment *theEnv,
|
410
|
+
UDFContext *context,
|
411
|
+
UDFValue *returnValue)
|
412
|
+
{
|
413
|
+
UndefconstructCommand(context,"undefinstances",DefinstancesData(theEnv)->DefinstancesConstruct);
|
414
|
+
}
|
415
|
+
|
416
|
+
/*****************************************************************
|
417
|
+
NAME : GetDefinstancesModuleCommand
|
418
|
+
DESCRIPTION : Determines to which module a definstances belongs
|
419
|
+
INPUTS : None
|
420
|
+
RETURNS : The symbolic name of the module
|
421
|
+
SIDE EFFECTS : None
|
422
|
+
NOTES : H/L Syntax: (definstances-module <defins-name>)
|
423
|
+
*****************************************************************/
|
424
|
+
void GetDefinstancesModuleCommand(
|
425
|
+
Environment *theEnv,
|
426
|
+
UDFContext *context,
|
427
|
+
UDFValue *returnValue)
|
428
|
+
{
|
429
|
+
returnValue->value = GetConstructModuleCommand(context,"definstances-module",DefinstancesData(theEnv)->DefinstancesConstruct);
|
430
|
+
}
|
431
|
+
|
432
|
+
/***********************************************************
|
433
|
+
NAME : Undefinstances
|
434
|
+
DESCRIPTION : Removes a definstance
|
435
|
+
INPUTS : Address of definstances to remove
|
436
|
+
RETURNS : True if successful,
|
437
|
+
false otherwise
|
438
|
+
SIDE EFFECTS : Definstance deallocated
|
439
|
+
NOTES : None
|
440
|
+
***********************************************************/
|
441
|
+
bool Undefinstances(
|
442
|
+
Definstances *theDefinstances,
|
443
|
+
Environment *allEnv)
|
444
|
+
{
|
445
|
+
Environment *theEnv;
|
446
|
+
|
447
|
+
if (theDefinstances == NULL)
|
448
|
+
{
|
449
|
+
theEnv = allEnv;
|
450
|
+
return Undefconstruct(theEnv,NULL,DefinstancesData(theEnv)->DefinstancesConstruct);
|
451
|
+
}
|
452
|
+
else
|
453
|
+
{
|
454
|
+
theEnv = theDefinstances->header.env;
|
455
|
+
return Undefconstruct(theEnv,&theDefinstances->header,DefinstancesData(theEnv)->DefinstancesConstruct);
|
456
|
+
}
|
457
|
+
}
|
458
|
+
|
459
|
+
#if DEBUGGING_FUNCTIONS
|
460
|
+
|
461
|
+
/***************************************************************
|
462
|
+
NAME : PPDefinstancesCommand
|
463
|
+
DESCRIPTION : Prints out the pretty-print form of a definstance
|
464
|
+
INPUTS : None
|
465
|
+
RETURNS : Nothing useful
|
466
|
+
SIDE EFFECTS : None
|
467
|
+
NOTES : H/L Syntax : (ppdefinstances <name>)
|
468
|
+
***************************************************************/
|
469
|
+
void PPDefinstancesCommand(
|
470
|
+
Environment *theEnv,
|
471
|
+
UDFContext *context,
|
472
|
+
UDFValue *returnValue)
|
473
|
+
{
|
474
|
+
PPConstructCommand(context,"ppdefinstances",DefinstancesData(theEnv)->DefinstancesConstruct,returnValue);
|
475
|
+
}
|
476
|
+
|
477
|
+
/***************************************************
|
478
|
+
NAME : ListDefinstancesCommand
|
479
|
+
DESCRIPTION : Displays all definstances names
|
480
|
+
INPUTS : None
|
481
|
+
RETURNS : Nothing useful
|
482
|
+
SIDE EFFECTS : Definstances name sprinted
|
483
|
+
NOTES : H/L Interface
|
484
|
+
***************************************************/
|
485
|
+
void ListDefinstancesCommand(
|
486
|
+
Environment *theEnv,
|
487
|
+
UDFContext *context,
|
488
|
+
UDFValue *returnValue)
|
489
|
+
{
|
490
|
+
ListConstructCommand(context,DefinstancesData(theEnv)->DefinstancesConstruct);
|
491
|
+
}
|
492
|
+
|
493
|
+
/***************************************************
|
494
|
+
NAME : ListDefinstances
|
495
|
+
DESCRIPTION : Displays all definstances names
|
496
|
+
INPUTS : 1) The logical name of the output
|
497
|
+
2) The module
|
498
|
+
RETURNS : Nothing useful
|
499
|
+
SIDE EFFECTS : Definstances names printed
|
500
|
+
NOTES : C Interface
|
501
|
+
***************************************************/
|
502
|
+
void ListDefinstances(
|
503
|
+
Environment *theEnv,
|
504
|
+
const char *logicalName,
|
505
|
+
Defmodule *theModule)
|
506
|
+
{
|
507
|
+
ListConstruct(theEnv,DefinstancesData(theEnv)->DefinstancesConstruct,logicalName,theModule);
|
508
|
+
}
|
509
|
+
|
510
|
+
#endif
|
511
|
+
|
512
|
+
/****************************************************************
|
513
|
+
NAME : GetDefinstancesListFunction
|
514
|
+
DESCRIPTION : Groups all definstances names into
|
515
|
+
a multifield list
|
516
|
+
INPUTS : A data object buffer to hold
|
517
|
+
the multifield result
|
518
|
+
RETURNS : Nothing useful
|
519
|
+
SIDE EFFECTS : Multifield allocated and filled
|
520
|
+
NOTES : H/L Syntax: (get-definstances-list [<module>])
|
521
|
+
****************************************************************/
|
522
|
+
void GetDefinstancesListFunction(
|
523
|
+
Environment *theEnv,
|
524
|
+
UDFContext *context,
|
525
|
+
UDFValue *returnValue)
|
526
|
+
{
|
527
|
+
GetConstructListFunction(context,returnValue,DefinstancesData(theEnv)->DefinstancesConstruct);
|
528
|
+
}
|
529
|
+
|
530
|
+
/***************************************************************
|
531
|
+
NAME : GetDefinstancesList
|
532
|
+
DESCRIPTION : Groups all definstances names into
|
533
|
+
a multifield list
|
534
|
+
INPUTS : 1) A data object buffer to hold
|
535
|
+
the multifield result
|
536
|
+
2) The module from which to obtain definstances
|
537
|
+
RETURNS : Nothing useful
|
538
|
+
SIDE EFFECTS : Multifield allocated and filled
|
539
|
+
NOTES : External C access
|
540
|
+
***************************************************************/
|
541
|
+
void GetDefinstancesList(
|
542
|
+
Environment *theEnv,
|
543
|
+
CLIPSValue *returnValue,
|
544
|
+
Defmodule *theModule)
|
545
|
+
{
|
546
|
+
UDFValue result;
|
547
|
+
|
548
|
+
GetConstructList(theEnv,&result,DefinstancesData(theEnv)->DefinstancesConstruct,theModule);
|
549
|
+
NormalizeMultifield(theEnv,&result);
|
550
|
+
returnValue->value = result.value;
|
551
|
+
}
|
552
|
+
|
553
|
+
/* =========================================
|
554
|
+
*****************************************
|
555
|
+
INTERNALLY VISIBLE FUNCTIONS
|
556
|
+
=========================================
|
557
|
+
***************************************** */
|
558
|
+
|
559
|
+
#if (! BLOAD_ONLY) && (! RUN_TIME)
|
560
|
+
|
561
|
+
/*********************************************************************
|
562
|
+
NAME : ParseDefinstances
|
563
|
+
DESCRIPTION : Parses and allocates a definstances construct
|
564
|
+
INPUTS : The logical name of the input source
|
565
|
+
RETURNS : False if no errors, true otherwise
|
566
|
+
SIDE EFFECTS : Definstances parsed and created
|
567
|
+
NOTES : H/L Syntax :
|
568
|
+
|
569
|
+
(definstances <name> [active] [<comment>]
|
570
|
+
<instance-definition>+)
|
571
|
+
|
572
|
+
<instance-definition> ::=
|
573
|
+
(<instance-name> of <class-name> <slot-override>*)
|
574
|
+
|
575
|
+
<slot-override> ::= (<slot-name> <value-expression>*)
|
576
|
+
*********************************************************************/
|
577
|
+
static bool ParseDefinstances(
|
578
|
+
Environment *theEnv,
|
579
|
+
const char *readSource)
|
580
|
+
{
|
581
|
+
CLIPSLexeme *dname;
|
582
|
+
struct functionDefinition *mkinsfcall;
|
583
|
+
Expression *mkinstance,*mkbot = NULL;
|
584
|
+
Definstances *dobj;
|
585
|
+
bool active;
|
586
|
+
|
587
|
+
SetPPBufferStatus(theEnv,true);
|
588
|
+
FlushPPBuffer(theEnv);
|
589
|
+
SetIndentDepth(theEnv,3);
|
590
|
+
SavePPBuffer(theEnv,"(definstances ");
|
591
|
+
|
592
|
+
#if BLOAD || BLOAD_AND_BSAVE
|
593
|
+
if ((Bloaded(theEnv)) && (! ConstructData(theEnv)->CheckSyntaxMode))
|
594
|
+
{
|
595
|
+
CannotLoadWithBloadMessage(theEnv,"definstances");
|
596
|
+
return true;
|
597
|
+
}
|
598
|
+
#endif
|
599
|
+
dname = ParseDefinstancesName(theEnv,readSource,&active);
|
600
|
+
if (dname == NULL)
|
601
|
+
return true;
|
602
|
+
|
603
|
+
dobj = get_struct(theEnv,definstances);
|
604
|
+
InitializeConstructHeader(theEnv,"definstances",DEFINSTANCES,&dobj->header,dname);
|
605
|
+
dobj->busy = 0;
|
606
|
+
dobj->mkinstance = NULL;
|
607
|
+
#if DEFRULE_CONSTRUCT
|
608
|
+
if (active)
|
609
|
+
mkinsfcall = FindFunction(theEnv,"active-make-instance");
|
610
|
+
else
|
611
|
+
mkinsfcall = FindFunction(theEnv,"make-instance");
|
612
|
+
#else
|
613
|
+
mkinsfcall = FindFunction(theEnv,"make-instance");
|
614
|
+
#endif
|
615
|
+
while (DefclassData(theEnv)->ObjectParseToken.tknType == LEFT_PARENTHESIS_TOKEN)
|
616
|
+
{
|
617
|
+
mkinstance = GenConstant(theEnv,UNKNOWN_VALUE,mkinsfcall);
|
618
|
+
mkinstance = ParseInitializeInstance(theEnv,mkinstance,readSource);
|
619
|
+
if (mkinstance == NULL)
|
620
|
+
{
|
621
|
+
ReturnExpression(theEnv,dobj->mkinstance);
|
622
|
+
rtn_struct(theEnv,definstances,dobj);
|
623
|
+
return true;
|
624
|
+
}
|
625
|
+
if (ExpressionContainsVariables(mkinstance,false) == true)
|
626
|
+
{
|
627
|
+
LocalVariableErrorMessage(theEnv,"definstances");
|
628
|
+
ReturnExpression(theEnv,mkinstance);
|
629
|
+
ReturnExpression(theEnv,dobj->mkinstance);
|
630
|
+
rtn_struct(theEnv,definstances,dobj);
|
631
|
+
return true;
|
632
|
+
}
|
633
|
+
if (mkbot == NULL)
|
634
|
+
dobj->mkinstance = mkinstance;
|
635
|
+
else
|
636
|
+
GetNextArgument(mkbot) = mkinstance;
|
637
|
+
mkbot = mkinstance;
|
638
|
+
GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken);
|
639
|
+
PPBackup(theEnv);
|
640
|
+
PPCRAndIndent(theEnv);
|
641
|
+
SavePPBuffer(theEnv,DefclassData(theEnv)->ObjectParseToken.printForm);
|
642
|
+
}
|
643
|
+
|
644
|
+
if (DefclassData(theEnv)->ObjectParseToken.tknType != RIGHT_PARENTHESIS_TOKEN)
|
645
|
+
{
|
646
|
+
ReturnExpression(theEnv,dobj->mkinstance);
|
647
|
+
rtn_struct(theEnv,definstances,dobj);
|
648
|
+
SyntaxErrorMessage(theEnv,"definstances");
|
649
|
+
return true;
|
650
|
+
}
|
651
|
+
else
|
652
|
+
{
|
653
|
+
if (ConstructData(theEnv)->CheckSyntaxMode)
|
654
|
+
{
|
655
|
+
ReturnExpression(theEnv,dobj->mkinstance);
|
656
|
+
rtn_struct(theEnv,definstances,dobj);
|
657
|
+
return false;
|
658
|
+
}
|
659
|
+
#if DEBUGGING_FUNCTIONS
|
660
|
+
if (GetConserveMemory(theEnv) == false)
|
661
|
+
{
|
662
|
+
if (dobj->mkinstance != NULL)
|
663
|
+
PPBackup(theEnv);
|
664
|
+
PPBackup(theEnv);
|
665
|
+
SavePPBuffer(theEnv,")\n");
|
666
|
+
SetDefinstancesPPForm(theEnv,dobj,CopyPPBuffer(theEnv));
|
667
|
+
}
|
668
|
+
#endif
|
669
|
+
mkinstance = dobj->mkinstance;
|
670
|
+
dobj->mkinstance = PackExpression(theEnv,mkinstance);
|
671
|
+
ReturnExpression(theEnv,mkinstance);
|
672
|
+
IncrementLexemeCount(GetDefinstancesNamePointer(theEnv,dobj));
|
673
|
+
ExpressionInstall(theEnv,dobj->mkinstance);
|
674
|
+
}
|
675
|
+
|
676
|
+
AddConstructToModule(&dobj->header);
|
677
|
+
return false;
|
678
|
+
}
|
679
|
+
|
680
|
+
/*************************************************************
|
681
|
+
NAME : ParseDefinstancesName
|
682
|
+
DESCRIPTION : Parses definstance name and optional comment
|
683
|
+
and optional "active" keyword
|
684
|
+
INPUTS : 1) The logical name of the input source
|
685
|
+
2) Buffer to hold flag indicating if
|
686
|
+
definstances should cause pattern-matching
|
687
|
+
to occur during slot-overrides
|
688
|
+
RETURNS : Address of name symbol, or
|
689
|
+
NULL if there was an error
|
690
|
+
SIDE EFFECTS : Token after name or comment is scanned
|
691
|
+
NOTES : Assumes "(definstances" has already
|
692
|
+
been scanned.
|
693
|
+
*************************************************************/
|
694
|
+
static CLIPSLexeme *ParseDefinstancesName(
|
695
|
+
Environment *theEnv,
|
696
|
+
const char *readSource,
|
697
|
+
bool *active)
|
698
|
+
{
|
699
|
+
CLIPSLexeme *dname;
|
700
|
+
|
701
|
+
*active = false;
|
702
|
+
dname = GetConstructNameAndComment(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken,"definstances",
|
703
|
+
(FindConstructFunction *) FindDefinstancesInModule,
|
704
|
+
(DeleteConstructFunction *) Undefinstances,"@",
|
705
|
+
true,false,true,false);
|
706
|
+
if (dname == NULL)
|
707
|
+
return NULL;
|
708
|
+
|
709
|
+
#if DEFRULE_CONSTRUCT
|
710
|
+
if ((DefclassData(theEnv)->ObjectParseToken.tknType != SYMBOL_TOKEN) ? false :
|
711
|
+
(strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,ACTIVE_RLN) == 0))
|
712
|
+
{
|
713
|
+
PPBackup(theEnv);
|
714
|
+
PPBackup(theEnv);
|
715
|
+
SavePPBuffer(theEnv," ");
|
716
|
+
SavePPBuffer(theEnv,DefclassData(theEnv)->ObjectParseToken.printForm);
|
717
|
+
PPCRAndIndent(theEnv);
|
718
|
+
GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken);
|
719
|
+
*active = true;
|
720
|
+
}
|
721
|
+
#endif
|
722
|
+
if (DefclassData(theEnv)->ObjectParseToken.tknType == STRING_TOKEN)
|
723
|
+
{
|
724
|
+
PPBackup(theEnv);
|
725
|
+
PPBackup(theEnv);
|
726
|
+
SavePPBuffer(theEnv," ");
|
727
|
+
SavePPBuffer(theEnv,DefclassData(theEnv)->ObjectParseToken.printForm);
|
728
|
+
PPCRAndIndent(theEnv);
|
729
|
+
GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken);
|
730
|
+
}
|
731
|
+
return(dname);
|
732
|
+
}
|
733
|
+
|
734
|
+
/**************************************************************
|
735
|
+
NAME : RemoveDefinstances
|
736
|
+
DESCRIPTION : Deallocates and removes a definstance construct
|
737
|
+
INPUTS : The definstance address
|
738
|
+
RETURNS : Nothing useful
|
739
|
+
SIDE EFFECTS : Existing definstance construct deleted
|
740
|
+
NOTES : Assumes busy count of definstance is 0
|
741
|
+
**************************************************************/
|
742
|
+
static void RemoveDefinstances(
|
743
|
+
Environment *theEnv,
|
744
|
+
Definstances *theDefinstances)
|
745
|
+
{
|
746
|
+
ReleaseLexeme(theEnv,theDefinstances->header.name);
|
747
|
+
ExpressionDeinstall(theEnv,theDefinstances->mkinstance);
|
748
|
+
ReturnPackedExpression(theEnv,theDefinstances->mkinstance);
|
749
|
+
SetDefinstancesPPForm(theEnv,theDefinstances,NULL);
|
750
|
+
ClearUserDataList(theEnv,theDefinstances->header.usrData);
|
751
|
+
rtn_struct(theEnv,definstances,theDefinstances);
|
752
|
+
}
|
753
|
+
|
754
|
+
/***************************************************
|
755
|
+
NAME : SaveDefinstances
|
756
|
+
DESCRIPTION : Prints pretty print form of
|
757
|
+
definstances to specified output
|
758
|
+
INPUTS : The logical name of the output
|
759
|
+
RETURNS : Nothing useful
|
760
|
+
SIDE EFFECTS : None
|
761
|
+
NOTES : None
|
762
|
+
***************************************************/
|
763
|
+
static void SaveDefinstances(
|
764
|
+
Environment *theEnv,
|
765
|
+
Defmodule *theModule,
|
766
|
+
const char *logName,
|
767
|
+
void *context)
|
768
|
+
{
|
769
|
+
SaveConstruct(theEnv,theModule,logName,DefinstancesData(theEnv)->DefinstancesConstruct);
|
770
|
+
}
|
771
|
+
|
772
|
+
#endif
|
773
|
+
|
774
|
+
#if ! RUN_TIME
|
775
|
+
|
776
|
+
/*****************************************************
|
777
|
+
NAME : AllocateModule
|
778
|
+
DESCRIPTION : Creates and initializes a
|
779
|
+
list of definstances for a new module
|
780
|
+
INPUTS : None
|
781
|
+
RETURNS : The new definstances module
|
782
|
+
SIDE EFFECTS : Definstances module created
|
783
|
+
NOTES : None
|
784
|
+
*****************************************************/
|
785
|
+
static void *AllocateModule(
|
786
|
+
Environment *theEnv)
|
787
|
+
{
|
788
|
+
return (void *) get_struct(theEnv,definstancesModule);
|
789
|
+
}
|
790
|
+
|
791
|
+
/***************************************************
|
792
|
+
NAME : ReturnModule
|
793
|
+
DESCRIPTION : Removes a definstances module and
|
794
|
+
all associated definstances
|
795
|
+
INPUTS : The definstances module
|
796
|
+
RETURNS : Nothing useful
|
797
|
+
SIDE EFFECTS : Module and definstances deleted
|
798
|
+
NOTES : None
|
799
|
+
***************************************************/
|
800
|
+
static void ReturnModule(
|
801
|
+
Environment *theEnv,
|
802
|
+
void *theItem)
|
803
|
+
{
|
804
|
+
#if (! BLOAD_ONLY)
|
805
|
+
FreeConstructHeaderModule(theEnv,(struct defmoduleItemHeader *) theItem,DefinstancesData(theEnv)->DefinstancesConstruct);
|
806
|
+
#endif
|
807
|
+
rtn_struct(theEnv,definstancesModule,theItem);
|
808
|
+
}
|
809
|
+
|
810
|
+
/***************************************************
|
811
|
+
NAME : ClearDefinstancesReady
|
812
|
+
DESCRIPTION : Determines if it is safe to
|
813
|
+
remove all definstances
|
814
|
+
Assumes *all* constructs will be
|
815
|
+
deleted
|
816
|
+
INPUTS : None
|
817
|
+
RETURNS : True if all definstances can
|
818
|
+
be deleted, false otherwise
|
819
|
+
SIDE EFFECTS : None
|
820
|
+
NOTES : Used by (clear) and (bload)
|
821
|
+
***************************************************/
|
822
|
+
static bool ClearDefinstancesReady(
|
823
|
+
Environment *theEnv,
|
824
|
+
void *context)
|
825
|
+
{
|
826
|
+
bool flagBuffer = true;
|
827
|
+
|
828
|
+
DoForAllConstructs(theEnv,CheckDefinstancesBusy,DefinstancesData(theEnv)->DefinstancesModuleIndex,
|
829
|
+
false,&flagBuffer);
|
830
|
+
return(flagBuffer);
|
831
|
+
}
|
832
|
+
|
833
|
+
/***************************************************
|
834
|
+
NAME : CheckDefinstancesBusy
|
835
|
+
DESCRIPTION : Determines if a definstances is
|
836
|
+
in use or not
|
837
|
+
INPUTS : 1) The definstances
|
838
|
+
2) A buffer to set to 0 if the
|
839
|
+
the definstances is busy
|
840
|
+
RETURNS : Nothing useful
|
841
|
+
SIDE EFFECTS : Buffer set to 0 if definstances
|
842
|
+
busy
|
843
|
+
NOTES : The flag buffer is not modified
|
844
|
+
if definstances is not busy
|
845
|
+
(assumed to be initialized to 1)
|
846
|
+
***************************************************/
|
847
|
+
static void CheckDefinstancesBusy(
|
848
|
+
Environment *theEnv,
|
849
|
+
ConstructHeader *theDefinstances,
|
850
|
+
void *userBuffer)
|
851
|
+
{
|
852
|
+
#if MAC_XCD
|
853
|
+
#pragma unused(theEnv)
|
854
|
+
#endif
|
855
|
+
|
856
|
+
if (((Definstances *) theDefinstances)->busy > 0)
|
857
|
+
{ *((bool *) userBuffer) = false; }
|
858
|
+
}
|
859
|
+
|
860
|
+
#endif
|
861
|
+
|
862
|
+
/***************************************************
|
863
|
+
NAME : ResetDefinstances
|
864
|
+
DESCRIPTION : Calls EvaluateExpression for each of
|
865
|
+
the make-instance calls in all
|
866
|
+
of the definstances constructs
|
867
|
+
INPUTS : None
|
868
|
+
RETURNS : Nothing useful
|
869
|
+
SIDE EFFECTS : All instances in the definstances
|
870
|
+
are evaluated (and created if
|
871
|
+
there are no errors)
|
872
|
+
Any previously existing instances
|
873
|
+
are deleted first.
|
874
|
+
NOTES : None
|
875
|
+
***************************************************/
|
876
|
+
static void ResetDefinstances(
|
877
|
+
Environment *theEnv,
|
878
|
+
void *context)
|
879
|
+
{
|
880
|
+
DoForAllConstructs(theEnv,ResetDefinstancesAction,DefinstancesData(theEnv)->DefinstancesModuleIndex,true,NULL);
|
881
|
+
}
|
882
|
+
|
883
|
+
/***************************************************
|
884
|
+
NAME : ResetDefinstancesAction
|
885
|
+
DESCRIPTION : Performs all the make-instance
|
886
|
+
calls in a definstances
|
887
|
+
INPUTS : 1) The definstances
|
888
|
+
2) User data buffer (ignored)
|
889
|
+
RETURNS : Nothing useful
|
890
|
+
SIDE EFFECTS : Instances created
|
891
|
+
NOTES : None
|
892
|
+
***************************************************/
|
893
|
+
static void ResetDefinstancesAction(
|
894
|
+
Environment *theEnv,
|
895
|
+
ConstructHeader *vDefinstances,
|
896
|
+
void *userBuffer)
|
897
|
+
{
|
898
|
+
#if MAC_XCD
|
899
|
+
#pragma unused(userBuffer)
|
900
|
+
#endif
|
901
|
+
Definstances *theDefinstances = (Definstances *) vDefinstances;
|
902
|
+
Expression *theExp;
|
903
|
+
UDFValue temp;
|
904
|
+
|
905
|
+
SaveCurrentModule(theEnv);
|
906
|
+
SetCurrentModule(theEnv,vDefinstances->whichModule->theModule);
|
907
|
+
theDefinstances->busy++;
|
908
|
+
for (theExp = theDefinstances->mkinstance ;
|
909
|
+
theExp != NULL ;
|
910
|
+
theExp = GetNextArgument(theExp))
|
911
|
+
{
|
912
|
+
EvaluateExpression(theEnv,theExp,&temp);
|
913
|
+
if (EvaluationData(theEnv)->HaltExecution ||
|
914
|
+
(temp.value == FalseSymbol(theEnv)))
|
915
|
+
{
|
916
|
+
RestoreCurrentModule(theEnv);
|
917
|
+
theDefinstances->busy--;
|
918
|
+
return;
|
919
|
+
}
|
920
|
+
}
|
921
|
+
theDefinstances->busy--;
|
922
|
+
RestoreCurrentModule(theEnv);
|
923
|
+
}
|
924
|
+
|
925
|
+
/*##################################*/
|
926
|
+
/* Additional Environment Functions */
|
927
|
+
/*##################################*/
|
928
|
+
|
929
|
+
const char *DefinstancesName(
|
930
|
+
Definstances *theDefinstances)
|
931
|
+
{
|
932
|
+
return GetConstructNameString(&theDefinstances->header);
|
933
|
+
}
|
934
|
+
|
935
|
+
const char *DefinstancesPPForm(
|
936
|
+
Definstances *theDefinstances)
|
937
|
+
{
|
938
|
+
return GetConstructPPForm(&theDefinstances->header);
|
939
|
+
}
|
940
|
+
|
941
|
+
void SetDefinstancesPPForm(
|
942
|
+
Environment *theEnv,
|
943
|
+
Definstances *theDefinstances,
|
944
|
+
const char *thePPForm)
|
945
|
+
{
|
946
|
+
SetConstructPPForm(theEnv,&theDefinstances->header,thePPForm);
|
947
|
+
}
|
948
|
+
|
949
|
+
const char *DefinstancesModule(
|
950
|
+
Definstances *theDefinstances)
|
951
|
+
{
|
952
|
+
return GetConstructModuleName(&theDefinstances->header);
|
953
|
+
}
|
954
|
+
|
955
|
+
CLIPSLexeme *GetDefinstancesNamePointer(
|
956
|
+
Environment *theEnv,
|
957
|
+
Definstances *theDefinstances)
|
958
|
+
{
|
959
|
+
return GetConstructNamePointer(&theDefinstances->header);
|
960
|
+
}
|
961
|
+
|
962
|
+
const char *DefinstancesModuleName(
|
963
|
+
Environment *theEnv,
|
964
|
+
Definstances *theDefinstances)
|
965
|
+
{
|
966
|
+
return GetConstructModuleName(&theDefinstances->header);
|
967
|
+
}
|
968
|
+
|
969
|
+
#endif
|
970
|
+
|
971
|
+
|