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,893 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.40 07/30/16 */
|
5
|
+
/* */
|
6
|
+
/* SYMBOL_TYPE CONSTRUCT COMPILER MODULE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: Implements the constructs-to-c feature for */
|
11
|
+
/* atomic data values: symbols, integers, floats, and */
|
12
|
+
/* bit maps. */
|
13
|
+
/* */
|
14
|
+
/* Principal Programmer(s): */
|
15
|
+
/* Gary D. Riley */
|
16
|
+
/* Barry Cameron */
|
17
|
+
/* */
|
18
|
+
/* Contributing Programmer(s): */
|
19
|
+
/* Brian L. Dantes */
|
20
|
+
/* */
|
21
|
+
/* Revision History: */
|
22
|
+
/* */
|
23
|
+
/* 6.24: Added environment parameter to GenClose. */
|
24
|
+
/* */
|
25
|
+
/* Corrected code to remove compiler warnings. */
|
26
|
+
/* */
|
27
|
+
/* 6.30: Added support for path name argument to */
|
28
|
+
/* constructs-to-c. */
|
29
|
+
/* */
|
30
|
+
/* Support for long long integers. */
|
31
|
+
/* */
|
32
|
+
/* Added const qualifiers to remove C++ */
|
33
|
+
/* deprecation warnings. */
|
34
|
+
/* */
|
35
|
+
/* 6.40: Pragma once and other inclusion changes. */
|
36
|
+
/* */
|
37
|
+
/* Added support for booleans with <stdbool.h>. */
|
38
|
+
/* */
|
39
|
+
/* Removed use of void pointers for specific */
|
40
|
+
/* data structures. */
|
41
|
+
/* */
|
42
|
+
/*************************************************************/
|
43
|
+
|
44
|
+
#include "setup.h"
|
45
|
+
|
46
|
+
#if CONSTRUCT_COMPILER && (! RUN_TIME)
|
47
|
+
|
48
|
+
#include <stdio.h>
|
49
|
+
#include <string.h>
|
50
|
+
|
51
|
+
#include "argacces.h"
|
52
|
+
#include "constant.h"
|
53
|
+
#include "conscomp.h"
|
54
|
+
#include "constrct.h"
|
55
|
+
#include "cstrncmp.h"
|
56
|
+
#include "cstrccom.h"
|
57
|
+
#include "envrnmnt.h"
|
58
|
+
#include "exprnpsr.h"
|
59
|
+
#include "memalloc.h"
|
60
|
+
#include "prntutil.h"
|
61
|
+
#include "router.h"
|
62
|
+
#include "symbol.h"
|
63
|
+
#include "sysdep.h"
|
64
|
+
#include "utility.h"
|
65
|
+
|
66
|
+
#include "symblcmp.h"
|
67
|
+
|
68
|
+
/***************************************/
|
69
|
+
/* LOCAL INTERNAL FUNCTION DEFINITIONS */
|
70
|
+
/***************************************/
|
71
|
+
|
72
|
+
static unsigned int SymbolHashNodesToCode(Environment *,const char *,const char *,char *,unsigned int);
|
73
|
+
static unsigned int BitMapHashNodesToCode(Environment *,const char *,const char *,char *,unsigned int);
|
74
|
+
static unsigned int BitMapValuesToCode(Environment *,const char *,const char *, char *,unsigned int);
|
75
|
+
static unsigned int FloatHashNodesToCode(Environment *,const char *,const char *,char *,unsigned int);
|
76
|
+
static unsigned int IntegerHashNodesToCode(Environment *,const char *,const char *,char *,unsigned int);
|
77
|
+
static int HashTablesToCode(Environment *,const char *,const char *,char *);
|
78
|
+
static void PrintCString(FILE *,const char *);
|
79
|
+
|
80
|
+
/**************************************************************/
|
81
|
+
/* AtomicValuesToCode: Driver routine for generating the code */
|
82
|
+
/* used by the symbol, integer, float, and bit map tables. */
|
83
|
+
/**************************************************************/
|
84
|
+
void AtomicValuesToCode(
|
85
|
+
Environment *theEnv,
|
86
|
+
const char *fileName,
|
87
|
+
const char *pathName,
|
88
|
+
char *fileNameBuffer)
|
89
|
+
{
|
90
|
+
unsigned int version; // TBD Necessary?
|
91
|
+
|
92
|
+
SetAtomicValueIndices(theEnv,true);
|
93
|
+
|
94
|
+
HashTablesToCode(theEnv,fileName,pathName,fileNameBuffer);
|
95
|
+
|
96
|
+
version = SymbolHashNodesToCode(theEnv,fileName,pathName,fileNameBuffer,5);
|
97
|
+
version = FloatHashNodesToCode(theEnv,fileName,pathName,fileNameBuffer,version);
|
98
|
+
version = IntegerHashNodesToCode(theEnv,fileName,pathName,fileNameBuffer,version);
|
99
|
+
version = BitMapHashNodesToCode(theEnv,fileName,pathName,fileNameBuffer,version);
|
100
|
+
BitMapValuesToCode(theEnv,fileName,pathName,fileNameBuffer,version);
|
101
|
+
}
|
102
|
+
|
103
|
+
/*****************************************************/
|
104
|
+
/* SymbolHashNodesToCode: Produces the code for the */
|
105
|
+
/* symbol hash table entries for a run-time module */
|
106
|
+
/* created using the constructs-to-c function. */
|
107
|
+
/*****************************************************/
|
108
|
+
static unsigned int SymbolHashNodesToCode(
|
109
|
+
Environment *theEnv,
|
110
|
+
const char *fileName,
|
111
|
+
const char *pathName,
|
112
|
+
char *fileNameBuffer,
|
113
|
+
unsigned int version)
|
114
|
+
{
|
115
|
+
unsigned long i, j;
|
116
|
+
CLIPSLexeme *hashPtr;
|
117
|
+
unsigned int count;
|
118
|
+
unsigned int numberOfEntries;
|
119
|
+
CLIPSLexeme **symbolTable;
|
120
|
+
bool newHeader = true;
|
121
|
+
int arrayVersion = 1;
|
122
|
+
FILE *fp;
|
123
|
+
|
124
|
+
/*====================================*/
|
125
|
+
/* Count the total number of entries. */
|
126
|
+
/*====================================*/
|
127
|
+
|
128
|
+
symbolTable = GetSymbolTable(theEnv);
|
129
|
+
count = numberOfEntries = 0;
|
130
|
+
|
131
|
+
for (i = 0; i < SYMBOL_HASH_SIZE; i++)
|
132
|
+
{
|
133
|
+
for (hashPtr = symbolTable[i];
|
134
|
+
hashPtr != NULL;
|
135
|
+
hashPtr = hashPtr->next)
|
136
|
+
{ numberOfEntries++; }
|
137
|
+
}
|
138
|
+
|
139
|
+
if (numberOfEntries == 0) return version;
|
140
|
+
|
141
|
+
for (i = 1; i <= (numberOfEntries / ConstructCompilerData(theEnv)->MaxIndices) + 1 ; i++)
|
142
|
+
{ fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern CLIPSLexeme S%d_%ld[];\n",ConstructCompilerData(theEnv)->ImageID,i); }
|
143
|
+
|
144
|
+
/*==================*/
|
145
|
+
/* Create the file. */
|
146
|
+
/*==================*/
|
147
|
+
|
148
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,false)) == NULL) return version;
|
149
|
+
|
150
|
+
/*===================*/
|
151
|
+
/* List the entries. */
|
152
|
+
/*===================*/
|
153
|
+
|
154
|
+
j = 0;
|
155
|
+
|
156
|
+
for (i = 0; i < SYMBOL_HASH_SIZE; i++)
|
157
|
+
{
|
158
|
+
for (hashPtr = symbolTable[i];
|
159
|
+
hashPtr != NULL;
|
160
|
+
hashPtr = hashPtr->next)
|
161
|
+
{
|
162
|
+
if (newHeader)
|
163
|
+
{
|
164
|
+
fprintf(fp,"CLIPSLexeme S%d_%d[] = {\n",ConstructCompilerData(theEnv)->ImageID,arrayVersion);
|
165
|
+
newHeader = false;
|
166
|
+
}
|
167
|
+
|
168
|
+
if (hashPtr->header.type == SYMBOL_TYPE)
|
169
|
+
{ fprintf(fp,"{{SYMBOL_TYPE},"); }
|
170
|
+
else if (hashPtr->header.type == STRING_TYPE)
|
171
|
+
{ fprintf(fp,"{{STRING_TYPE},"); }
|
172
|
+
else
|
173
|
+
{ fprintf(fp,"{{INSTANCE_NAME_TYPE},"); }
|
174
|
+
|
175
|
+
if (hashPtr->next == NULL)
|
176
|
+
{ fprintf(fp,"NULL,"); }
|
177
|
+
else
|
178
|
+
{
|
179
|
+
if ((j + 1) >= (unsigned long) ConstructCompilerData(theEnv)->MaxIndices)
|
180
|
+
{ fprintf(fp,"&S%d_%d[%d],",ConstructCompilerData(theEnv)->ImageID,arrayVersion + 1,0); }
|
181
|
+
else
|
182
|
+
{ fprintf(fp,"&S%d_%d[%ld],",ConstructCompilerData(theEnv)->ImageID,arrayVersion,j + 1); }
|
183
|
+
}
|
184
|
+
|
185
|
+
fprintf(fp,"%ld,1,0,0,%ld,",hashPtr->count + 1,i);
|
186
|
+
PrintCString(fp,hashPtr->contents);
|
187
|
+
|
188
|
+
count++;
|
189
|
+
j++;
|
190
|
+
|
191
|
+
if ((count == numberOfEntries) || (j >= ConstructCompilerData(theEnv)->MaxIndices))
|
192
|
+
{
|
193
|
+
fprintf(fp,"}};\n");
|
194
|
+
GenClose(theEnv,fp);
|
195
|
+
j = 0;
|
196
|
+
arrayVersion++;
|
197
|
+
version++;
|
198
|
+
if (count < numberOfEntries)
|
199
|
+
{
|
200
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,false)) == NULL)
|
201
|
+
{ return 0; }
|
202
|
+
newHeader = true;
|
203
|
+
}
|
204
|
+
}
|
205
|
+
else
|
206
|
+
{ fprintf(fp,"},\n"); }
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
return version;
|
211
|
+
}
|
212
|
+
|
213
|
+
/******************************************************/
|
214
|
+
/* BitMapHashNodesToCode: Produces the code for the */
|
215
|
+
/* bit map hash table entries for a run-time module */
|
216
|
+
/* created using the constructs-to-c function. */
|
217
|
+
/******************************************************/
|
218
|
+
static unsigned int BitMapHashNodesToCode(
|
219
|
+
Environment *theEnv,
|
220
|
+
const char *fileName,
|
221
|
+
const char *pathName,
|
222
|
+
char *fileNameBuffer,
|
223
|
+
unsigned int version)
|
224
|
+
{
|
225
|
+
unsigned int i, j;
|
226
|
+
CLIPSBitMap *hashPtr;
|
227
|
+
unsigned int count;
|
228
|
+
unsigned int numberOfEntries;
|
229
|
+
CLIPSBitMap **bitMapTable;
|
230
|
+
bool newHeader = true;
|
231
|
+
unsigned int arrayVersion = 1;
|
232
|
+
FILE *fp;
|
233
|
+
unsigned int longsReqdPartition = 1, longsReqdPartitionCount = 0;
|
234
|
+
|
235
|
+
/*====================================*/
|
236
|
+
/* Count the total number of entries. */
|
237
|
+
/*====================================*/
|
238
|
+
|
239
|
+
bitMapTable = GetBitMapTable(theEnv);
|
240
|
+
count = numberOfEntries = 0;
|
241
|
+
|
242
|
+
for (i = 0; i < BITMAP_HASH_SIZE; i++)
|
243
|
+
{
|
244
|
+
for (hashPtr = bitMapTable[i];
|
245
|
+
hashPtr != NULL;
|
246
|
+
hashPtr = hashPtr->next)
|
247
|
+
{ numberOfEntries++; }
|
248
|
+
}
|
249
|
+
|
250
|
+
if (numberOfEntries == 0) return version;
|
251
|
+
|
252
|
+
for (i = 1; i <= (numberOfEntries / ConstructCompilerData(theEnv)->MaxIndices) + 1 ; i++)
|
253
|
+
{ fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern struct clipsBitMap B%d_%d[];\n",ConstructCompilerData(theEnv)->ImageID,i); }
|
254
|
+
|
255
|
+
/*==================*/
|
256
|
+
/* Create the file. */
|
257
|
+
/*==================*/
|
258
|
+
|
259
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,false)) == NULL) return version;
|
260
|
+
|
261
|
+
/*===================*/
|
262
|
+
/* List the entries. */
|
263
|
+
/*===================*/
|
264
|
+
|
265
|
+
j = 0;
|
266
|
+
|
267
|
+
for (i = 0; i < BITMAP_HASH_SIZE; i++)
|
268
|
+
{
|
269
|
+
for (hashPtr = bitMapTable[i];
|
270
|
+
hashPtr != NULL;
|
271
|
+
hashPtr = hashPtr->next)
|
272
|
+
{
|
273
|
+
if (newHeader)
|
274
|
+
{
|
275
|
+
fprintf(fp,"struct clipsBitMap B%d_%d[] = {\n",ConstructCompilerData(theEnv)->ImageID,arrayVersion);
|
276
|
+
newHeader = false;
|
277
|
+
}
|
278
|
+
|
279
|
+
fprintf(fp,"{{BITMAP_TYPE},");
|
280
|
+
|
281
|
+
if (hashPtr->next == NULL)
|
282
|
+
{ fprintf(fp,"NULL,"); }
|
283
|
+
else
|
284
|
+
{
|
285
|
+
if ((j + 1) >= ConstructCompilerData(theEnv)->MaxIndices)
|
286
|
+
{ fprintf(fp,"&B%d_%d[%d],",ConstructCompilerData(theEnv)->ImageID,arrayVersion + 1,0); }
|
287
|
+
else
|
288
|
+
{ fprintf(fp,"&B%d_%d[%d],",ConstructCompilerData(theEnv)->ImageID,arrayVersion,j + 1); }
|
289
|
+
}
|
290
|
+
|
291
|
+
fprintf(fp,"%ld,1,0,0,%d,(char *) &L%d_%d[%d],%d",
|
292
|
+
hashPtr->count + 1,i,
|
293
|
+
ConstructCompilerData(theEnv)->ImageID,longsReqdPartition,longsReqdPartitionCount,
|
294
|
+
hashPtr->size);
|
295
|
+
|
296
|
+
longsReqdPartitionCount += (hashPtr->size / sizeof(unsigned long));
|
297
|
+
if ((hashPtr->size % sizeof(unsigned long)) != 0)
|
298
|
+
longsReqdPartitionCount++;
|
299
|
+
if (longsReqdPartitionCount >= ConstructCompilerData(theEnv)->MaxIndices)
|
300
|
+
{
|
301
|
+
longsReqdPartitionCount = 0;
|
302
|
+
longsReqdPartition++;
|
303
|
+
}
|
304
|
+
|
305
|
+
count++;
|
306
|
+
j++;
|
307
|
+
|
308
|
+
if ((count == numberOfEntries) || (j >= ConstructCompilerData(theEnv)->MaxIndices))
|
309
|
+
{
|
310
|
+
fprintf(fp,"}};\n");
|
311
|
+
GenClose(theEnv,fp);
|
312
|
+
j = 0;
|
313
|
+
arrayVersion++;
|
314
|
+
version++;
|
315
|
+
if (count < numberOfEntries)
|
316
|
+
{
|
317
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,false)) == NULL)
|
318
|
+
{ return 0; }
|
319
|
+
newHeader = true;
|
320
|
+
}
|
321
|
+
}
|
322
|
+
else
|
323
|
+
{ fprintf(fp,"},\n"); }
|
324
|
+
}
|
325
|
+
}
|
326
|
+
|
327
|
+
return version;
|
328
|
+
}
|
329
|
+
|
330
|
+
/*****************************************************/
|
331
|
+
/* BitMapValuesToCode: Produces the code for the bit */
|
332
|
+
/* map strings for a run-time module created using */
|
333
|
+
/* the constructs-to-c function. */
|
334
|
+
/*****************************************************/
|
335
|
+
static unsigned int BitMapValuesToCode(
|
336
|
+
Environment *theEnv,
|
337
|
+
const char *fileName,
|
338
|
+
const char *pathName,
|
339
|
+
char *fileNameBuffer,
|
340
|
+
unsigned int version)
|
341
|
+
{
|
342
|
+
unsigned int i, j, k;
|
343
|
+
unsigned l;
|
344
|
+
CLIPSBitMap *hashPtr;
|
345
|
+
unsigned int count;
|
346
|
+
unsigned int numberOfEntries;
|
347
|
+
CLIPSBitMap **bitMapTable;
|
348
|
+
bool newHeader = true;
|
349
|
+
unsigned int arrayVersion = 1;
|
350
|
+
FILE *fp;
|
351
|
+
unsigned long tmpLong;
|
352
|
+
unsigned int longsReqd;
|
353
|
+
|
354
|
+
/*====================================*/
|
355
|
+
/* Count the total number of entries. */
|
356
|
+
/*====================================*/
|
357
|
+
|
358
|
+
bitMapTable = GetBitMapTable(theEnv);
|
359
|
+
count = numberOfEntries = 0;
|
360
|
+
|
361
|
+
for (i = 0; i < BITMAP_HASH_SIZE; i++)
|
362
|
+
{
|
363
|
+
for (hashPtr = bitMapTable[i];
|
364
|
+
hashPtr != NULL;
|
365
|
+
hashPtr = hashPtr->next)
|
366
|
+
{
|
367
|
+
numberOfEntries += (hashPtr->size / sizeof(unsigned long));
|
368
|
+
if ((hashPtr->size % sizeof(unsigned long)) != 0)
|
369
|
+
{ numberOfEntries++; }
|
370
|
+
}
|
371
|
+
}
|
372
|
+
|
373
|
+
if (numberOfEntries == 0) return version;
|
374
|
+
|
375
|
+
for (i = 1; i <= (numberOfEntries / ConstructCompilerData(theEnv)->MaxIndices) + 1 ; i++)
|
376
|
+
{ fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern unsigned long L%d_%d[];\n",ConstructCompilerData(theEnv)->ImageID,i); }
|
377
|
+
|
378
|
+
/*==================*/
|
379
|
+
/* Create the file. */
|
380
|
+
/*==================*/
|
381
|
+
|
382
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,false)) == NULL) return version;
|
383
|
+
|
384
|
+
/*===================*/
|
385
|
+
/* List the entries. */
|
386
|
+
/*===================*/
|
387
|
+
|
388
|
+
j = 0;
|
389
|
+
|
390
|
+
for (i = 0; i < BITMAP_HASH_SIZE; i++)
|
391
|
+
{
|
392
|
+
for (hashPtr = bitMapTable[i];
|
393
|
+
hashPtr != NULL;
|
394
|
+
hashPtr = hashPtr->next)
|
395
|
+
{
|
396
|
+
if (newHeader)
|
397
|
+
{
|
398
|
+
fprintf(fp,"unsigned long L%d_%d[] = {\n",ConstructCompilerData(theEnv)->ImageID,arrayVersion);
|
399
|
+
newHeader = false;
|
400
|
+
}
|
401
|
+
|
402
|
+
longsReqd = (hashPtr->size / sizeof(unsigned long));
|
403
|
+
if ((hashPtr->size % sizeof(unsigned long)) != 0)
|
404
|
+
longsReqd++;
|
405
|
+
|
406
|
+
for (k = 0 ; k < longsReqd ; k++)
|
407
|
+
{
|
408
|
+
if (k > 0)
|
409
|
+
fprintf(fp,",");
|
410
|
+
tmpLong = 0L;
|
411
|
+
for (l = 0 ;
|
412
|
+
((l < sizeof(unsigned long)) &&
|
413
|
+
(((k * sizeof(unsigned long)) + l) < (size_t) hashPtr->size)) ;
|
414
|
+
l++)
|
415
|
+
((char *) &tmpLong)[l] = hashPtr->contents[(k * sizeof(unsigned long)) + l];
|
416
|
+
fprintf(fp,"0x%lxL",tmpLong);
|
417
|
+
}
|
418
|
+
|
419
|
+
count += longsReqd;
|
420
|
+
j += longsReqd;
|
421
|
+
|
422
|
+
if ((count == numberOfEntries) || (j >= ConstructCompilerData(theEnv)->MaxIndices))
|
423
|
+
{
|
424
|
+
fprintf(fp,"};\n");
|
425
|
+
GenClose(theEnv,fp);
|
426
|
+
j = 0;
|
427
|
+
arrayVersion++;
|
428
|
+
version++;
|
429
|
+
if (count < numberOfEntries)
|
430
|
+
{
|
431
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,false)) == NULL)
|
432
|
+
{ return 0; }
|
433
|
+
newHeader = true;
|
434
|
+
}
|
435
|
+
}
|
436
|
+
else
|
437
|
+
{ fprintf(fp,",\n"); }
|
438
|
+
}
|
439
|
+
}
|
440
|
+
|
441
|
+
return version;
|
442
|
+
}
|
443
|
+
|
444
|
+
/****************************************************/
|
445
|
+
/* FloatHashNodesToCode: Produces the code for the */
|
446
|
+
/* float hash table entries for a run-time module */
|
447
|
+
/* created using the constructs-to-c function. */
|
448
|
+
/****************************************************/
|
449
|
+
static unsigned int FloatHashNodesToCode(
|
450
|
+
Environment *theEnv,
|
451
|
+
const char *fileName,
|
452
|
+
const char *pathName,
|
453
|
+
char *fileNameBuffer,
|
454
|
+
unsigned int version)
|
455
|
+
{
|
456
|
+
unsigned int i, j;
|
457
|
+
CLIPSFloat *hashPtr;
|
458
|
+
unsigned int count;
|
459
|
+
unsigned int numberOfEntries;
|
460
|
+
CLIPSFloat **floatTable;
|
461
|
+
bool newHeader = true;
|
462
|
+
FILE *fp;
|
463
|
+
unsigned int arrayVersion = 1;
|
464
|
+
|
465
|
+
/*====================================*/
|
466
|
+
/* Count the total number of entries. */
|
467
|
+
/*====================================*/
|
468
|
+
|
469
|
+
floatTable = GetFloatTable(theEnv);
|
470
|
+
count = numberOfEntries = 0;
|
471
|
+
|
472
|
+
for (i = 0; i < FLOAT_HASH_SIZE; i++)
|
473
|
+
{
|
474
|
+
for (hashPtr = floatTable[i];
|
475
|
+
hashPtr != NULL;
|
476
|
+
hashPtr = hashPtr->next)
|
477
|
+
{ numberOfEntries++; }
|
478
|
+
}
|
479
|
+
|
480
|
+
if (numberOfEntries == 0) return version;
|
481
|
+
|
482
|
+
for (i = 1; i <= (numberOfEntries / ConstructCompilerData(theEnv)->MaxIndices) + 1 ; i++)
|
483
|
+
{ fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern CLIPSFloat F%d_%d[];\n",ConstructCompilerData(theEnv)->ImageID,i); }
|
484
|
+
|
485
|
+
/*==================*/
|
486
|
+
/* Create the file. */
|
487
|
+
/*==================*/
|
488
|
+
|
489
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,false)) == NULL) return version;
|
490
|
+
|
491
|
+
/*===================*/
|
492
|
+
/* List the entries. */
|
493
|
+
/*===================*/
|
494
|
+
|
495
|
+
j = 0;
|
496
|
+
|
497
|
+
for (i = 0; i < FLOAT_HASH_SIZE; i++)
|
498
|
+
{
|
499
|
+
for (hashPtr = floatTable[i];
|
500
|
+
hashPtr != NULL;
|
501
|
+
hashPtr = hashPtr->next)
|
502
|
+
{
|
503
|
+
if (newHeader)
|
504
|
+
{
|
505
|
+
fprintf(fp,"CLIPSFloat F%d_%d[] = {\n",ConstructCompilerData(theEnv)->ImageID,arrayVersion);
|
506
|
+
newHeader = false;
|
507
|
+
}
|
508
|
+
|
509
|
+
fprintf(fp,"{{FLOAT_TYPE},");
|
510
|
+
|
511
|
+
if (hashPtr->next == NULL)
|
512
|
+
{ fprintf(fp,"NULL,"); }
|
513
|
+
else
|
514
|
+
{
|
515
|
+
if ((j + 1) >= ConstructCompilerData(theEnv)->MaxIndices)
|
516
|
+
{ fprintf(fp,"&F%d_%d[%d],",ConstructCompilerData(theEnv)->ImageID,arrayVersion + 1,0); }
|
517
|
+
else
|
518
|
+
{ fprintf(fp,"&F%d_%d[%d],",ConstructCompilerData(theEnv)->ImageID,arrayVersion,j + 1); }
|
519
|
+
}
|
520
|
+
|
521
|
+
fprintf(fp,"%ld,1,0,0,%d,",hashPtr->count + 1,i);
|
522
|
+
fprintf(fp,"%s",FloatToString(theEnv,hashPtr->contents));
|
523
|
+
|
524
|
+
count++;
|
525
|
+
j++;
|
526
|
+
|
527
|
+
if ((count == numberOfEntries) || (j >= ConstructCompilerData(theEnv)->MaxIndices))
|
528
|
+
{
|
529
|
+
fprintf(fp,"}};\n");
|
530
|
+
GenClose(theEnv,fp);
|
531
|
+
j = 0;
|
532
|
+
version++;
|
533
|
+
arrayVersion++;
|
534
|
+
if (count < numberOfEntries)
|
535
|
+
{
|
536
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,false)) == NULL)
|
537
|
+
{ return 0; }
|
538
|
+
newHeader = true;
|
539
|
+
}
|
540
|
+
}
|
541
|
+
else
|
542
|
+
{ fprintf(fp,"},\n"); }
|
543
|
+
}
|
544
|
+
}
|
545
|
+
|
546
|
+
return version;
|
547
|
+
}
|
548
|
+
|
549
|
+
/******************************************************/
|
550
|
+
/* IntegerHashNodesToCode: Produces the code for the */
|
551
|
+
/* integer hash table entries for a run-time module */
|
552
|
+
/* created using the constructs-to-c function. */
|
553
|
+
/******************************************************/
|
554
|
+
static unsigned int IntegerHashNodesToCode(
|
555
|
+
Environment *theEnv,
|
556
|
+
const char *fileName,
|
557
|
+
const char *pathName,
|
558
|
+
char *fileNameBuffer,
|
559
|
+
unsigned int version)
|
560
|
+
{
|
561
|
+
unsigned int i, j;
|
562
|
+
CLIPSInteger *hashPtr;
|
563
|
+
unsigned int count;
|
564
|
+
unsigned int numberOfEntries;
|
565
|
+
CLIPSInteger **integerTable;
|
566
|
+
bool newHeader = true;
|
567
|
+
FILE *fp;
|
568
|
+
unsigned int arrayVersion = 1;
|
569
|
+
|
570
|
+
/*====================================*/
|
571
|
+
/* Count the total number of entries. */
|
572
|
+
/*====================================*/
|
573
|
+
|
574
|
+
integerTable = GetIntegerTable(theEnv);
|
575
|
+
count = numberOfEntries = 0;
|
576
|
+
|
577
|
+
for (i = 0; i < INTEGER_HASH_SIZE; i++)
|
578
|
+
{
|
579
|
+
for (hashPtr = integerTable[i];
|
580
|
+
hashPtr != NULL;
|
581
|
+
hashPtr = hashPtr->next)
|
582
|
+
{ numberOfEntries++; }
|
583
|
+
}
|
584
|
+
|
585
|
+
if (numberOfEntries == 0) return(version);
|
586
|
+
|
587
|
+
for (i = 1; i <= (numberOfEntries / ConstructCompilerData(theEnv)->MaxIndices) + 1 ; i++)
|
588
|
+
{ fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern CLIPSInteger I%d_%d[];\n",ConstructCompilerData(theEnv)->ImageID,i); }
|
589
|
+
|
590
|
+
/*==================*/
|
591
|
+
/* Create the file. */
|
592
|
+
/*==================*/
|
593
|
+
|
594
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,false)) == NULL) return version;
|
595
|
+
|
596
|
+
/*===================*/
|
597
|
+
/* List the entries. */
|
598
|
+
/*===================*/
|
599
|
+
|
600
|
+
j = 0;
|
601
|
+
|
602
|
+
for (i = 0; i < INTEGER_HASH_SIZE; i++)
|
603
|
+
{
|
604
|
+
for (hashPtr = integerTable[i];
|
605
|
+
hashPtr != NULL;
|
606
|
+
hashPtr = hashPtr->next)
|
607
|
+
{
|
608
|
+
if (newHeader)
|
609
|
+
{
|
610
|
+
fprintf(fp,"CLIPSInteger I%d_%d[] = {\n",ConstructCompilerData(theEnv)->ImageID,arrayVersion);
|
611
|
+
newHeader = false;
|
612
|
+
}
|
613
|
+
|
614
|
+
fprintf(fp,"{{INTEGER_TYPE},");
|
615
|
+
|
616
|
+
if (hashPtr->next == NULL)
|
617
|
+
{ fprintf(fp,"NULL,"); }
|
618
|
+
else
|
619
|
+
{
|
620
|
+
if ((j + 1) >= ConstructCompilerData(theEnv)->MaxIndices)
|
621
|
+
{ fprintf(fp,"&I%d_%d[%d],",ConstructCompilerData(theEnv)->ImageID,arrayVersion + 1,0); }
|
622
|
+
else
|
623
|
+
{ fprintf(fp,"&I%d_%d[%d],",ConstructCompilerData(theEnv)->ImageID,arrayVersion,j + 1); }
|
624
|
+
}
|
625
|
+
|
626
|
+
fprintf(fp,"%ld,1,0,0,%d,",hashPtr->count + 1,i);
|
627
|
+
fprintf(fp,"%lldLL",hashPtr->contents);
|
628
|
+
|
629
|
+
count++;
|
630
|
+
j++;
|
631
|
+
|
632
|
+
if ((count == numberOfEntries) || (j >= ConstructCompilerData(theEnv)->MaxIndices))
|
633
|
+
{
|
634
|
+
fprintf(fp,"}};\n");
|
635
|
+
GenClose(theEnv,fp);
|
636
|
+
j = 0;
|
637
|
+
version++;
|
638
|
+
arrayVersion++;
|
639
|
+
if (count < numberOfEntries)
|
640
|
+
{
|
641
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,false)) == NULL)
|
642
|
+
{ return 0; }
|
643
|
+
newHeader = true;
|
644
|
+
}
|
645
|
+
}
|
646
|
+
else
|
647
|
+
{ fprintf(fp,"},\n"); }
|
648
|
+
}
|
649
|
+
}
|
650
|
+
|
651
|
+
return version;
|
652
|
+
}
|
653
|
+
|
654
|
+
/****************************************************************/
|
655
|
+
/* HashTablesToCode: Produces the code for the symbol, integer, */
|
656
|
+
/* float, and bitmap hash tables for a run-time module */
|
657
|
+
/* created using the constructs-to-c function. */
|
658
|
+
/****************************************************************/
|
659
|
+
static int HashTablesToCode(
|
660
|
+
Environment *theEnv,
|
661
|
+
const char *fileName,
|
662
|
+
const char *pathName,
|
663
|
+
char *fileNameBuffer)
|
664
|
+
{
|
665
|
+
unsigned long i;
|
666
|
+
FILE *fp;
|
667
|
+
CLIPSLexeme **symbolTable;
|
668
|
+
CLIPSFloat **floatTable;
|
669
|
+
CLIPSInteger **integerTable;
|
670
|
+
CLIPSBitMap **bitMapTable;
|
671
|
+
|
672
|
+
/*======================================*/
|
673
|
+
/* Write the code for the symbol table. */
|
674
|
+
/*======================================*/
|
675
|
+
|
676
|
+
symbolTable = GetSymbolTable(theEnv);
|
677
|
+
|
678
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,1,false)) == NULL)
|
679
|
+
{ return 0; }
|
680
|
+
|
681
|
+
fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern CLIPSLexeme *sht%d[];\n",ConstructCompilerData(theEnv)->ImageID);
|
682
|
+
fprintf(fp,"CLIPSLexeme *sht%d[%ld] = {\n",ConstructCompilerData(theEnv)->ImageID,SYMBOL_HASH_SIZE);
|
683
|
+
|
684
|
+
for (i = 0; i < SYMBOL_HASH_SIZE; i++)
|
685
|
+
{
|
686
|
+
PrintSymbolReference(theEnv,fp,symbolTable[i]);
|
687
|
+
|
688
|
+
if (i + 1 != SYMBOL_HASH_SIZE) fprintf(fp,",\n");
|
689
|
+
}
|
690
|
+
|
691
|
+
fprintf(fp,"};\n");
|
692
|
+
|
693
|
+
GenClose(theEnv,fp);
|
694
|
+
|
695
|
+
/*=====================================*/
|
696
|
+
/* Write the code for the float table. */
|
697
|
+
/*=====================================*/
|
698
|
+
|
699
|
+
floatTable = GetFloatTable(theEnv);
|
700
|
+
|
701
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,2,false)) == NULL)
|
702
|
+
{ return 0; }
|
703
|
+
|
704
|
+
fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern CLIPSFloat *fht%d[];\n",ConstructCompilerData(theEnv)->ImageID);
|
705
|
+
fprintf(fp,"CLIPSFloat *fht%d[%d] = {\n",ConstructCompilerData(theEnv)->ImageID,FLOAT_HASH_SIZE);
|
706
|
+
|
707
|
+
for (i = 0; i < FLOAT_HASH_SIZE; i++)
|
708
|
+
{
|
709
|
+
if (floatTable[i] == NULL) { fprintf(fp,"NULL"); }
|
710
|
+
else PrintFloatReference(theEnv,fp,floatTable[i]);
|
711
|
+
|
712
|
+
if (i + 1 != FLOAT_HASH_SIZE) fprintf(fp,",\n");
|
713
|
+
}
|
714
|
+
|
715
|
+
fprintf(fp,"};\n");
|
716
|
+
|
717
|
+
GenClose(theEnv,fp);
|
718
|
+
|
719
|
+
/*=======================================*/
|
720
|
+
/* Write the code for the integer table. */
|
721
|
+
/*=======================================*/
|
722
|
+
|
723
|
+
integerTable = GetIntegerTable(theEnv);
|
724
|
+
|
725
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,3,false)) == NULL)
|
726
|
+
{ return 0; }
|
727
|
+
|
728
|
+
fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern CLIPSInteger *iht%d[];\n",ConstructCompilerData(theEnv)->ImageID);
|
729
|
+
fprintf(fp,"CLIPSInteger *iht%d[%d] = {\n",ConstructCompilerData(theEnv)->ImageID,INTEGER_HASH_SIZE);
|
730
|
+
|
731
|
+
for (i = 0; i < INTEGER_HASH_SIZE; i++)
|
732
|
+
{
|
733
|
+
if (integerTable[i] == NULL) { fprintf(fp,"NULL"); }
|
734
|
+
else PrintIntegerReference(theEnv,fp,integerTable[i]);
|
735
|
+
|
736
|
+
if (i + 1 != INTEGER_HASH_SIZE) fprintf(fp,",\n");
|
737
|
+
}
|
738
|
+
|
739
|
+
fprintf(fp,"};\n");
|
740
|
+
|
741
|
+
GenClose(theEnv,fp);
|
742
|
+
|
743
|
+
/*======================================*/
|
744
|
+
/* Write the code for the bitmap table. */
|
745
|
+
/*======================================*/
|
746
|
+
|
747
|
+
bitMapTable = GetBitMapTable(theEnv);
|
748
|
+
|
749
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,4,false)) == NULL)
|
750
|
+
{ return 0; }
|
751
|
+
|
752
|
+
fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern struct clipsBitMap *bmht%d[];\n",ConstructCompilerData(theEnv)->ImageID);
|
753
|
+
fprintf(fp,"struct clipsBitMap *bmht%d[%d] = {\n",ConstructCompilerData(theEnv)->ImageID,BITMAP_HASH_SIZE);
|
754
|
+
|
755
|
+
for (i = 0; i < BITMAP_HASH_SIZE; i++)
|
756
|
+
{
|
757
|
+
PrintBitMapReference(theEnv,fp,bitMapTable[i]);
|
758
|
+
|
759
|
+
if (i + 1 != BITMAP_HASH_SIZE) fprintf(fp,",\n");
|
760
|
+
}
|
761
|
+
|
762
|
+
fprintf(fp,"};\n");
|
763
|
+
|
764
|
+
GenClose(theEnv,fp);
|
765
|
+
|
766
|
+
return 1;
|
767
|
+
}
|
768
|
+
|
769
|
+
/*****************************************************/
|
770
|
+
/* PrintSymbolReference: Prints the C code reference */
|
771
|
+
/* address to the specified symbol (also used for */
|
772
|
+
/* strings and instance names). */
|
773
|
+
/*****************************************************/
|
774
|
+
void PrintSymbolReference(
|
775
|
+
Environment *theEnv,
|
776
|
+
FILE *theFile,
|
777
|
+
CLIPSLexeme *theSymbol)
|
778
|
+
{
|
779
|
+
if (theSymbol == NULL) fprintf(theFile,"NULL");
|
780
|
+
else fprintf(theFile,"&S%u_%u[%u]",
|
781
|
+
ConstructCompilerData(theEnv)->ImageID,
|
782
|
+
(theSymbol->bucket / ConstructCompilerData(theEnv)->MaxIndices) + 1,
|
783
|
+
theSymbol->bucket % ConstructCompilerData(theEnv)->MaxIndices);
|
784
|
+
}
|
785
|
+
|
786
|
+
/****************************************************/
|
787
|
+
/* PrintFloatReference: Prints the C code reference */
|
788
|
+
/* address to the specified float. */
|
789
|
+
/****************************************************/
|
790
|
+
void PrintFloatReference(
|
791
|
+
Environment *theEnv,
|
792
|
+
FILE *theFile,
|
793
|
+
CLIPSFloat *theFloat)
|
794
|
+
{
|
795
|
+
fprintf(theFile,"&F%u_%u[%u]",
|
796
|
+
ConstructCompilerData(theEnv)->ImageID,
|
797
|
+
(theFloat->bucket / ConstructCompilerData(theEnv)->MaxIndices) + 1,
|
798
|
+
theFloat->bucket % ConstructCompilerData(theEnv)->MaxIndices);
|
799
|
+
}
|
800
|
+
|
801
|
+
/******************************************************/
|
802
|
+
/* PrintIntegerReference: Prints the C code reference */
|
803
|
+
/* address to the specified integer. */
|
804
|
+
/******************************************************/
|
805
|
+
void PrintIntegerReference(
|
806
|
+
Environment *theEnv,
|
807
|
+
FILE *theFile,
|
808
|
+
CLIPSInteger *theInteger)
|
809
|
+
{
|
810
|
+
fprintf(theFile,"&I%u_%u[%u]",
|
811
|
+
ConstructCompilerData(theEnv)->ImageID,
|
812
|
+
(theInteger->bucket / ConstructCompilerData(theEnv)->MaxIndices) + 1,
|
813
|
+
theInteger->bucket % ConstructCompilerData(theEnv)->MaxIndices);
|
814
|
+
}
|
815
|
+
|
816
|
+
/*****************************************************/
|
817
|
+
/* PrintBitMapReference: Prints the C code reference */
|
818
|
+
/* address to the specified bit map. */
|
819
|
+
/*****************************************************/
|
820
|
+
void PrintBitMapReference(
|
821
|
+
Environment *theEnv,
|
822
|
+
FILE *theFile,
|
823
|
+
CLIPSBitMap *theBitMap)
|
824
|
+
{
|
825
|
+
if (theBitMap == NULL) fprintf(theFile,"NULL");
|
826
|
+
else fprintf(theFile,"&B%u_%u[%u]",
|
827
|
+
ConstructCompilerData(theEnv)->ImageID,
|
828
|
+
(theBitMap->bucket / ConstructCompilerData(theEnv)->MaxIndices) + 1,
|
829
|
+
theBitMap->bucket % ConstructCompilerData(theEnv)->MaxIndices);
|
830
|
+
}
|
831
|
+
|
832
|
+
/*********************************************************/
|
833
|
+
/* PrintCString: Prints KB strings in the appropriate */
|
834
|
+
/* format for C (the " and \ characters are preceeded */
|
835
|
+
/* by a \ and carriage returns are replaced with \n). */
|
836
|
+
/*********************************************************/
|
837
|
+
static void PrintCString(
|
838
|
+
FILE *theFile,
|
839
|
+
const char *str)
|
840
|
+
{
|
841
|
+
unsigned i;
|
842
|
+
size_t slen;
|
843
|
+
|
844
|
+
/*============================================*/
|
845
|
+
/* Print the string's opening quotation mark. */
|
846
|
+
/*============================================*/
|
847
|
+
|
848
|
+
fprintf(theFile,"\"");
|
849
|
+
|
850
|
+
/*===============================================*/
|
851
|
+
/* Convert and write each character to the file. */
|
852
|
+
/*===============================================*/
|
853
|
+
|
854
|
+
slen = strlen(str);
|
855
|
+
for (i = 0 ; i < slen ; i++)
|
856
|
+
{
|
857
|
+
/*====================================*/
|
858
|
+
/* Preceed " and \ with the \ escape. */
|
859
|
+
/*====================================*/
|
860
|
+
|
861
|
+
if ((str[i] == '"') || (str[i] == '\\'))
|
862
|
+
{
|
863
|
+
fputc('\\',theFile);
|
864
|
+
fputc(str[i],theFile);
|
865
|
+
}
|
866
|
+
|
867
|
+
/*====================================*/
|
868
|
+
/* Replace a carriage return with \n. */
|
869
|
+
/*====================================*/
|
870
|
+
|
871
|
+
else if (str[i] == '\n')
|
872
|
+
{
|
873
|
+
fputc('\\',theFile);
|
874
|
+
fputc('n',theFile);
|
875
|
+
}
|
876
|
+
|
877
|
+
/*===============================*/
|
878
|
+
/* All other characters can be */
|
879
|
+
/* printed without modification. */
|
880
|
+
/*===============================*/
|
881
|
+
|
882
|
+
else
|
883
|
+
{ fputc(str[i],theFile); }
|
884
|
+
}
|
885
|
+
|
886
|
+
/*============================================*/
|
887
|
+
/* Print the string's closing quotation mark. */
|
888
|
+
/*============================================*/
|
889
|
+
|
890
|
+
fprintf(theFile,"\"");
|
891
|
+
}
|
892
|
+
|
893
|
+
#endif /* CONSTRUCT_COMPILER && (! RUN_TIME) */
|