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,1791 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.41 12/04/22 */
|
5
|
+
/* */
|
6
|
+
/* CONSTRUCT COMMANDS MODULE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: Contains generic routines for deleting, pretty */
|
11
|
+
/* printing, finding, obtaining module information, */
|
12
|
+
/* obtaining lists of constructs, listing constructs, and */
|
13
|
+
/* manipulation routines. */
|
14
|
+
/* */
|
15
|
+
/* Principal Programmer(s): */
|
16
|
+
/* Gary D. Riley */
|
17
|
+
/* Brian L. Dantes */
|
18
|
+
/* */
|
19
|
+
/* Contributing Programmer(s): */
|
20
|
+
/* */
|
21
|
+
/* Revision History: */
|
22
|
+
/* */
|
23
|
+
/* 6.23: Modified GetConstructList to remove buffer */
|
24
|
+
/* overflow problem with large construct/module */
|
25
|
+
/* names. DR0858 */
|
26
|
+
/* */
|
27
|
+
/* Changed name of variable log to logName */
|
28
|
+
/* because of Unix compiler warnings of shadowed */
|
29
|
+
/* definitions. */
|
30
|
+
/* */
|
31
|
+
/* Correction for FalseSymbol/TrueSymbol. DR0859 */
|
32
|
+
/* */
|
33
|
+
/* 6.24: Corrected an error when compiling as a C++ */
|
34
|
+
/* file. DR0868 */
|
35
|
+
/* */
|
36
|
+
/* Renamed BOOLEAN macro type to intBool. */
|
37
|
+
/* */
|
38
|
+
/* Added ConstructsDeletable function. */
|
39
|
+
/* */
|
40
|
+
/* 6.30: Added const qualifiers to remove C++ */
|
41
|
+
/* deprecation warnings. */
|
42
|
+
/* */
|
43
|
+
/* Change find construct functionality so that */
|
44
|
+
/* imported modules are search when locating a */
|
45
|
+
/* named construct. */
|
46
|
+
/* */
|
47
|
+
/* 6.31: Fixed use after free issue for deallocation */
|
48
|
+
/* functions passed to DoForAllConstructs. */
|
49
|
+
/* */
|
50
|
+
/* 6.32: Fixed embedded reset of error flags. */
|
51
|
+
/* */
|
52
|
+
/* 6.40: Added Env prefix to GetHaltExecution and */
|
53
|
+
/* SetHaltExecution functions. */
|
54
|
+
/* */
|
55
|
+
/* Pragma once and other inclusion changes. */
|
56
|
+
/* */
|
57
|
+
/* Added support for booleans with <stdbool.h>. */
|
58
|
+
/* */
|
59
|
+
/* Removed use of void pointers for specific */
|
60
|
+
/* data structures. */
|
61
|
+
/* */
|
62
|
+
/* UDF redesign. */
|
63
|
+
/* */
|
64
|
+
/* Pretty print functions accept optional logical */
|
65
|
+
/* name argument. */
|
66
|
+
/* */
|
67
|
+
/* 6.41: Used gensnprintf in place of gensprintf and. */
|
68
|
+
/* sprintf. */
|
69
|
+
/* */
|
70
|
+
/*************************************************************/
|
71
|
+
|
72
|
+
#include <string.h>
|
73
|
+
|
74
|
+
#include "setup.h"
|
75
|
+
|
76
|
+
#include "constant.h"
|
77
|
+
#include "envrnmnt.h"
|
78
|
+
#include "extnfunc.h"
|
79
|
+
#include "memalloc.h"
|
80
|
+
#include "moduldef.h"
|
81
|
+
#include "argacces.h"
|
82
|
+
#include "multifld.h"
|
83
|
+
#include "modulutl.h"
|
84
|
+
#include "prntutil.h"
|
85
|
+
#include "router.h"
|
86
|
+
#include "utility.h"
|
87
|
+
#include "commline.h"
|
88
|
+
#include "sysdep.h"
|
89
|
+
|
90
|
+
#if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE
|
91
|
+
#include "bload.h"
|
92
|
+
#endif
|
93
|
+
|
94
|
+
#if (! BLOAD_ONLY) && (! RUN_TIME)
|
95
|
+
#include "cstrcpsr.h"
|
96
|
+
#endif
|
97
|
+
|
98
|
+
#include "cstrccom.h"
|
99
|
+
|
100
|
+
/***************************************/
|
101
|
+
/* LOCAL INTERNAL FUNCTION DEFINITIONS */
|
102
|
+
/***************************************/
|
103
|
+
|
104
|
+
#if DEBUGGING_FUNCTIONS
|
105
|
+
static void ConstructPrintWatch(Environment *,const char *,Construct *,
|
106
|
+
ConstructHeader *,
|
107
|
+
ConstructGetWatchFunction *);
|
108
|
+
static bool ConstructWatchSupport(Environment *,Construct *,const char *,
|
109
|
+
const char *,Expression *,bool,
|
110
|
+
bool,ConstructGetWatchFunction *,
|
111
|
+
ConstructSetWatchFunction *);
|
112
|
+
#endif
|
113
|
+
|
114
|
+
#if (! RUN_TIME)
|
115
|
+
|
116
|
+
/************************************/
|
117
|
+
/* AddConstructToModule: Adds a */
|
118
|
+
/* construct to the current module. */
|
119
|
+
/************************************/
|
120
|
+
void AddConstructToModule(
|
121
|
+
ConstructHeader *theConstruct)
|
122
|
+
{
|
123
|
+
if (theConstruct->whichModule->lastItem == NULL)
|
124
|
+
{ theConstruct->whichModule->firstItem = theConstruct; }
|
125
|
+
else
|
126
|
+
{ theConstruct->whichModule->lastItem->next = theConstruct; }
|
127
|
+
|
128
|
+
theConstruct->whichModule->lastItem = theConstruct;
|
129
|
+
theConstruct->next = NULL;
|
130
|
+
}
|
131
|
+
|
132
|
+
#endif /* (! RUN_TIME) */
|
133
|
+
|
134
|
+
/****************************************************/
|
135
|
+
/* DeleteNamedConstruct: Generic driver routine for */
|
136
|
+
/* deleting a specific construct from a module. */
|
137
|
+
/****************************************************/
|
138
|
+
bool DeleteNamedConstruct(
|
139
|
+
Environment *theEnv,
|
140
|
+
const char *constructName,
|
141
|
+
Construct *constructClass)
|
142
|
+
{
|
143
|
+
#if (! BLOAD_ONLY)
|
144
|
+
ConstructHeader *constructPtr;
|
145
|
+
|
146
|
+
/*=============================*/
|
147
|
+
/* Constructs can't be deleted */
|
148
|
+
/* while a bload is in effect. */
|
149
|
+
/*=============================*/
|
150
|
+
|
151
|
+
#if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE
|
152
|
+
if (Bloaded(theEnv) == true) return false;
|
153
|
+
#endif
|
154
|
+
|
155
|
+
/*===============================*/
|
156
|
+
/* Look for the named construct. */
|
157
|
+
/*===============================*/
|
158
|
+
|
159
|
+
constructPtr = (*constructClass->findFunction)(theEnv,constructName);
|
160
|
+
|
161
|
+
/*========================================*/
|
162
|
+
/* If the construct was found, delete it. */
|
163
|
+
/*========================================*/
|
164
|
+
|
165
|
+
if (constructPtr != NULL)
|
166
|
+
{ return (*constructClass->deleteFunction)(constructPtr,theEnv); }
|
167
|
+
|
168
|
+
/*========================================*/
|
169
|
+
/* If the construct wasn't found, but the */
|
170
|
+
/* special symbol * was used, then delete */
|
171
|
+
/* all constructs of the specified type. */
|
172
|
+
/*========================================*/
|
173
|
+
|
174
|
+
if (strcmp("*",constructName) == 0)
|
175
|
+
{
|
176
|
+
(*constructClass->deleteFunction)(NULL,theEnv);
|
177
|
+
return true;
|
178
|
+
}
|
179
|
+
|
180
|
+
/*===============================*/
|
181
|
+
/* Otherwise, return false to */
|
182
|
+
/* indicate no deletion occured. */
|
183
|
+
/*===============================*/
|
184
|
+
|
185
|
+
return false;
|
186
|
+
#else
|
187
|
+
#if MAC_XCD
|
188
|
+
#pragma unused(theEnv,constructName,constructClass)
|
189
|
+
#endif
|
190
|
+
return false;
|
191
|
+
#endif
|
192
|
+
}
|
193
|
+
|
194
|
+
/********************************************************/
|
195
|
+
/* FindNamedConstructInModuleOrImports: Generic routine */
|
196
|
+
/* for searching for a specified construct. */
|
197
|
+
/********************************************************/
|
198
|
+
ConstructHeader *FindNamedConstructInModuleOrImports(
|
199
|
+
Environment *theEnv,
|
200
|
+
const char *constructName,
|
201
|
+
Construct *constructClass)
|
202
|
+
{
|
203
|
+
ConstructHeader *theConstruct;
|
204
|
+
unsigned int count;
|
205
|
+
|
206
|
+
/*================================================*/
|
207
|
+
/* First look in the current or specified module. */
|
208
|
+
/*================================================*/
|
209
|
+
|
210
|
+
theConstruct = FindNamedConstructInModule(theEnv,constructName,constructClass);
|
211
|
+
if (theConstruct != NULL) return theConstruct;
|
212
|
+
|
213
|
+
/*=====================================*/
|
214
|
+
/* If there's a module specifier, then */
|
215
|
+
/* the construct does not exist. */
|
216
|
+
/*=====================================*/
|
217
|
+
|
218
|
+
if (FindModuleSeparator(constructName))
|
219
|
+
{ return NULL; }
|
220
|
+
|
221
|
+
/*========================================*/
|
222
|
+
/* Otherwise, search in imported modules. */
|
223
|
+
/*========================================*/
|
224
|
+
|
225
|
+
theConstruct = FindImportedConstruct(theEnv,constructClass->constructName,NULL,
|
226
|
+
constructName,&count,true,NULL);
|
227
|
+
|
228
|
+
if (count > 1)
|
229
|
+
{
|
230
|
+
AmbiguousReferenceErrorMessage(theEnv,constructClass->constructName,constructName);
|
231
|
+
return NULL;
|
232
|
+
}
|
233
|
+
|
234
|
+
return theConstruct;
|
235
|
+
}
|
236
|
+
|
237
|
+
/***********************************************/
|
238
|
+
/* FindNamedConstructInModule: Generic routine */
|
239
|
+
/* for searching for a specified construct. */
|
240
|
+
/***********************************************/
|
241
|
+
ConstructHeader *FindNamedConstructInModule(
|
242
|
+
Environment *theEnv,
|
243
|
+
const char *constructName,
|
244
|
+
Construct *constructClass)
|
245
|
+
{
|
246
|
+
ConstructHeader *theConstruct;
|
247
|
+
CLIPSLexeme *findValue = NULL;
|
248
|
+
|
249
|
+
/*==========================*/
|
250
|
+
/* Save the current module. */
|
251
|
+
/*==========================*/
|
252
|
+
|
253
|
+
SaveCurrentModule(theEnv);
|
254
|
+
|
255
|
+
/*=========================================================*/
|
256
|
+
/* Extract the construct name. If a module was specified, */
|
257
|
+
/* then ExtractModuleAndConstructName will set the current */
|
258
|
+
/* module to the module specified in the name. */
|
259
|
+
/*=========================================================*/
|
260
|
+
|
261
|
+
constructName = ExtractModuleAndConstructName(theEnv,constructName);
|
262
|
+
|
263
|
+
/*=================================================*/
|
264
|
+
/* If a valid construct name couldn't be extracted */
|
265
|
+
/* or the construct name isn't in the symbol table */
|
266
|
+
/* (which means the construct doesn't exist), then */
|
267
|
+
/* return NULL to indicate the specified construct */
|
268
|
+
/* couldn't be found. */
|
269
|
+
/*=================================================*/
|
270
|
+
|
271
|
+
if ((constructName == NULL) ?
|
272
|
+
true :
|
273
|
+
((findValue = FindSymbolHN(theEnv,constructName,SYMBOL_BIT)) == NULL))
|
274
|
+
{
|
275
|
+
RestoreCurrentModule(theEnv);
|
276
|
+
return NULL;
|
277
|
+
}
|
278
|
+
|
279
|
+
/*===============================================*/
|
280
|
+
/* If we find the symbol for the construct name, */
|
281
|
+
/* but it has a count of 0, then it can't be for */
|
282
|
+
/* a construct that's currently defined. */
|
283
|
+
/*===============================================*/
|
284
|
+
|
285
|
+
if (findValue->count == 0)
|
286
|
+
{
|
287
|
+
RestoreCurrentModule(theEnv);
|
288
|
+
return NULL;
|
289
|
+
}
|
290
|
+
|
291
|
+
/*===============================================*/
|
292
|
+
/* Loop through every construct of the specified */
|
293
|
+
/* class in the current module checking to see */
|
294
|
+
/* if the construct's name matches the construct */
|
295
|
+
/* being sought. If found, restore the current */
|
296
|
+
/* module and return a pointer to the construct. */
|
297
|
+
/*===============================================*/
|
298
|
+
|
299
|
+
for (theConstruct = (*constructClass->getNextItemFunction)(theEnv,NULL);
|
300
|
+
theConstruct != NULL;
|
301
|
+
theConstruct = (*constructClass->getNextItemFunction)(theEnv,theConstruct))
|
302
|
+
{
|
303
|
+
if (findValue == (*constructClass->getConstructNameFunction)(theConstruct))
|
304
|
+
{
|
305
|
+
RestoreCurrentModule(theEnv);
|
306
|
+
return theConstruct;
|
307
|
+
}
|
308
|
+
}
|
309
|
+
|
310
|
+
/*=============================*/
|
311
|
+
/* Restore the current module. */
|
312
|
+
/*=============================*/
|
313
|
+
|
314
|
+
RestoreCurrentModule(theEnv);
|
315
|
+
|
316
|
+
/*====================================*/
|
317
|
+
/* Return NULL to indicated the named */
|
318
|
+
/* construct was not found. */
|
319
|
+
/*====================================*/
|
320
|
+
|
321
|
+
return NULL;
|
322
|
+
}
|
323
|
+
|
324
|
+
/*****************************************/
|
325
|
+
/* UndefconstructCommand: Driver routine */
|
326
|
+
/* for the undef<construct> commands. */
|
327
|
+
/*****************************************/
|
328
|
+
void UndefconstructCommand(
|
329
|
+
UDFContext *context,
|
330
|
+
const char *command,
|
331
|
+
Construct *constructClass)
|
332
|
+
{
|
333
|
+
Environment *theEnv = context->environment;
|
334
|
+
const char *constructName;
|
335
|
+
char buffer[80];
|
336
|
+
|
337
|
+
/*==============================================*/
|
338
|
+
/* Get the name of the construct to be deleted. */
|
339
|
+
/*==============================================*/
|
340
|
+
|
341
|
+
gensnprintf(buffer,sizeof(buffer),"%s name",constructClass->constructName);
|
342
|
+
|
343
|
+
constructName = GetConstructName(context,command,buffer);
|
344
|
+
if (constructName == NULL) return;
|
345
|
+
|
346
|
+
#if (! RUN_TIME) && (! BLOAD_ONLY)
|
347
|
+
|
348
|
+
/*=============================================*/
|
349
|
+
/* Check to see if the named construct exists. */
|
350
|
+
/*=============================================*/
|
351
|
+
|
352
|
+
if (((*constructClass->findFunction)(theEnv,constructName) == NULL) &&
|
353
|
+
(strcmp("*",constructName) != 0))
|
354
|
+
{
|
355
|
+
CantFindItemErrorMessage(theEnv,constructClass->constructName,constructName,true);
|
356
|
+
return;
|
357
|
+
}
|
358
|
+
|
359
|
+
/*===============================================*/
|
360
|
+
/* If the construct does exist, try deleting it. */
|
361
|
+
/*===============================================*/
|
362
|
+
|
363
|
+
else if (DeleteNamedConstruct(theEnv,constructName,constructClass) == false)
|
364
|
+
{
|
365
|
+
CantDeleteItemErrorMessage(theEnv,constructClass->constructName,constructName);
|
366
|
+
return;
|
367
|
+
}
|
368
|
+
|
369
|
+
return;
|
370
|
+
#else
|
371
|
+
/*=====================================*/
|
372
|
+
/* Constructs can't be deleted in a */
|
373
|
+
/* run-time or bload only environment. */
|
374
|
+
/*=====================================*/
|
375
|
+
|
376
|
+
CantDeleteItemErrorMessage(theEnv,constructClass->constructName,constructName);
|
377
|
+
return;
|
378
|
+
#endif
|
379
|
+
}
|
380
|
+
|
381
|
+
/******************************************/
|
382
|
+
/* PPConstructCommand: Driver routine for */
|
383
|
+
/* the ppdef<construct> commands. */
|
384
|
+
/******************************************/
|
385
|
+
void PPConstructCommand(
|
386
|
+
UDFContext *context,
|
387
|
+
const char *command,
|
388
|
+
Construct *constructClass,
|
389
|
+
UDFValue *returnValue)
|
390
|
+
{
|
391
|
+
Environment *theEnv = context->environment;
|
392
|
+
const char *constructName;
|
393
|
+
const char *logicalName;
|
394
|
+
const char *ppForm;
|
395
|
+
char buffer[80];
|
396
|
+
|
397
|
+
/*===============================*/
|
398
|
+
/* Get the name of the construct */
|
399
|
+
/* to be "pretty printed." */
|
400
|
+
/*===============================*/
|
401
|
+
|
402
|
+
gensnprintf(buffer,sizeof(buffer),"%s name",constructClass->constructName);
|
403
|
+
|
404
|
+
constructName = GetConstructName(context,command,buffer);
|
405
|
+
if (constructName == NULL) return;
|
406
|
+
|
407
|
+
if (UDFHasNextArgument(context))
|
408
|
+
{
|
409
|
+
logicalName = GetLogicalName(context,STDOUT);
|
410
|
+
if (logicalName == NULL)
|
411
|
+
{
|
412
|
+
IllegalLogicalNameMessage(theEnv,command);
|
413
|
+
SetHaltExecution(theEnv,true);
|
414
|
+
SetEvaluationError(theEnv,true);
|
415
|
+
return;
|
416
|
+
}
|
417
|
+
}
|
418
|
+
else
|
419
|
+
{ logicalName = STDOUT; }
|
420
|
+
|
421
|
+
/*================================*/
|
422
|
+
/* Call the driver routine for */
|
423
|
+
/* pretty printing the construct. */
|
424
|
+
/*================================*/
|
425
|
+
|
426
|
+
if (strcmp(logicalName,"nil") == 0)
|
427
|
+
{
|
428
|
+
ppForm = PPConstructNil(theEnv,constructName,constructClass);
|
429
|
+
|
430
|
+
if (ppForm == NULL)
|
431
|
+
{
|
432
|
+
CantFindItemErrorMessage(theEnv,constructClass->constructName,constructName,true);
|
433
|
+
ppForm = "";
|
434
|
+
}
|
435
|
+
|
436
|
+
returnValue->lexemeValue = CreateString(theEnv,ppForm);
|
437
|
+
|
438
|
+
return;
|
439
|
+
}
|
440
|
+
|
441
|
+
if (PPConstruct(theEnv,constructName,logicalName,constructClass) == false)
|
442
|
+
{ CantFindItemErrorMessage(theEnv,constructClass->constructName,constructName,true); }
|
443
|
+
}
|
444
|
+
|
445
|
+
/******************************************************/
|
446
|
+
/* PPConstructNil: Driver routine for pretty printing */
|
447
|
+
/* a construct using the logical name nil. */
|
448
|
+
/******************************************************/
|
449
|
+
const char *PPConstructNil(
|
450
|
+
Environment *theEnv,
|
451
|
+
const char *constructName,
|
452
|
+
Construct *constructClass)
|
453
|
+
{
|
454
|
+
ConstructHeader *constructPtr;
|
455
|
+
|
456
|
+
/*==================================*/
|
457
|
+
/* Use the construct's name to find */
|
458
|
+
/* a pointer to actual construct. */
|
459
|
+
/*==================================*/
|
460
|
+
|
461
|
+
constructPtr = (*constructClass->findFunction)(theEnv,constructName);
|
462
|
+
if (constructPtr == NULL) return NULL;
|
463
|
+
|
464
|
+
/*==============================================*/
|
465
|
+
/* If the pretty print form is NULL (because of */
|
466
|
+
/* conserve-mem), return "" (which indicates */
|
467
|
+
/* the construct was found). */
|
468
|
+
/*==============================================*/
|
469
|
+
|
470
|
+
if ((*constructClass->getPPFormFunction)(constructPtr) == NULL)
|
471
|
+
{ return ""; }
|
472
|
+
|
473
|
+
/*=================================*/
|
474
|
+
/* Return the pretty print string. */
|
475
|
+
/*=================================*/
|
476
|
+
|
477
|
+
return (*constructClass->getPPFormFunction)(constructPtr);
|
478
|
+
}
|
479
|
+
|
480
|
+
/***********************************/
|
481
|
+
/* PPConstruct: Driver routine for */
|
482
|
+
/* pretty printing a construct. */
|
483
|
+
/***********************************/
|
484
|
+
bool PPConstruct(
|
485
|
+
Environment *theEnv,
|
486
|
+
const char *constructName,
|
487
|
+
const char *logicalName,
|
488
|
+
Construct *constructClass)
|
489
|
+
{
|
490
|
+
ConstructHeader *constructPtr;
|
491
|
+
|
492
|
+
/*==================================*/
|
493
|
+
/* Use the construct's name to find */
|
494
|
+
/* a pointer to actual construct. */
|
495
|
+
/*==================================*/
|
496
|
+
|
497
|
+
constructPtr = (*constructClass->findFunction)(theEnv,constructName);
|
498
|
+
if (constructPtr == NULL) return false;
|
499
|
+
|
500
|
+
/*==============================================*/
|
501
|
+
/* If the pretty print form is NULL (because of */
|
502
|
+
/* conserve-mem), return true (which indicates */
|
503
|
+
/* the construct was found). */
|
504
|
+
/*==============================================*/
|
505
|
+
|
506
|
+
if ((*constructClass->getPPFormFunction)(constructPtr) == NULL)
|
507
|
+
{ return true; }
|
508
|
+
|
509
|
+
/*================================*/
|
510
|
+
/* Print the pretty print string. */
|
511
|
+
/*================================*/
|
512
|
+
|
513
|
+
WriteString(theEnv,logicalName,(*constructClass->getPPFormFunction)(constructPtr));
|
514
|
+
|
515
|
+
/*=======================================*/
|
516
|
+
/* Return true to indicate the construct */
|
517
|
+
/* was found and pretty printed. */
|
518
|
+
/*=======================================*/
|
519
|
+
|
520
|
+
return true;
|
521
|
+
}
|
522
|
+
|
523
|
+
/*********************************************/
|
524
|
+
/* GetConstructModuleCommand: Driver routine */
|
525
|
+
/* for def<construct>-module routines */
|
526
|
+
/*********************************************/
|
527
|
+
CLIPSLexeme *GetConstructModuleCommand(
|
528
|
+
UDFContext *context,
|
529
|
+
const char *command,
|
530
|
+
Construct *constructClass)
|
531
|
+
{
|
532
|
+
Environment *theEnv = context->environment;
|
533
|
+
const char *constructName;
|
534
|
+
char buffer[80];
|
535
|
+
Defmodule *constructModule;
|
536
|
+
|
537
|
+
/*=========================================*/
|
538
|
+
/* Get the name of the construct for which */
|
539
|
+
/* we want to determine its module. */
|
540
|
+
/*=========================================*/
|
541
|
+
|
542
|
+
gensnprintf(buffer,sizeof(buffer),"%s name",constructClass->constructName);
|
543
|
+
|
544
|
+
constructName = GetConstructName(context,command,buffer);
|
545
|
+
if (constructName == NULL) return FalseSymbol(theEnv);
|
546
|
+
|
547
|
+
/*==========================================*/
|
548
|
+
/* Get a pointer to the construct's module. */
|
549
|
+
/*==========================================*/
|
550
|
+
|
551
|
+
constructModule = GetConstructModule(theEnv,constructName,constructClass);
|
552
|
+
if (constructModule == NULL)
|
553
|
+
{
|
554
|
+
CantFindItemErrorMessage(theEnv,constructClass->constructName,constructName,true);
|
555
|
+
return FalseSymbol(theEnv);
|
556
|
+
}
|
557
|
+
|
558
|
+
/*============================================*/
|
559
|
+
/* Return the name of the construct's module. */
|
560
|
+
/*============================================*/
|
561
|
+
|
562
|
+
return constructModule->header.name;
|
563
|
+
}
|
564
|
+
|
565
|
+
/******************************************/
|
566
|
+
/* GetConstructModule: Driver routine for */
|
567
|
+
/* getting the module for a construct */
|
568
|
+
/******************************************/
|
569
|
+
Defmodule *GetConstructModule(
|
570
|
+
Environment *theEnv,
|
571
|
+
const char *constructName,
|
572
|
+
Construct *constructClass)
|
573
|
+
{
|
574
|
+
ConstructHeader *constructPtr;
|
575
|
+
unsigned int count;
|
576
|
+
unsigned position;
|
577
|
+
CLIPSLexeme *theName;
|
578
|
+
|
579
|
+
/*====================================================*/
|
580
|
+
/* If the construct name contains a module specifier, */
|
581
|
+
/* then get a pointer to the defmodule associated */
|
582
|
+
/* with the specified name. */
|
583
|
+
/*====================================================*/
|
584
|
+
|
585
|
+
if ((position = FindModuleSeparator(constructName)) != 0)
|
586
|
+
{
|
587
|
+
theName = ExtractModuleName(theEnv,position,constructName);
|
588
|
+
if (theName != NULL)
|
589
|
+
{ return FindDefmodule(theEnv,theName->contents); }
|
590
|
+
}
|
591
|
+
|
592
|
+
/*============================================*/
|
593
|
+
/* No module was specified, so search for the */
|
594
|
+
/* named construct in the current module and */
|
595
|
+
/* modules from which it imports. */
|
596
|
+
/*============================================*/
|
597
|
+
|
598
|
+
constructPtr = FindImportedConstruct(theEnv,constructClass->constructName,NULL,constructName,
|
599
|
+
&count,true,NULL);
|
600
|
+
if (constructPtr == NULL) return NULL;
|
601
|
+
|
602
|
+
return(constructPtr->whichModule->theModule);
|
603
|
+
}
|
604
|
+
|
605
|
+
/****************************************/
|
606
|
+
/* UndefconstructAll: Generic C routine */
|
607
|
+
/* for deleting all constructs. */
|
608
|
+
/****************************************/
|
609
|
+
bool UndefconstructAll(
|
610
|
+
Environment *theEnv,
|
611
|
+
Construct *constructClass)
|
612
|
+
{
|
613
|
+
#if BLOAD_ONLY || RUN_TIME
|
614
|
+
#if MAC_XCD
|
615
|
+
#pragma unused(constructClass)
|
616
|
+
#pragma unused(theEnv)
|
617
|
+
#endif
|
618
|
+
return false;
|
619
|
+
#else
|
620
|
+
ConstructHeader *currentConstruct, *nextConstruct;
|
621
|
+
bool success = true;
|
622
|
+
GCBlock gcb;
|
623
|
+
|
624
|
+
/*===================================================*/
|
625
|
+
/* Loop through all of the constructs in the module. */
|
626
|
+
/*===================================================*/
|
627
|
+
|
628
|
+
GCBlockStart(theEnv,&gcb);
|
629
|
+
|
630
|
+
currentConstruct = (*constructClass->getNextItemFunction)(theEnv,NULL);
|
631
|
+
while (currentConstruct != NULL)
|
632
|
+
{
|
633
|
+
/*==============================*/
|
634
|
+
/* Remember the next construct. */
|
635
|
+
/*==============================*/
|
636
|
+
|
637
|
+
nextConstruct = (*constructClass->getNextItemFunction)(theEnv,currentConstruct);
|
638
|
+
|
639
|
+
/*=============================*/
|
640
|
+
/* Try deleting the construct. */
|
641
|
+
/*=============================*/
|
642
|
+
|
643
|
+
if ((*constructClass->isConstructDeletableFunction)(currentConstruct))
|
644
|
+
{
|
645
|
+
RemoveConstructFromModule(theEnv,currentConstruct);
|
646
|
+
(*constructClass->freeFunction)(theEnv,currentConstruct);
|
647
|
+
}
|
648
|
+
else
|
649
|
+
{
|
650
|
+
CantDeleteItemErrorMessage(theEnv,constructClass->constructName,
|
651
|
+
(*constructClass->getConstructNameFunction)(currentConstruct)->contents);
|
652
|
+
success = false;
|
653
|
+
}
|
654
|
+
|
655
|
+
/*================================*/
|
656
|
+
/* Move on to the next construct. */
|
657
|
+
/*================================*/
|
658
|
+
|
659
|
+
currentConstruct = nextConstruct;
|
660
|
+
}
|
661
|
+
|
662
|
+
GCBlockEnd(theEnv,&gcb);
|
663
|
+
CallPeriodicTasks(theEnv);
|
664
|
+
|
665
|
+
/*============================================*/
|
666
|
+
/* Return true if all constructs successfully */
|
667
|
+
/* deleted, otherwise false. */
|
668
|
+
/*============================================*/
|
669
|
+
|
670
|
+
return success;
|
671
|
+
|
672
|
+
#endif
|
673
|
+
}
|
674
|
+
|
675
|
+
/*************************************/
|
676
|
+
/* Undefconstruct: Generic C routine */
|
677
|
+
/* for deleting a construct. */
|
678
|
+
/*************************************/
|
679
|
+
bool Undefconstruct(
|
680
|
+
Environment *theEnv,
|
681
|
+
ConstructHeader *theConstruct,
|
682
|
+
Construct *constructClass)
|
683
|
+
{
|
684
|
+
#if BLOAD_ONLY || RUN_TIME
|
685
|
+
#if MAC_XCD
|
686
|
+
#pragma unused(theConstruct)
|
687
|
+
#pragma unused(constructClass)
|
688
|
+
#pragma unused(theEnv)
|
689
|
+
#endif
|
690
|
+
return false;
|
691
|
+
#else
|
692
|
+
GCBlock gcb;
|
693
|
+
|
694
|
+
/*================================================*/
|
695
|
+
/* Delete all constructs of the specified type if */
|
696
|
+
/* the construct pointer is the NULL pointer. */
|
697
|
+
/*================================================*/
|
698
|
+
|
699
|
+
if (theConstruct == NULL)
|
700
|
+
{ return UndefconstructAll(theEnv,constructClass); }
|
701
|
+
|
702
|
+
/*==================================================*/
|
703
|
+
/* Return false if the construct cannot be deleted. */
|
704
|
+
/*==================================================*/
|
705
|
+
|
706
|
+
if ((*constructClass->isConstructDeletableFunction)(theConstruct) == false)
|
707
|
+
{ return false; }
|
708
|
+
|
709
|
+
/*===================================*/
|
710
|
+
/* Start a garbage collection block. */
|
711
|
+
/*===================================*/
|
712
|
+
|
713
|
+
GCBlockStart(theEnv,&gcb);
|
714
|
+
|
715
|
+
/*===========================*/
|
716
|
+
/* Remove the construct from */
|
717
|
+
/* the list in its module. */
|
718
|
+
/*===========================*/
|
719
|
+
|
720
|
+
RemoveConstructFromModule(theEnv,theConstruct);
|
721
|
+
|
722
|
+
/*=======================*/
|
723
|
+
/* Delete the construct. */
|
724
|
+
/*=======================*/
|
725
|
+
|
726
|
+
(*constructClass->freeFunction)(theEnv,theConstruct);
|
727
|
+
|
728
|
+
/*===================================*/
|
729
|
+
/* End the garbage collection block. */
|
730
|
+
/*===================================*/
|
731
|
+
|
732
|
+
GCBlockEnd(theEnv,&gcb);
|
733
|
+
|
734
|
+
/*=============================*/
|
735
|
+
/* Return true to indicate the */
|
736
|
+
/* construct was deleted. */
|
737
|
+
/*=============================*/
|
738
|
+
|
739
|
+
return true;
|
740
|
+
#endif
|
741
|
+
}
|
742
|
+
|
743
|
+
/***********************************/
|
744
|
+
/* SaveConstruct: Generic routine */
|
745
|
+
/* for saving a construct class. */
|
746
|
+
/***********************************/
|
747
|
+
void SaveConstruct(
|
748
|
+
Environment *theEnv,
|
749
|
+
Defmodule *theModule,
|
750
|
+
const char *logicalName,
|
751
|
+
Construct *constructClass)
|
752
|
+
{
|
753
|
+
const char *ppform;
|
754
|
+
ConstructHeader *theConstruct;
|
755
|
+
|
756
|
+
/*==========================*/
|
757
|
+
/* Save the current module. */
|
758
|
+
/*==========================*/
|
759
|
+
|
760
|
+
SaveCurrentModule(theEnv);
|
761
|
+
|
762
|
+
/*===========================*/
|
763
|
+
/* Set the current module to */
|
764
|
+
/* the one we're examining. */
|
765
|
+
/*===========================*/
|
766
|
+
|
767
|
+
SetCurrentModule(theEnv,theModule);
|
768
|
+
|
769
|
+
/*==============================================*/
|
770
|
+
/* Loop through each construct of the specified */
|
771
|
+
/* construct class in the module. */
|
772
|
+
/*==============================================*/
|
773
|
+
|
774
|
+
for (theConstruct = (*constructClass->getNextItemFunction)(theEnv,NULL);
|
775
|
+
theConstruct != NULL;
|
776
|
+
theConstruct = (*constructClass->getNextItemFunction)(theEnv,theConstruct))
|
777
|
+
{
|
778
|
+
/*==========================================*/
|
779
|
+
/* Print the construct's pretty print form. */
|
780
|
+
/*==========================================*/
|
781
|
+
|
782
|
+
ppform = (*constructClass->getPPFormFunction)(theConstruct);
|
783
|
+
if (ppform != NULL)
|
784
|
+
{
|
785
|
+
WriteString(theEnv,logicalName,ppform);
|
786
|
+
WriteString(theEnv,logicalName,"\n");
|
787
|
+
}
|
788
|
+
}
|
789
|
+
|
790
|
+
/*=============================*/
|
791
|
+
/* Restore the current module. */
|
792
|
+
/*=============================*/
|
793
|
+
|
794
|
+
RestoreCurrentModule(theEnv);
|
795
|
+
}
|
796
|
+
|
797
|
+
/*********************************************************/
|
798
|
+
/* GetConstructModuleName: Generic routine for returning */
|
799
|
+
/* the name of the module to which a construct belongs */
|
800
|
+
/*********************************************************/
|
801
|
+
const char *GetConstructModuleName(
|
802
|
+
ConstructHeader *theConstruct)
|
803
|
+
{ return DefmoduleName(theConstruct->whichModule->theModule); }
|
804
|
+
|
805
|
+
/*********************************************************/
|
806
|
+
/* GetConstructNameString: Generic routine for returning */
|
807
|
+
/* the name string of a construct. */
|
808
|
+
/*********************************************************/
|
809
|
+
const char *GetConstructNameString(
|
810
|
+
ConstructHeader *theConstruct)
|
811
|
+
{ return theConstruct->name->contents; }
|
812
|
+
|
813
|
+
/**********************************************************/
|
814
|
+
/* GetConstructNamePointer: Generic routine for returning */
|
815
|
+
/* the name pointer of a construct. */
|
816
|
+
/**********************************************************/
|
817
|
+
CLIPSLexeme *GetConstructNamePointer(
|
818
|
+
ConstructHeader *theConstruct)
|
819
|
+
{ return theConstruct->name; }
|
820
|
+
|
821
|
+
/************************************************/
|
822
|
+
/* GetConstructListFunction: Generic Routine */
|
823
|
+
/* for retrieving the constructs in a module. */
|
824
|
+
/************************************************/
|
825
|
+
void GetConstructListFunction(
|
826
|
+
UDFContext *context,
|
827
|
+
UDFValue *returnValue,
|
828
|
+
Construct *constructClass)
|
829
|
+
{
|
830
|
+
Defmodule *theModule;
|
831
|
+
UDFValue result;
|
832
|
+
unsigned int numArgs;
|
833
|
+
Environment *theEnv = context->environment;
|
834
|
+
|
835
|
+
/*====================================*/
|
836
|
+
/* If an argument was given, check to */
|
837
|
+
/* see that it's a valid module name. */
|
838
|
+
/*====================================*/
|
839
|
+
|
840
|
+
numArgs = UDFArgumentCount(context);
|
841
|
+
if (numArgs == 1)
|
842
|
+
{
|
843
|
+
/*======================================*/
|
844
|
+
/* Only symbols are valid module names. */
|
845
|
+
/*======================================*/
|
846
|
+
|
847
|
+
if (! UDFFirstArgument(context,SYMBOL_BIT,&result))
|
848
|
+
{ return; }
|
849
|
+
|
850
|
+
/*===========================================*/
|
851
|
+
/* Verify that the named module exists or is */
|
852
|
+
/* the symbol * (for obtaining the construct */
|
853
|
+
/* list for all modules). */
|
854
|
+
/*===========================================*/
|
855
|
+
|
856
|
+
if ((theModule = FindDefmodule(theEnv,result.lexemeValue->contents)) == NULL)
|
857
|
+
{
|
858
|
+
if (strcmp("*",result.lexemeValue->contents) != 0)
|
859
|
+
{
|
860
|
+
SetMultifieldErrorValue(theEnv,returnValue);
|
861
|
+
ExpectedTypeError1(theEnv,UDFContextFunctionName(context),1,"'defmodule name'");
|
862
|
+
return;
|
863
|
+
}
|
864
|
+
|
865
|
+
theModule = NULL;
|
866
|
+
}
|
867
|
+
}
|
868
|
+
|
869
|
+
/*=====================================*/
|
870
|
+
/* Otherwise use the current module to */
|
871
|
+
/* generate the construct list. */
|
872
|
+
/*=====================================*/
|
873
|
+
|
874
|
+
else
|
875
|
+
{ theModule = GetCurrentModule(theEnv); }
|
876
|
+
|
877
|
+
/*=============================*/
|
878
|
+
/* Call the driver routine to */
|
879
|
+
/* get the list of constructs. */
|
880
|
+
/*=============================*/
|
881
|
+
|
882
|
+
GetConstructList(theEnv,returnValue,constructClass,theModule);
|
883
|
+
}
|
884
|
+
|
885
|
+
/********************************************/
|
886
|
+
/* GetConstructList: Generic C Routine for */
|
887
|
+
/* retrieving the constructs in a module. */
|
888
|
+
/********************************************/
|
889
|
+
void GetConstructList(
|
890
|
+
Environment *theEnv,
|
891
|
+
UDFValue *returnValue,
|
892
|
+
Construct *constructClass,
|
893
|
+
Defmodule *theModule)
|
894
|
+
{
|
895
|
+
ConstructHeader *theConstruct;
|
896
|
+
unsigned long count = 0;
|
897
|
+
Multifield *theList;
|
898
|
+
CLIPSLexeme *theName;
|
899
|
+
Defmodule *loopModule;
|
900
|
+
bool allModules = false;
|
901
|
+
size_t largestConstructNameSize = 0, bufferSize = 80; /* prevents warning */
|
902
|
+
char *buffer;
|
903
|
+
|
904
|
+
/*==========================*/
|
905
|
+
/* Save the current module. */
|
906
|
+
/*==========================*/
|
907
|
+
|
908
|
+
SaveCurrentModule(theEnv);
|
909
|
+
|
910
|
+
/*=======================================*/
|
911
|
+
/* If the module specified is NULL, then */
|
912
|
+
/* get all constructs in all modules. */
|
913
|
+
/*=======================================*/
|
914
|
+
|
915
|
+
if (theModule == NULL)
|
916
|
+
{
|
917
|
+
theModule = GetNextDefmodule(theEnv,NULL);
|
918
|
+
allModules = true;
|
919
|
+
}
|
920
|
+
|
921
|
+
/*======================================================*/
|
922
|
+
/* Count the number of constructs to be retrieved and */
|
923
|
+
/* determine the buffer size needed to store the */
|
924
|
+
/* module-name::construct-names that will be generated. */
|
925
|
+
/*======================================================*/
|
926
|
+
|
927
|
+
loopModule = theModule;
|
928
|
+
while (loopModule != NULL)
|
929
|
+
{
|
930
|
+
size_t tempSize;
|
931
|
+
|
932
|
+
/*======================================================*/
|
933
|
+
/* Set the current module to the module being examined. */
|
934
|
+
/*======================================================*/
|
935
|
+
|
936
|
+
SetCurrentModule(theEnv,loopModule);
|
937
|
+
|
938
|
+
/*===========================================*/
|
939
|
+
/* Loop over every construct in the module. */
|
940
|
+
/*===========================================*/
|
941
|
+
|
942
|
+
theConstruct = NULL;
|
943
|
+
largestConstructNameSize = 0;
|
944
|
+
|
945
|
+
while ((theConstruct = (*constructClass->getNextItemFunction)(theEnv,theConstruct)) != NULL)
|
946
|
+
{
|
947
|
+
/*================================*/
|
948
|
+
/* Increment the construct count. */
|
949
|
+
/*================================*/
|
950
|
+
|
951
|
+
count++;
|
952
|
+
|
953
|
+
/*=================================================*/
|
954
|
+
/* Is this the largest construct name encountered? */
|
955
|
+
/*=================================================*/
|
956
|
+
|
957
|
+
tempSize = strlen((*constructClass->getConstructNameFunction)(theConstruct)->contents);
|
958
|
+
if (tempSize > largestConstructNameSize)
|
959
|
+
{ largestConstructNameSize = tempSize; }
|
960
|
+
}
|
961
|
+
|
962
|
+
/*========================================*/
|
963
|
+
/* Determine the size of the module name. */
|
964
|
+
/*========================================*/
|
965
|
+
|
966
|
+
tempSize = strlen(DefmoduleName(loopModule));
|
967
|
+
|
968
|
+
/*======================================================*/
|
969
|
+
/* The buffer must be large enough for the module name, */
|
970
|
+
/* the largest name of all the constructs, and the ::. */
|
971
|
+
/*======================================================*/
|
972
|
+
|
973
|
+
if ((tempSize + largestConstructNameSize + 5) > bufferSize)
|
974
|
+
{ bufferSize = tempSize + largestConstructNameSize + 5; }
|
975
|
+
|
976
|
+
/*=============================*/
|
977
|
+
/* Move on to the next module. */
|
978
|
+
/*=============================*/
|
979
|
+
|
980
|
+
if (allModules) loopModule = GetNextDefmodule(theEnv,loopModule);
|
981
|
+
else loopModule = NULL;
|
982
|
+
}
|
983
|
+
|
984
|
+
/*===========================*/
|
985
|
+
/* Allocate the name buffer. */
|
986
|
+
/*===========================*/
|
987
|
+
|
988
|
+
buffer = (char *) genalloc(theEnv,bufferSize);
|
989
|
+
|
990
|
+
/*================================*/
|
991
|
+
/* Create the multifield value to */
|
992
|
+
/* store the construct names. */
|
993
|
+
/*================================*/
|
994
|
+
|
995
|
+
returnValue->begin = 0;
|
996
|
+
returnValue->range = count;
|
997
|
+
theList = CreateMultifield(theEnv,count);
|
998
|
+
returnValue->value = theList;
|
999
|
+
|
1000
|
+
/*===========================*/
|
1001
|
+
/* Store the construct names */
|
1002
|
+
/* in the multifield value. */
|
1003
|
+
/*===========================*/
|
1004
|
+
|
1005
|
+
loopModule = theModule;
|
1006
|
+
count = 0;
|
1007
|
+
while (loopModule != NULL)
|
1008
|
+
{
|
1009
|
+
/*============================*/
|
1010
|
+
/* Set the current module to */
|
1011
|
+
/* the module being examined. */
|
1012
|
+
/*============================*/
|
1013
|
+
|
1014
|
+
SetCurrentModule(theEnv,loopModule);
|
1015
|
+
|
1016
|
+
/*===============================*/
|
1017
|
+
/* Add each construct name found */
|
1018
|
+
/* in the module to the list. */
|
1019
|
+
/*===============================*/
|
1020
|
+
|
1021
|
+
theConstruct = NULL;
|
1022
|
+
while ((theConstruct = (*constructClass->getNextItemFunction)(theEnv,theConstruct)) != NULL)
|
1023
|
+
{
|
1024
|
+
theName = (*constructClass->getConstructNameFunction)(theConstruct);
|
1025
|
+
if (allModules)
|
1026
|
+
{
|
1027
|
+
genstrcpy(buffer,DefmoduleName(loopModule));
|
1028
|
+
genstrcat(buffer,"::");
|
1029
|
+
genstrcat(buffer,theName->contents);
|
1030
|
+
theList->contents[count].value = CreateSymbol(theEnv,buffer);
|
1031
|
+
}
|
1032
|
+
else
|
1033
|
+
{ theList->contents[count].value = CreateSymbol(theEnv,theName->contents); }
|
1034
|
+
count++;
|
1035
|
+
}
|
1036
|
+
|
1037
|
+
/*==================================*/
|
1038
|
+
/* Move on to the next module (if */
|
1039
|
+
/* the list is to contain the names */
|
1040
|
+
/* of constructs from all modules). */
|
1041
|
+
/*==================================*/
|
1042
|
+
|
1043
|
+
if (allModules) loopModule = GetNextDefmodule(theEnv,loopModule);
|
1044
|
+
else loopModule = NULL;
|
1045
|
+
}
|
1046
|
+
|
1047
|
+
/*=========================*/
|
1048
|
+
/* Return the name buffer. */
|
1049
|
+
/*=========================*/
|
1050
|
+
|
1051
|
+
genfree(theEnv,buffer,bufferSize);
|
1052
|
+
|
1053
|
+
/*=============================*/
|
1054
|
+
/* Restore the current module. */
|
1055
|
+
/*=============================*/
|
1056
|
+
|
1057
|
+
RestoreCurrentModule(theEnv);
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
/*********************************************/
|
1061
|
+
/* ListConstructCommand: Generic Routine for */
|
1062
|
+
/* listing the constructs in a module. */
|
1063
|
+
/*********************************************/
|
1064
|
+
void ListConstructCommand(
|
1065
|
+
UDFContext *context,
|
1066
|
+
Construct *constructClass)
|
1067
|
+
{
|
1068
|
+
Defmodule *theModule;
|
1069
|
+
UDFValue result;
|
1070
|
+
unsigned int numArgs;
|
1071
|
+
Environment *theEnv = context->environment;
|
1072
|
+
|
1073
|
+
/*====================================*/
|
1074
|
+
/* If an argument was given, check to */
|
1075
|
+
/* see that it's a valid module name. */
|
1076
|
+
/*====================================*/
|
1077
|
+
|
1078
|
+
numArgs = UDFArgumentCount(context);
|
1079
|
+
if (numArgs == 1)
|
1080
|
+
{
|
1081
|
+
/*======================================*/
|
1082
|
+
/* Only symbols are valid module names. */
|
1083
|
+
/*======================================*/
|
1084
|
+
|
1085
|
+
if (! UDFFirstArgument(context,SYMBOL_BIT,&result))
|
1086
|
+
{ return; }
|
1087
|
+
|
1088
|
+
/*===========================================*/
|
1089
|
+
/* Verify that the named module exists or is */
|
1090
|
+
/* the symbol * (for obtaining the construct */
|
1091
|
+
/* list for all modules). */
|
1092
|
+
/*===========================================*/
|
1093
|
+
|
1094
|
+
if ((theModule = FindDefmodule(theEnv,result.lexemeValue->contents)) == NULL)
|
1095
|
+
{
|
1096
|
+
if (strcmp("*",result.lexemeValue->contents) != 0)
|
1097
|
+
{
|
1098
|
+
ExpectedTypeError1(theEnv,UDFContextFunctionName(context),1,"'defmodule name'");
|
1099
|
+
return;
|
1100
|
+
}
|
1101
|
+
|
1102
|
+
theModule = NULL;
|
1103
|
+
}
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
/*=====================================*/
|
1107
|
+
/* Otherwise use the current module to */
|
1108
|
+
/* generate the construct list. */
|
1109
|
+
/*=====================================*/
|
1110
|
+
|
1111
|
+
else
|
1112
|
+
{ theModule = GetCurrentModule(theEnv); }
|
1113
|
+
|
1114
|
+
/*=========================*/
|
1115
|
+
/* Call the driver routine */
|
1116
|
+
/* to list the constructs. */
|
1117
|
+
/*=========================*/
|
1118
|
+
|
1119
|
+
ListConstruct(theEnv,constructClass,STDOUT,theModule);
|
1120
|
+
}
|
1121
|
+
|
1122
|
+
/*****************************************/
|
1123
|
+
/* ListConstruct: Generic C Routine for */
|
1124
|
+
/* listing the constructs in a module. */
|
1125
|
+
/*****************************************/
|
1126
|
+
void ListConstruct(
|
1127
|
+
Environment *theEnv,
|
1128
|
+
Construct *constructClass,
|
1129
|
+
const char *logicalName,
|
1130
|
+
Defmodule *theModule)
|
1131
|
+
{
|
1132
|
+
ConstructHeader *constructPtr;
|
1133
|
+
CLIPSLexeme *constructName;
|
1134
|
+
unsigned long count = 0;
|
1135
|
+
bool allModules = false;
|
1136
|
+
|
1137
|
+
/*=====================================*/
|
1138
|
+
/* If embedded, clear the error flags. */
|
1139
|
+
/*=====================================*/
|
1140
|
+
|
1141
|
+
if (EvaluationData(theEnv)->CurrentExpression == NULL)
|
1142
|
+
{ ResetErrorFlags(theEnv); }
|
1143
|
+
|
1144
|
+
/*==========================*/
|
1145
|
+
/* Save the current module. */
|
1146
|
+
/*==========================*/
|
1147
|
+
|
1148
|
+
SaveCurrentModule(theEnv);
|
1149
|
+
|
1150
|
+
/*=======================================*/
|
1151
|
+
/* If the module specified is NULL, then */
|
1152
|
+
/* list all constructs in all modules. */
|
1153
|
+
/*=======================================*/
|
1154
|
+
|
1155
|
+
if (theModule == NULL)
|
1156
|
+
{
|
1157
|
+
theModule = GetNextDefmodule(theEnv,NULL);
|
1158
|
+
allModules = true;
|
1159
|
+
}
|
1160
|
+
|
1161
|
+
/*==================================*/
|
1162
|
+
/* Loop through all of the modules. */
|
1163
|
+
/*==================================*/
|
1164
|
+
|
1165
|
+
while (theModule != NULL)
|
1166
|
+
{
|
1167
|
+
/*========================================*/
|
1168
|
+
/* If we're printing the construct in all */
|
1169
|
+
/* modules, then preface each module */
|
1170
|
+
/* listing with the name of the module. */
|
1171
|
+
/*========================================*/
|
1172
|
+
|
1173
|
+
if (allModules)
|
1174
|
+
{
|
1175
|
+
WriteString(theEnv,logicalName,DefmoduleName(theModule));
|
1176
|
+
WriteString(theEnv,logicalName,":\n");
|
1177
|
+
}
|
1178
|
+
|
1179
|
+
/*===============================*/
|
1180
|
+
/* Set the current module to the */
|
1181
|
+
/* module we're examining. */
|
1182
|
+
/*===============================*/
|
1183
|
+
|
1184
|
+
SetCurrentModule(theEnv,theModule);
|
1185
|
+
|
1186
|
+
/*===========================================*/
|
1187
|
+
/* List all of the constructs in the module. */
|
1188
|
+
/*===========================================*/
|
1189
|
+
|
1190
|
+
for (constructPtr = (*constructClass->getNextItemFunction)(theEnv,NULL);
|
1191
|
+
constructPtr != NULL;
|
1192
|
+
constructPtr = (*constructClass->getNextItemFunction)(theEnv,constructPtr))
|
1193
|
+
{
|
1194
|
+
if (EvaluationData(theEnv)->HaltExecution == true) return;
|
1195
|
+
|
1196
|
+
constructName = (*constructClass->getConstructNameFunction)(constructPtr);
|
1197
|
+
|
1198
|
+
if (constructName != NULL)
|
1199
|
+
{
|
1200
|
+
if (allModules) WriteString(theEnv,STDOUT," ");
|
1201
|
+
WriteString(theEnv,logicalName,constructName->contents);
|
1202
|
+
WriteString(theEnv,logicalName,"\n");
|
1203
|
+
}
|
1204
|
+
|
1205
|
+
count++;
|
1206
|
+
}
|
1207
|
+
|
1208
|
+
/*====================================*/
|
1209
|
+
/* Move on to the next module (if the */
|
1210
|
+
/* listing is to contain the names of */
|
1211
|
+
/* constructs from all modules). */
|
1212
|
+
/*====================================*/
|
1213
|
+
|
1214
|
+
if (allModules) theModule = GetNextDefmodule(theEnv,theModule);
|
1215
|
+
else theModule = NULL;
|
1216
|
+
}
|
1217
|
+
|
1218
|
+
/*=================================================*/
|
1219
|
+
/* Print the tally and restore the current module. */
|
1220
|
+
/*=================================================*/
|
1221
|
+
|
1222
|
+
PrintTally(theEnv,STDOUT,count,constructClass->constructName,
|
1223
|
+
constructClass->pluralName);
|
1224
|
+
|
1225
|
+
RestoreCurrentModule(theEnv);
|
1226
|
+
}
|
1227
|
+
|
1228
|
+
/**********************************************************/
|
1229
|
+
/* SetNextConstruct: Sets the next field of one construct */
|
1230
|
+
/* to point to another construct of the same type. */
|
1231
|
+
/**********************************************************/
|
1232
|
+
void SetNextConstruct(
|
1233
|
+
ConstructHeader *theConstruct,
|
1234
|
+
ConstructHeader *targetConstruct)
|
1235
|
+
{ theConstruct->next = targetConstruct; }
|
1236
|
+
|
1237
|
+
/********************************************************************/
|
1238
|
+
/* GetConstructModuleItem: Returns the construct module for a given */
|
1239
|
+
/* construct (note that this is a pointer to a data structure */
|
1240
|
+
/* like the deffactsModule, not a pointer to an environment */
|
1241
|
+
/* module which contains a number of types of constructs. */
|
1242
|
+
/********************************************************************/
|
1243
|
+
struct defmoduleItemHeader *GetConstructModuleItem(
|
1244
|
+
ConstructHeader *theConstruct)
|
1245
|
+
{ return(theConstruct->whichModule); }
|
1246
|
+
|
1247
|
+
/*************************************************/
|
1248
|
+
/* GetConstructPPForm: Returns the pretty print */
|
1249
|
+
/* representation for the specified construct. */
|
1250
|
+
/*************************************************/
|
1251
|
+
const char *GetConstructPPForm(
|
1252
|
+
ConstructHeader *theConstruct)
|
1253
|
+
{
|
1254
|
+
return theConstruct->ppForm;
|
1255
|
+
}
|
1256
|
+
|
1257
|
+
/****************************************************/
|
1258
|
+
/* GetNextConstructItem: Returns the next construct */
|
1259
|
+
/* items from a list of constructs. */
|
1260
|
+
/****************************************************/
|
1261
|
+
ConstructHeader *GetNextConstructItem(
|
1262
|
+
Environment *theEnv,
|
1263
|
+
ConstructHeader *theConstruct,
|
1264
|
+
unsigned moduleIndex)
|
1265
|
+
{
|
1266
|
+
struct defmoduleItemHeader *theModuleItem;
|
1267
|
+
|
1268
|
+
if (theConstruct == NULL)
|
1269
|
+
{
|
1270
|
+
theModuleItem = (struct defmoduleItemHeader *)
|
1271
|
+
GetModuleItem(theEnv,NULL,moduleIndex);
|
1272
|
+
if (theModuleItem == NULL) return NULL;
|
1273
|
+
return(theModuleItem->firstItem);
|
1274
|
+
}
|
1275
|
+
|
1276
|
+
return(theConstruct->next);
|
1277
|
+
}
|
1278
|
+
|
1279
|
+
/*******************************************************/
|
1280
|
+
/* GetConstructModuleItemByIndex: Returns a pointer to */
|
1281
|
+
/* the defmodule item for the specified construct. If */
|
1282
|
+
/* theModule is NULL, then the construct module item */
|
1283
|
+
/* for the current module is returned, otherwise the */
|
1284
|
+
/* construct module item for the specified construct */
|
1285
|
+
/* is returned. */
|
1286
|
+
/*******************************************************/
|
1287
|
+
struct defmoduleItemHeader *GetConstructModuleItemByIndex(
|
1288
|
+
Environment *theEnv,
|
1289
|
+
Defmodule *theModule,
|
1290
|
+
unsigned moduleIndex)
|
1291
|
+
{
|
1292
|
+
if (theModule != NULL)
|
1293
|
+
{
|
1294
|
+
return((struct defmoduleItemHeader *)
|
1295
|
+
GetModuleItem(theEnv,theModule,moduleIndex));
|
1296
|
+
}
|
1297
|
+
|
1298
|
+
return((struct defmoduleItemHeader *)
|
1299
|
+
GetModuleItem(theEnv,GetCurrentModule(theEnv),moduleIndex));
|
1300
|
+
}
|
1301
|
+
|
1302
|
+
/******************************************/
|
1303
|
+
/* FreeConstructHeaderModule: Deallocates */
|
1304
|
+
/* the data structures associated with */
|
1305
|
+
/* the construct module item header. */
|
1306
|
+
/******************************************/
|
1307
|
+
void FreeConstructHeaderModule(
|
1308
|
+
Environment *theEnv,
|
1309
|
+
struct defmoduleItemHeader *theModuleItem,
|
1310
|
+
Construct *constructClass)
|
1311
|
+
{
|
1312
|
+
ConstructHeader *thisOne, *nextOne;
|
1313
|
+
|
1314
|
+
thisOne = theModuleItem->firstItem;
|
1315
|
+
|
1316
|
+
while (thisOne != NULL)
|
1317
|
+
{
|
1318
|
+
nextOne = thisOne->next;
|
1319
|
+
(*constructClass->freeFunction)(theEnv,thisOne);
|
1320
|
+
thisOne = nextOne;
|
1321
|
+
}
|
1322
|
+
}
|
1323
|
+
|
1324
|
+
/**********************************************/
|
1325
|
+
/* DoForAllConstructs: Executes an action for */
|
1326
|
+
/* all constructs of a specified type. */
|
1327
|
+
/**********************************************/
|
1328
|
+
void DoForAllConstructs(
|
1329
|
+
Environment *theEnv,
|
1330
|
+
void (*actionFunction)(Environment *,ConstructHeader *,void *),
|
1331
|
+
unsigned moduleItemIndex,
|
1332
|
+
bool interruptable,
|
1333
|
+
void *userBuffer)
|
1334
|
+
{
|
1335
|
+
ConstructHeader *theConstruct, *next = NULL;
|
1336
|
+
struct defmoduleItemHeader *theModuleItem;
|
1337
|
+
Defmodule *theModule;
|
1338
|
+
long moduleCount = 0L;
|
1339
|
+
|
1340
|
+
/*==========================*/
|
1341
|
+
/* Save the current module. */
|
1342
|
+
/*==========================*/
|
1343
|
+
|
1344
|
+
SaveCurrentModule(theEnv);
|
1345
|
+
|
1346
|
+
/*==================================*/
|
1347
|
+
/* Loop through all of the modules. */
|
1348
|
+
/*==================================*/
|
1349
|
+
|
1350
|
+
for (theModule = GetNextDefmodule(theEnv,NULL);
|
1351
|
+
theModule != NULL;
|
1352
|
+
theModule = GetNextDefmodule(theEnv,theModule), moduleCount++)
|
1353
|
+
{
|
1354
|
+
/*=============================*/
|
1355
|
+
/* Set the current module to */
|
1356
|
+
/* the module we're examining. */
|
1357
|
+
/*=============================*/
|
1358
|
+
|
1359
|
+
SetCurrentModule(theEnv,theModule);
|
1360
|
+
|
1361
|
+
/*================================================*/
|
1362
|
+
/* Perform the action for each of the constructs. */
|
1363
|
+
/*================================================*/
|
1364
|
+
|
1365
|
+
theModuleItem = (struct defmoduleItemHeader *)
|
1366
|
+
GetModuleItem(theEnv,theModule,moduleItemIndex);
|
1367
|
+
|
1368
|
+
for (theConstruct = theModuleItem->firstItem;
|
1369
|
+
theConstruct != NULL;
|
1370
|
+
theConstruct = next)
|
1371
|
+
{
|
1372
|
+
/*==========================================*/
|
1373
|
+
/* Check to see iteration should be halted. */
|
1374
|
+
/*==========================================*/
|
1375
|
+
|
1376
|
+
if (interruptable)
|
1377
|
+
{
|
1378
|
+
if (GetHaltExecution(theEnv) == true)
|
1379
|
+
{
|
1380
|
+
RestoreCurrentModule(theEnv);
|
1381
|
+
return;
|
1382
|
+
}
|
1383
|
+
}
|
1384
|
+
|
1385
|
+
/*===============================================*/
|
1386
|
+
/* Determine the next construct since the action */
|
1387
|
+
/* could delete the current construct. */
|
1388
|
+
/*===============================================*/
|
1389
|
+
|
1390
|
+
next = theConstruct->next;
|
1391
|
+
|
1392
|
+
/*===============================================*/
|
1393
|
+
/* Perform the action for the current construct. */
|
1394
|
+
/*===============================================*/
|
1395
|
+
|
1396
|
+
(*actionFunction)(theEnv,theConstruct,userBuffer);
|
1397
|
+
}
|
1398
|
+
}
|
1399
|
+
|
1400
|
+
/*=============================*/
|
1401
|
+
/* Restore the current module. */
|
1402
|
+
/*=============================*/
|
1403
|
+
|
1404
|
+
RestoreCurrentModule(theEnv);
|
1405
|
+
}
|
1406
|
+
|
1407
|
+
/******************************************************/
|
1408
|
+
/* DoForAllConstructsInModule: Executes an action for */
|
1409
|
+
/* all constructs of a specified type in a module. */
|
1410
|
+
/******************************************************/
|
1411
|
+
void DoForAllConstructsInModule(
|
1412
|
+
Environment *theEnv,
|
1413
|
+
Defmodule *theModule,
|
1414
|
+
ConstructActionFunction *actionFunction,
|
1415
|
+
unsigned moduleItemIndex,
|
1416
|
+
bool interruptable,
|
1417
|
+
void *userBuffer)
|
1418
|
+
{
|
1419
|
+
ConstructHeader *theConstruct;
|
1420
|
+
struct defmoduleItemHeader *theModuleItem;
|
1421
|
+
|
1422
|
+
/*==========================*/
|
1423
|
+
/* Save the current module. */
|
1424
|
+
/*==========================*/
|
1425
|
+
|
1426
|
+
SaveCurrentModule(theEnv);
|
1427
|
+
|
1428
|
+
/*=============================*/
|
1429
|
+
/* Set the current module to */
|
1430
|
+
/* the module we're examining. */
|
1431
|
+
/*=============================*/
|
1432
|
+
|
1433
|
+
SetCurrentModule(theEnv,theModule);
|
1434
|
+
|
1435
|
+
/*================================================*/
|
1436
|
+
/* Perform the action for each of the constructs. */
|
1437
|
+
/*================================================*/
|
1438
|
+
|
1439
|
+
theModuleItem = (struct defmoduleItemHeader *)
|
1440
|
+
GetModuleItem(theEnv,theModule,moduleItemIndex);
|
1441
|
+
|
1442
|
+
for (theConstruct = theModuleItem->firstItem;
|
1443
|
+
theConstruct != NULL;
|
1444
|
+
theConstruct = theConstruct->next)
|
1445
|
+
{
|
1446
|
+
if (interruptable)
|
1447
|
+
{
|
1448
|
+
if (GetHaltExecution(theEnv) == true)
|
1449
|
+
{
|
1450
|
+
RestoreCurrentModule(theEnv);
|
1451
|
+
return;
|
1452
|
+
}
|
1453
|
+
}
|
1454
|
+
|
1455
|
+
(*actionFunction)(theEnv,theConstruct,userBuffer);
|
1456
|
+
}
|
1457
|
+
|
1458
|
+
/*=============================*/
|
1459
|
+
/* Restore the current module. */
|
1460
|
+
/*=============================*/
|
1461
|
+
|
1462
|
+
RestoreCurrentModule(theEnv);
|
1463
|
+
}
|
1464
|
+
|
1465
|
+
/*****************************************************/
|
1466
|
+
/* InitializeConstructHeader: Initializes construct */
|
1467
|
+
/* header info, including to which module item the */
|
1468
|
+
/* new construct belongs */
|
1469
|
+
/*****************************************************/
|
1470
|
+
void InitializeConstructHeader(
|
1471
|
+
Environment *theEnv,
|
1472
|
+
const char *constructNameString,
|
1473
|
+
ConstructType theType,
|
1474
|
+
ConstructHeader *theConstruct,
|
1475
|
+
CLIPSLexeme *theConstructName)
|
1476
|
+
{
|
1477
|
+
struct moduleItem *theModuleItem;
|
1478
|
+
struct defmoduleItemHeader *theItemHeader;
|
1479
|
+
|
1480
|
+
theModuleItem = FindModuleItem(theEnv,constructNameString);
|
1481
|
+
theItemHeader = (struct defmoduleItemHeader *)
|
1482
|
+
GetModuleItem(theEnv,NULL,theModuleItem->moduleIndex);
|
1483
|
+
|
1484
|
+
theConstruct->whichModule = theItemHeader;
|
1485
|
+
theConstruct->name = theConstructName;
|
1486
|
+
theConstruct->ppForm = NULL;
|
1487
|
+
theConstruct->bsaveID = 0L;
|
1488
|
+
theConstruct->next = NULL;
|
1489
|
+
theConstruct->usrData = NULL;
|
1490
|
+
theConstruct->constructType = theType;
|
1491
|
+
theConstruct->env = theEnv;
|
1492
|
+
}
|
1493
|
+
|
1494
|
+
/*************************************************/
|
1495
|
+
/* SetConstructPPForm: Sets a construct's pretty */
|
1496
|
+
/* print form and deletes the old one. */
|
1497
|
+
/*************************************************/
|
1498
|
+
void SetConstructPPForm(
|
1499
|
+
Environment *theEnv,
|
1500
|
+
ConstructHeader *theConstruct,
|
1501
|
+
const char *ppForm)
|
1502
|
+
{
|
1503
|
+
if (theConstruct->ppForm != NULL)
|
1504
|
+
{
|
1505
|
+
rm(theEnv,(void *) theConstruct->ppForm,
|
1506
|
+
((strlen(theConstruct->ppForm) + 1) * sizeof(char)));
|
1507
|
+
}
|
1508
|
+
theConstruct->ppForm = ppForm;
|
1509
|
+
}
|
1510
|
+
|
1511
|
+
#if DEBUGGING_FUNCTIONS
|
1512
|
+
|
1513
|
+
/******************************************************/
|
1514
|
+
/* ConstructPrintWatchAccess: Provides an interface */
|
1515
|
+
/* to the list-watch-items function for a construct */
|
1516
|
+
/******************************************************/
|
1517
|
+
bool ConstructPrintWatchAccess(
|
1518
|
+
Environment *theEnv,
|
1519
|
+
Construct *constructClass,
|
1520
|
+
const char *logName,
|
1521
|
+
Expression *argExprs,
|
1522
|
+
ConstructGetWatchFunction *getWatchFunc,
|
1523
|
+
ConstructSetWatchFunction *setWatchFunc)
|
1524
|
+
{
|
1525
|
+
return(ConstructWatchSupport(theEnv,constructClass,"list-watch-items",logName,argExprs,
|
1526
|
+
false,false,getWatchFunc,setWatchFunc));
|
1527
|
+
}
|
1528
|
+
|
1529
|
+
/**************************************************/
|
1530
|
+
/* ConstructSetWatchAccess: Provides an interface */
|
1531
|
+
/* to the watch function for a construct */
|
1532
|
+
/**************************************************/
|
1533
|
+
bool ConstructSetWatchAccess(
|
1534
|
+
Environment *theEnv,
|
1535
|
+
Construct *constructClass,
|
1536
|
+
bool newState,
|
1537
|
+
Expression *argExprs,
|
1538
|
+
ConstructGetWatchFunction *getWatchFunc,
|
1539
|
+
ConstructSetWatchFunction *setWatchFunc)
|
1540
|
+
{
|
1541
|
+
return(ConstructWatchSupport(theEnv,constructClass,"watch",STDERR,argExprs,
|
1542
|
+
true,newState,getWatchFunc,setWatchFunc));
|
1543
|
+
}
|
1544
|
+
|
1545
|
+
/******************************************************/
|
1546
|
+
/* ConstructWatchSupport: Generic construct interface */
|
1547
|
+
/* into watch and list-watch-items. */
|
1548
|
+
/******************************************************/
|
1549
|
+
static bool ConstructWatchSupport(
|
1550
|
+
Environment *theEnv,
|
1551
|
+
Construct *constructClass,
|
1552
|
+
const char *funcName,
|
1553
|
+
const char *logName,
|
1554
|
+
Expression *argExprs,
|
1555
|
+
bool setFlag,
|
1556
|
+
bool newState,
|
1557
|
+
ConstructGetWatchFunction *getWatchFunc,
|
1558
|
+
ConstructSetWatchFunction *setWatchFunc)
|
1559
|
+
{
|
1560
|
+
Defmodule *theModule;
|
1561
|
+
ConstructHeader *theConstruct = NULL;
|
1562
|
+
UDFValue constructName;
|
1563
|
+
unsigned int argIndex = 2;
|
1564
|
+
|
1565
|
+
/*========================================*/
|
1566
|
+
/* If no constructs are specified, then */
|
1567
|
+
/* show/set the trace for all constructs. */
|
1568
|
+
/*========================================*/
|
1569
|
+
|
1570
|
+
if (argExprs == NULL)
|
1571
|
+
{
|
1572
|
+
/*==========================*/
|
1573
|
+
/* Save the current module. */
|
1574
|
+
/*==========================*/
|
1575
|
+
|
1576
|
+
SaveCurrentModule(theEnv);
|
1577
|
+
|
1578
|
+
/*===========================*/
|
1579
|
+
/* Loop through each module. */
|
1580
|
+
/*===========================*/
|
1581
|
+
|
1582
|
+
for (theModule = GetNextDefmodule(theEnv,NULL);
|
1583
|
+
theModule != NULL;
|
1584
|
+
theModule = GetNextDefmodule(theEnv,theModule))
|
1585
|
+
{
|
1586
|
+
/*============================*/
|
1587
|
+
/* Set the current module to */
|
1588
|
+
/* the module being examined. */
|
1589
|
+
/*============================*/
|
1590
|
+
|
1591
|
+
SetCurrentModule(theEnv,theModule);
|
1592
|
+
|
1593
|
+
/*====================================================*/
|
1594
|
+
/* If we're displaying the names of constructs with */
|
1595
|
+
/* watch flags enabled, then preface each module */
|
1596
|
+
/* listing of constructs with the name of the module. */
|
1597
|
+
/*====================================================*/
|
1598
|
+
|
1599
|
+
if (setFlag == false)
|
1600
|
+
{
|
1601
|
+
WriteString(theEnv,logName,DefmoduleName(theModule));
|
1602
|
+
WriteString(theEnv,logName,":\n");
|
1603
|
+
}
|
1604
|
+
|
1605
|
+
/*============================================*/
|
1606
|
+
/* Loop through each construct in the module. */
|
1607
|
+
/*============================================*/
|
1608
|
+
|
1609
|
+
for (theConstruct = (*constructClass->getNextItemFunction)(theEnv,NULL);
|
1610
|
+
theConstruct != NULL;
|
1611
|
+
theConstruct = (*constructClass->getNextItemFunction)(theEnv,theConstruct))
|
1612
|
+
{
|
1613
|
+
/*=============================================*/
|
1614
|
+
/* Either set the watch flag for the construct */
|
1615
|
+
/* or display its current state. */
|
1616
|
+
/*=============================================*/
|
1617
|
+
|
1618
|
+
if (setFlag)
|
1619
|
+
{ (*setWatchFunc)(theConstruct,newState); }
|
1620
|
+
else
|
1621
|
+
{
|
1622
|
+
WriteString(theEnv,logName," ");
|
1623
|
+
ConstructPrintWatch(theEnv,logName,constructClass,theConstruct,getWatchFunc);
|
1624
|
+
}
|
1625
|
+
}
|
1626
|
+
}
|
1627
|
+
|
1628
|
+
/*=============================*/
|
1629
|
+
/* Restore the current module. */
|
1630
|
+
/*=============================*/
|
1631
|
+
|
1632
|
+
RestoreCurrentModule(theEnv);
|
1633
|
+
|
1634
|
+
/*====================================*/
|
1635
|
+
/* Return true to indicate successful */
|
1636
|
+
/* completion of the command. */
|
1637
|
+
/*====================================*/
|
1638
|
+
|
1639
|
+
return true;
|
1640
|
+
}
|
1641
|
+
|
1642
|
+
/*==================================================*/
|
1643
|
+
/* Show/set the trace for each specified construct. */
|
1644
|
+
/*==================================================*/
|
1645
|
+
|
1646
|
+
while (argExprs != NULL)
|
1647
|
+
{
|
1648
|
+
/*==========================================*/
|
1649
|
+
/* Evaluate the argument that should be a */
|
1650
|
+
/* construct name. Return false is an error */
|
1651
|
+
/* occurs when evaluating the argument. */
|
1652
|
+
/*==========================================*/
|
1653
|
+
|
1654
|
+
if (EvaluateExpression(theEnv,argExprs,&constructName))
|
1655
|
+
{ return false; }
|
1656
|
+
|
1657
|
+
/*================================================*/
|
1658
|
+
/* Check to see that it's a valid construct name. */
|
1659
|
+
/*================================================*/
|
1660
|
+
|
1661
|
+
if ((constructName.header->type != SYMBOL_TYPE) ? true :
|
1662
|
+
((theConstruct = LookupConstruct(theEnv,constructClass,
|
1663
|
+
constructName.lexemeValue->contents,true)) == NULL))
|
1664
|
+
{
|
1665
|
+
ExpectedTypeError1(theEnv,funcName,argIndex,constructClass->constructName);
|
1666
|
+
return false;
|
1667
|
+
}
|
1668
|
+
|
1669
|
+
/*=============================================*/
|
1670
|
+
/* Either set the watch flag for the construct */
|
1671
|
+
/* or display its current state. */
|
1672
|
+
/*=============================================*/
|
1673
|
+
|
1674
|
+
if (setFlag)
|
1675
|
+
{ (*setWatchFunc)(theConstruct,newState); }
|
1676
|
+
else
|
1677
|
+
{ ConstructPrintWatch(theEnv,logName,constructClass,theConstruct,getWatchFunc); }
|
1678
|
+
|
1679
|
+
/*===============================*/
|
1680
|
+
/* Move on to the next argument. */
|
1681
|
+
/*===============================*/
|
1682
|
+
|
1683
|
+
argIndex++;
|
1684
|
+
argExprs = GetNextArgument(argExprs);
|
1685
|
+
}
|
1686
|
+
|
1687
|
+
/*====================================*/
|
1688
|
+
/* Return true to indicate successful */
|
1689
|
+
/* completion of the command. */
|
1690
|
+
/*====================================*/
|
1691
|
+
|
1692
|
+
return true;
|
1693
|
+
}
|
1694
|
+
|
1695
|
+
/*************************************************/
|
1696
|
+
/* ConstructPrintWatch: Displays the trace value */
|
1697
|
+
/* of a construct for list-watch-items */
|
1698
|
+
/*************************************************/
|
1699
|
+
static void ConstructPrintWatch(
|
1700
|
+
Environment *theEnv,
|
1701
|
+
const char *logName,
|
1702
|
+
Construct *constructClass,
|
1703
|
+
ConstructHeader *theConstruct,
|
1704
|
+
ConstructGetWatchFunction *getWatchFunc)
|
1705
|
+
{
|
1706
|
+
WriteString(theEnv,logName,(*constructClass->getConstructNameFunction)(theConstruct)->contents);
|
1707
|
+
if ((*getWatchFunc)(theConstruct))
|
1708
|
+
WriteString(theEnv,logName," = on\n");
|
1709
|
+
else
|
1710
|
+
WriteString(theEnv,logName," = off\n");
|
1711
|
+
}
|
1712
|
+
|
1713
|
+
#endif /* DEBUGGING_FUNCTIONS */
|
1714
|
+
|
1715
|
+
/*****************************************************/
|
1716
|
+
/* LookupConstruct: Finds a construct in the current */
|
1717
|
+
/* or imported modules. If specified, will also */
|
1718
|
+
/* look for construct in a non-imported module. */
|
1719
|
+
/*****************************************************/
|
1720
|
+
ConstructHeader *LookupConstruct(
|
1721
|
+
Environment *theEnv,
|
1722
|
+
Construct *constructClass,
|
1723
|
+
const char *constructName,
|
1724
|
+
bool moduleNameAllowed)
|
1725
|
+
{
|
1726
|
+
ConstructHeader *theConstruct;
|
1727
|
+
const char *constructType;
|
1728
|
+
unsigned int moduleCount;
|
1729
|
+
|
1730
|
+
/*============================================*/
|
1731
|
+
/* Look for the specified construct in the */
|
1732
|
+
/* current module or in any imported modules. */
|
1733
|
+
/*============================================*/
|
1734
|
+
|
1735
|
+
constructType = constructClass->constructName;
|
1736
|
+
theConstruct = FindImportedConstruct(theEnv,constructType,NULL,constructName,
|
1737
|
+
&moduleCount,true,NULL);
|
1738
|
+
|
1739
|
+
/*===========================================*/
|
1740
|
+
/* Return NULL if the reference is ambiguous */
|
1741
|
+
/* (it was found in more than one module). */
|
1742
|
+
/*===========================================*/
|
1743
|
+
|
1744
|
+
if (theConstruct != NULL)
|
1745
|
+
{
|
1746
|
+
if (moduleCount > 1)
|
1747
|
+
{
|
1748
|
+
AmbiguousReferenceErrorMessage(theEnv,constructType,constructName);
|
1749
|
+
return NULL;
|
1750
|
+
}
|
1751
|
+
return(theConstruct);
|
1752
|
+
}
|
1753
|
+
|
1754
|
+
/*=============================================*/
|
1755
|
+
/* If specified, check to see if the construct */
|
1756
|
+
/* is in a non-imported module. */
|
1757
|
+
/*=============================================*/
|
1758
|
+
|
1759
|
+
if (moduleNameAllowed && FindModuleSeparator(constructName))
|
1760
|
+
{ theConstruct = (*constructClass->findFunction)(theEnv,constructName); }
|
1761
|
+
|
1762
|
+
/*====================================*/
|
1763
|
+
/* Return a pointer to the construct. */
|
1764
|
+
/*====================================*/
|
1765
|
+
|
1766
|
+
return(theConstruct);
|
1767
|
+
}
|
1768
|
+
|
1769
|
+
/***********************************************************/
|
1770
|
+
/* ConstructsDeletable: Returns a boolean value indicating */
|
1771
|
+
/* whether constructs in general can be deleted. */
|
1772
|
+
/***********************************************************/
|
1773
|
+
bool ConstructsDeletable(
|
1774
|
+
Environment *theEnv)
|
1775
|
+
{
|
1776
|
+
#if BLOAD_ONLY || RUN_TIME || ((! BLOAD) && (! BLOAD_AND_BSAVE))
|
1777
|
+
#if MAC_XCD
|
1778
|
+
#pragma unused(theEnv)
|
1779
|
+
#endif
|
1780
|
+
#endif
|
1781
|
+
|
1782
|
+
#if BLOAD_ONLY || RUN_TIME
|
1783
|
+
return false;
|
1784
|
+
#elif BLOAD || BLOAD_AND_BSAVE
|
1785
|
+
if (Bloaded(theEnv))
|
1786
|
+
return false;
|
1787
|
+
return true;
|
1788
|
+
#else
|
1789
|
+
return true;
|
1790
|
+
#endif
|
1791
|
+
}
|