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,734 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.40 02/03/18 */
|
5
|
+
/* */
|
6
|
+
/* OBJECT PATTERN NETWORK CONSTRUCTS-TO-C MODULE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: Saves object pattern network for constructs-to-c */
|
11
|
+
/* */
|
12
|
+
/* Principal Programmer(s): */
|
13
|
+
/* Brian L. Dantes */
|
14
|
+
/* */
|
15
|
+
/* Contributing Programmer(s): */
|
16
|
+
/* */
|
17
|
+
/* Revision History: */
|
18
|
+
/* */
|
19
|
+
/* 6.24: Converted INSTANCE_PATTERN_MATCHING to */
|
20
|
+
/* DEFRULE_CONSTRUCT. */
|
21
|
+
/* */
|
22
|
+
/* Added environment parameter to GenClose. */
|
23
|
+
/* */
|
24
|
+
/* 6.30: Added support for path name argument to */
|
25
|
+
/* constructs-to-c. */
|
26
|
+
/* */
|
27
|
+
/* Added support for hashed comparisons to */
|
28
|
+
/* constants. */
|
29
|
+
/* */
|
30
|
+
/* Added const qualifiers to remove C++ */
|
31
|
+
/* deprecation warnings. */
|
32
|
+
/* */
|
33
|
+
/* 6.31: Optimization for marking relevant alpha nodes */
|
34
|
+
/* in the object pattern network. */
|
35
|
+
/* */
|
36
|
+
/* 6.40: Pragma once and other inclusion changes. */
|
37
|
+
/* */
|
38
|
+
/* Added support for booleans with <stdbool.h>. */
|
39
|
+
/* */
|
40
|
+
/* Removed use of void pointers for specific */
|
41
|
+
/* data structures. */
|
42
|
+
/* */
|
43
|
+
/*************************************************************/
|
44
|
+
/* =========================================
|
45
|
+
*****************************************
|
46
|
+
EXTERNAL DEFINITIONS
|
47
|
+
=========================================
|
48
|
+
***************************************** */
|
49
|
+
#include "setup.h"
|
50
|
+
|
51
|
+
#if DEFRULE_CONSTRUCT && OBJECT_SYSTEM && (! RUN_TIME) && CONSTRUCT_COMPILER
|
52
|
+
|
53
|
+
#include <stdio.h>
|
54
|
+
|
55
|
+
#include "conscomp.h"
|
56
|
+
#include "classcom.h"
|
57
|
+
#include "envrnmnt.h"
|
58
|
+
#include "objrtfnx.h"
|
59
|
+
#include "objrtmch.h"
|
60
|
+
#include "pattern.h"
|
61
|
+
#include "sysdep.h"
|
62
|
+
|
63
|
+
#include "objrtcmp.h"
|
64
|
+
|
65
|
+
/* =========================================
|
66
|
+
*****************************************
|
67
|
+
MACROS AND TYPES
|
68
|
+
=========================================
|
69
|
+
***************************************** */
|
70
|
+
#define ObjectPNPrefix() ArbitraryPrefix(ObjectReteData(theEnv)->ObjectPatternCodeItem,0)
|
71
|
+
#define ObjectANPrefix() ArbitraryPrefix(ObjectReteData(theEnv)->ObjectPatternCodeItem,1)
|
72
|
+
#define ObjectALPrefix() ArbitraryPrefix(ObjectReteData(theEnv)->ObjectPatternCodeItem,2)
|
73
|
+
|
74
|
+
/***************************************/
|
75
|
+
/* LOCAL INTERNAL FUNCTION DEFINITIONS */
|
76
|
+
/***************************************/
|
77
|
+
|
78
|
+
static void BeforeObjectPatternsToCode(Environment *);
|
79
|
+
static OBJECT_PATTERN_NODE *GetNextObjectPatternNode(OBJECT_PATTERN_NODE *);
|
80
|
+
static void InitObjectPatternsCode(Environment *,FILE *,unsigned int,unsigned int);
|
81
|
+
static bool ObjectPatternsToCode(Environment *,const char *,const char *,char *,
|
82
|
+
unsigned int,FILE *,unsigned int,unsigned int);
|
83
|
+
static void IntermediatePatternNodeReference(Environment *,OBJECT_PATTERN_NODE *,FILE *,
|
84
|
+
unsigned int,unsigned int);
|
85
|
+
static unsigned IntermediatePatternNodesToCode(Environment *,const char *,const char *,
|
86
|
+
char *,unsigned int,FILE *,unsigned int,
|
87
|
+
unsigned int,unsigned int);
|
88
|
+
static unsigned AlphaPatternNodesToCode(Environment *,const char *,const char *,char *,
|
89
|
+
unsigned int,FILE *,unsigned int,unsigned int,unsigned int);
|
90
|
+
static unsigned ClassAlphaLinksToCode(Environment *,const char *,const char *,char *,
|
91
|
+
unsigned int,FILE *,unsigned int,unsigned int,unsigned int);
|
92
|
+
static CLASS_ALPHA_LINK *GetNextAlphaLink(Environment *,struct defmodule **,Defclass **theClass,CLASS_ALPHA_LINK *);
|
93
|
+
|
94
|
+
/* =========================================
|
95
|
+
*****************************************
|
96
|
+
EXTERNALLY VISIBLE FUNCTIONS
|
97
|
+
=========================================
|
98
|
+
***************************************** */
|
99
|
+
|
100
|
+
/***************************************************
|
101
|
+
NAME : ObjectPatternsCompilerSetup
|
102
|
+
DESCRIPTION : Sets up interface for object
|
103
|
+
patterns to construct compiler
|
104
|
+
INPUTS : None
|
105
|
+
RETURNS : Nothing useful
|
106
|
+
SIDE EFFECTS : Code generator item added
|
107
|
+
NOTES : None
|
108
|
+
***************************************************/
|
109
|
+
void ObjectPatternsCompilerSetup(
|
110
|
+
Environment *theEnv)
|
111
|
+
{
|
112
|
+
ObjectReteData(theEnv)->ObjectPatternCodeItem =
|
113
|
+
AddCodeGeneratorItem(theEnv,"object-patterns",0,BeforeObjectPatternsToCode,
|
114
|
+
InitObjectPatternsCode,ObjectPatternsToCode,3);
|
115
|
+
}
|
116
|
+
|
117
|
+
/***************************************************
|
118
|
+
NAME : ObjectPatternNodeReference
|
119
|
+
DESCRIPTION : Prints out a reference to an
|
120
|
+
object pattern alpha memory for
|
121
|
+
the join network interface to the
|
122
|
+
construct compiler
|
123
|
+
INPUTS : 1) A pointer to the object pattern
|
124
|
+
alpha memory
|
125
|
+
2) A pointer to the output file
|
126
|
+
3) The id of constructs-to-c image
|
127
|
+
4) The maximum number of indices
|
128
|
+
allowed in any single array
|
129
|
+
in the image
|
130
|
+
RETURNS : Nothing useful
|
131
|
+
SIDE EFFECTS : Reference to object pattern alpha
|
132
|
+
memory printed
|
133
|
+
NOTES : None
|
134
|
+
***************************************************/
|
135
|
+
void ObjectPatternNodeReference(
|
136
|
+
Environment *theEnv,
|
137
|
+
void *theVPattern,
|
138
|
+
FILE *theFile,
|
139
|
+
unsigned int imageID,
|
140
|
+
unsigned int maxIndices)
|
141
|
+
{
|
142
|
+
OBJECT_ALPHA_NODE *thePattern;
|
143
|
+
|
144
|
+
if (theVPattern == NULL)
|
145
|
+
fprintf(theFile,"NULL");
|
146
|
+
else
|
147
|
+
{
|
148
|
+
thePattern = (OBJECT_ALPHA_NODE *) theVPattern;
|
149
|
+
fprintf(theFile,"&%s%u_%lu[%lu]",
|
150
|
+
ObjectANPrefix(),imageID,
|
151
|
+
((thePattern->bsaveID) / maxIndices) + 1,
|
152
|
+
(thePattern->bsaveID) % maxIndices);
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
/***************************************************
|
157
|
+
NAME : ClassAlphaLinkReference
|
158
|
+
DESCRIPTION : Prints out a reference to a
|
159
|
+
class alpha link for
|
160
|
+
the pattern network interface to the
|
161
|
+
construct compiler
|
162
|
+
INPUTS : 1) A pointer to a class alpha link
|
163
|
+
2) A pointer to the output file
|
164
|
+
3) The id of constructs-to-c image
|
165
|
+
4) The maximum number of indices
|
166
|
+
allowed in any single array
|
167
|
+
in the image
|
168
|
+
RETURNS : Nothing useful
|
169
|
+
SIDE EFFECTS : Reference to the class alpha link printed
|
170
|
+
NOTES : None
|
171
|
+
***************************************************/
|
172
|
+
void ClassAlphaLinkReference(
|
173
|
+
Environment *theEnv,
|
174
|
+
void *theVLink,
|
175
|
+
FILE *theFile,
|
176
|
+
unsigned int imageID,
|
177
|
+
unsigned int maxIndices)
|
178
|
+
{
|
179
|
+
CLASS_ALPHA_LINK *theLink;
|
180
|
+
|
181
|
+
if (theVLink == NULL)
|
182
|
+
fprintf(theFile,"NULL");
|
183
|
+
else
|
184
|
+
{
|
185
|
+
theLink = (CLASS_ALPHA_LINK *) theVLink;
|
186
|
+
fprintf(theFile,"&%s%u_%lu[%lu]",
|
187
|
+
ObjectALPrefix(),imageID,
|
188
|
+
((theLink->bsaveID) / maxIndices) + 1,
|
189
|
+
(theLink->bsaveID) % maxIndices);
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
/* =========================================
|
194
|
+
*****************************************
|
195
|
+
INTERNALLY VISIBLE FUNCTIONS
|
196
|
+
=========================================
|
197
|
+
***************************************** */
|
198
|
+
|
199
|
+
/*****************************************************
|
200
|
+
NAME : BeforeObjectPatternsToCode
|
201
|
+
DESCRIPTION : Marks all object pattern intermediate
|
202
|
+
and alpha memory nodes with a
|
203
|
+
unique integer id prior to the
|
204
|
+
constructs-to-c execution
|
205
|
+
INPUTS : None
|
206
|
+
RETURNS : Nothing useful
|
207
|
+
SIDE EFFECTS : bsaveIDs of nodes set
|
208
|
+
NOTES : None
|
209
|
+
*****************************************************/
|
210
|
+
static void BeforeObjectPatternsToCode(
|
211
|
+
Environment *theEnv)
|
212
|
+
{
|
213
|
+
unsigned long whichPattern;
|
214
|
+
OBJECT_PATTERN_NODE *intermediateNode;
|
215
|
+
OBJECT_ALPHA_NODE *alphaNode;
|
216
|
+
Defmodule *theModule;
|
217
|
+
Defclass *theDefclass;
|
218
|
+
CLASS_ALPHA_LINK *theLink;
|
219
|
+
|
220
|
+
whichPattern = 0L;
|
221
|
+
intermediateNode = ObjectNetworkPointer(theEnv);
|
222
|
+
while (intermediateNode != NULL)
|
223
|
+
{
|
224
|
+
intermediateNode->bsaveID = whichPattern++;
|
225
|
+
intermediateNode = GetNextObjectPatternNode(intermediateNode);
|
226
|
+
}
|
227
|
+
|
228
|
+
whichPattern = 0L;
|
229
|
+
alphaNode = ObjectNetworkTerminalPointer(theEnv);
|
230
|
+
while (alphaNode != NULL)
|
231
|
+
{
|
232
|
+
alphaNode->bsaveID = whichPattern++;
|
233
|
+
alphaNode = alphaNode->nxtTerminal;
|
234
|
+
}
|
235
|
+
|
236
|
+
whichPattern = 0L;
|
237
|
+
for (theModule = GetNextDefmodule(theEnv,NULL);
|
238
|
+
theModule != NULL;
|
239
|
+
theModule = GetNextDefmodule(theEnv,theModule))
|
240
|
+
{
|
241
|
+
SetCurrentModule(theEnv,theModule);
|
242
|
+
for (theDefclass = GetNextDefclass(theEnv,NULL) ;
|
243
|
+
theDefclass != NULL ;
|
244
|
+
theDefclass = GetNextDefclass(theEnv,theDefclass))
|
245
|
+
{
|
246
|
+
for (theLink = theDefclass->relevant_terminal_alpha_nodes;
|
247
|
+
theLink != NULL;
|
248
|
+
theLink = theLink->next)
|
249
|
+
{ theLink->bsaveID = whichPattern++; }
|
250
|
+
}
|
251
|
+
}
|
252
|
+
}
|
253
|
+
|
254
|
+
/***************************************************
|
255
|
+
NAME : GetNextObjectPatternNode
|
256
|
+
DESCRIPTION : Grabs the next node in a depth
|
257
|
+
first perusal of the object pattern
|
258
|
+
intermediate nodes
|
259
|
+
INPUTS : The previous node
|
260
|
+
RETURNS : The next node (NULL if done)
|
261
|
+
SIDE EFFECTS : None
|
262
|
+
NOTES : Alpha meory nodes are ignored
|
263
|
+
***************************************************/
|
264
|
+
static OBJECT_PATTERN_NODE *GetNextObjectPatternNode(
|
265
|
+
OBJECT_PATTERN_NODE *thePattern)
|
266
|
+
{
|
267
|
+
if (thePattern->nextLevel != NULL)
|
268
|
+
return thePattern->nextLevel;
|
269
|
+
while (thePattern->rightNode == NULL)
|
270
|
+
{
|
271
|
+
thePattern = thePattern->lastLevel;
|
272
|
+
if (thePattern == NULL)
|
273
|
+
return NULL;
|
274
|
+
}
|
275
|
+
return thePattern->rightNode;
|
276
|
+
}
|
277
|
+
|
278
|
+
/***************************************************
|
279
|
+
NAME : InitObjectPatternsCode
|
280
|
+
DESCRIPTION : Prints out run-time initialization
|
281
|
+
code for object patterns
|
282
|
+
INPUTS : 1) A pointer to the output file
|
283
|
+
2) The id of constructs-to-c image
|
284
|
+
3) The maximum number of indices
|
285
|
+
allowed in any single array
|
286
|
+
in the image
|
287
|
+
RETURNS : Nothing useful
|
288
|
+
SIDE EFFECTS : Initialization code written
|
289
|
+
NOTES : None
|
290
|
+
***************************************************/
|
291
|
+
static void InitObjectPatternsCode(
|
292
|
+
Environment *theEnv,
|
293
|
+
FILE *initFP,
|
294
|
+
unsigned int imageID,
|
295
|
+
unsigned int maxIndices)
|
296
|
+
{
|
297
|
+
unsigned long firstIntermediateNode, firstAlphaNode;
|
298
|
+
|
299
|
+
if (ObjectNetworkPointer(theEnv) != NULL)
|
300
|
+
{
|
301
|
+
firstIntermediateNode = ObjectNetworkPointer(theEnv)->bsaveID;
|
302
|
+
firstAlphaNode = ObjectNetworkTerminalPointer(theEnv)->bsaveID;
|
303
|
+
fprintf(initFP," SetObjectNetworkPointer(theEnv,&%s%u_%lu[%lu]);\n",
|
304
|
+
ObjectPNPrefix(),imageID,
|
305
|
+
((firstIntermediateNode / maxIndices) + 1),
|
306
|
+
(firstIntermediateNode % maxIndices));
|
307
|
+
fprintf(initFP," SetObjectNetworkTerminalPointer(theEnv,&%s%u_%lu[%lu]);\n",
|
308
|
+
ObjectANPrefix(),imageID,
|
309
|
+
((firstAlphaNode / maxIndices) + 1),
|
310
|
+
(firstAlphaNode % maxIndices));
|
311
|
+
}
|
312
|
+
else
|
313
|
+
{
|
314
|
+
fprintf(initFP," SetObjectNetworkPointer(theEnv,NULL);\n");
|
315
|
+
fprintf(initFP," SetObjectNetworkTerminalPointer(theEnv,NULL);\n");
|
316
|
+
}
|
317
|
+
}
|
318
|
+
|
319
|
+
/***********************************************************
|
320
|
+
NAME : ObjectPatternsToCode
|
321
|
+
DESCRIPTION : Writes out data structures for run-time
|
322
|
+
creation of object patterns
|
323
|
+
INPUTS : 1) The base image output file name
|
324
|
+
2) The base image file id
|
325
|
+
3) A pointer to the header output file
|
326
|
+
4) The id of constructs-to-c image
|
327
|
+
5) The maximum number of indices
|
328
|
+
allowed in any single array
|
329
|
+
in the image
|
330
|
+
RETURNS : 1 if OK, 0 if could not open a file
|
331
|
+
SIDE EFFECTS : Object patterns code written to files
|
332
|
+
NOTES : None
|
333
|
+
***********************************************************/
|
334
|
+
static bool ObjectPatternsToCode(
|
335
|
+
Environment *theEnv,
|
336
|
+
const char *fileName,
|
337
|
+
const char *pathName,
|
338
|
+
char *fileNameBuffer,
|
339
|
+
unsigned int fileID,
|
340
|
+
FILE *headerFP,
|
341
|
+
unsigned int imageID,
|
342
|
+
unsigned int maxIndices)
|
343
|
+
{
|
344
|
+
unsigned int version;
|
345
|
+
|
346
|
+
version = ClassAlphaLinksToCode(theEnv,fileName,pathName,fileNameBuffer,
|
347
|
+
fileID,headerFP,imageID,maxIndices,1);
|
348
|
+
if (version == 0)
|
349
|
+
return(0);
|
350
|
+
|
351
|
+
version = IntermediatePatternNodesToCode(theEnv,fileName,pathName,fileNameBuffer,
|
352
|
+
fileID,headerFP,imageID,maxIndices,version);
|
353
|
+
if (version == 0)
|
354
|
+
return false;
|
355
|
+
if (! AlphaPatternNodesToCode(theEnv,fileName,pathName,fileNameBuffer,
|
356
|
+
fileID,headerFP,imageID,maxIndices,version))
|
357
|
+
return false;
|
358
|
+
return true;
|
359
|
+
}
|
360
|
+
|
361
|
+
/***************************************************
|
362
|
+
NAME : IntermediatePatternNodeReference
|
363
|
+
DESCRIPTION : Prints out a reference to an
|
364
|
+
object pattern intermediate node
|
365
|
+
INPUTS : 1) A pointer to the object pattern
|
366
|
+
intermediate node
|
367
|
+
2) A pointer to the output file
|
368
|
+
3) The id of constructs-to-c image
|
369
|
+
4) The maximum number of indices
|
370
|
+
allowed in any single array
|
371
|
+
in the image
|
372
|
+
RETURNS : 1 if OK, 0 if could not open a file
|
373
|
+
SIDE EFFECTS : Reference to object pattern alpha
|
374
|
+
memory printed
|
375
|
+
NOTES : None
|
376
|
+
***************************************************/
|
377
|
+
static void IntermediatePatternNodeReference(
|
378
|
+
Environment *theEnv,
|
379
|
+
OBJECT_PATTERN_NODE *thePattern,
|
380
|
+
FILE *theFile,
|
381
|
+
unsigned int imageID,
|
382
|
+
unsigned int maxIndices)
|
383
|
+
{
|
384
|
+
if (thePattern == NULL)
|
385
|
+
fprintf(theFile,"NULL");
|
386
|
+
else
|
387
|
+
{
|
388
|
+
fprintf(theFile,"&%s%u_%lu[%lu]",
|
389
|
+
ObjectPNPrefix(),imageID,
|
390
|
+
((thePattern->bsaveID) / maxIndices) + 1,
|
391
|
+
thePattern->bsaveID % maxIndices);
|
392
|
+
}
|
393
|
+
}
|
394
|
+
|
395
|
+
/*************************************************************
|
396
|
+
NAME : IntermediatePatternNodesToCode
|
397
|
+
DESCRIPTION : Writes out data structures for run-time
|
398
|
+
creation of object pattern intermediate nodes
|
399
|
+
INPUTS : 1) The base image output file name
|
400
|
+
2) The base image file id
|
401
|
+
3) A pointer to the header output file
|
402
|
+
4) The id of constructs-to-c image
|
403
|
+
5) The maximum number of indices
|
404
|
+
allowed in any single array
|
405
|
+
in the image
|
406
|
+
RETURNS : Next version file to open, 0 if error
|
407
|
+
SIDE EFFECTS : Object patterns code written to files
|
408
|
+
NOTES : None
|
409
|
+
*************************************************************/
|
410
|
+
static unsigned IntermediatePatternNodesToCode(
|
411
|
+
Environment *theEnv,
|
412
|
+
const char *fileName,
|
413
|
+
const char *pathName,
|
414
|
+
char *fileNameBuffer,
|
415
|
+
unsigned int fileID,
|
416
|
+
FILE *headerFP,
|
417
|
+
unsigned int imageID,
|
418
|
+
unsigned int maxIndices,
|
419
|
+
unsigned int version)
|
420
|
+
{
|
421
|
+
FILE *fp;
|
422
|
+
int arrayVersion;
|
423
|
+
bool newHeader;
|
424
|
+
unsigned int i;
|
425
|
+
OBJECT_PATTERN_NODE *thePattern;
|
426
|
+
|
427
|
+
/* ================
|
428
|
+
Create the file.
|
429
|
+
================ */
|
430
|
+
if (ObjectNetworkPointer(theEnv) == NULL)
|
431
|
+
{ return 1; }
|
432
|
+
|
433
|
+
fprintf(headerFP,"#include \"objrtmch.h\"\n");
|
434
|
+
|
435
|
+
/* =================================
|
436
|
+
Dump the pattern node structures.
|
437
|
+
================================= */
|
438
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,fileID,version,false)) == NULL)
|
439
|
+
{ return 0; }
|
440
|
+
newHeader = true;
|
441
|
+
|
442
|
+
arrayVersion = 1;
|
443
|
+
i = 1;
|
444
|
+
|
445
|
+
thePattern = ObjectNetworkPointer(theEnv);
|
446
|
+
while (thePattern != NULL)
|
447
|
+
{
|
448
|
+
if (newHeader)
|
449
|
+
{
|
450
|
+
fprintf(fp,"OBJECT_PATTERN_NODE %s%u_%u[] = {\n",
|
451
|
+
ObjectPNPrefix(),imageID,arrayVersion);
|
452
|
+
fprintf(headerFP,"extern OBJECT_PATTERN_NODE %s%u_%u[];\n",
|
453
|
+
ObjectPNPrefix(),imageID,arrayVersion);
|
454
|
+
newHeader = false;
|
455
|
+
}
|
456
|
+
fprintf(fp,"{0,%u,%u,%u,%u,%u,0L,%u,",thePattern->multifieldNode,
|
457
|
+
thePattern->endSlot,
|
458
|
+
thePattern->selector,
|
459
|
+
thePattern->whichField,
|
460
|
+
thePattern->leaveFields,
|
461
|
+
thePattern->slotNameID);
|
462
|
+
|
463
|
+
PrintHashedExpressionReference(theEnv,fp,thePattern->networkTest,imageID,maxIndices);
|
464
|
+
fprintf(fp,",");
|
465
|
+
IntermediatePatternNodeReference(theEnv,thePattern->nextLevel,fp,imageID,maxIndices);
|
466
|
+
fprintf(fp,",");
|
467
|
+
IntermediatePatternNodeReference(theEnv,thePattern->lastLevel,fp,imageID,maxIndices);
|
468
|
+
fprintf(fp,",");
|
469
|
+
IntermediatePatternNodeReference(theEnv,thePattern->leftNode,fp,imageID,maxIndices);
|
470
|
+
fprintf(fp,",");
|
471
|
+
IntermediatePatternNodeReference(theEnv,thePattern->rightNode,fp,imageID,maxIndices);
|
472
|
+
fprintf(fp,",");
|
473
|
+
ObjectPatternNodeReference(theEnv,thePattern->alphaNode,fp,imageID,maxIndices);
|
474
|
+
fprintf(fp,",0L}");
|
475
|
+
|
476
|
+
i++;
|
477
|
+
thePattern = GetNextObjectPatternNode(thePattern);
|
478
|
+
|
479
|
+
if ((i > maxIndices) || (thePattern == NULL))
|
480
|
+
{
|
481
|
+
fprintf(fp,"};\n");
|
482
|
+
GenClose(theEnv,fp);
|
483
|
+
i = 1;
|
484
|
+
version++;
|
485
|
+
arrayVersion++;
|
486
|
+
if (thePattern != NULL)
|
487
|
+
{
|
488
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,fileID,version,false)) == NULL)
|
489
|
+
{ return 0; }
|
490
|
+
newHeader = true;
|
491
|
+
}
|
492
|
+
}
|
493
|
+
else if (thePattern != NULL)
|
494
|
+
{ fprintf(fp,",\n"); }
|
495
|
+
}
|
496
|
+
|
497
|
+
return version;
|
498
|
+
}
|
499
|
+
|
500
|
+
/***********************************************************
|
501
|
+
NAME : AlphaPatternNodesToCode
|
502
|
+
DESCRIPTION : Writes out data structures for run-time
|
503
|
+
creation of object pattern alpha memories
|
504
|
+
INPUTS : 1) The base image output file name
|
505
|
+
2) The base image file id
|
506
|
+
3) A pointer to the header output file
|
507
|
+
4) The id of constructs-to-c image
|
508
|
+
5) The maximum number of indices
|
509
|
+
allowed in any single array
|
510
|
+
in the image
|
511
|
+
RETURNS : Next version file to open, 0 if error
|
512
|
+
SIDE EFFECTS : Object patterns code written to files
|
513
|
+
NOTES : None
|
514
|
+
***********************************************************/
|
515
|
+
static unsigned AlphaPatternNodesToCode(
|
516
|
+
Environment *theEnv,
|
517
|
+
const char *fileName,
|
518
|
+
const char *pathName,
|
519
|
+
char *fileNameBuffer,
|
520
|
+
unsigned int fileID,
|
521
|
+
FILE *headerFP,
|
522
|
+
unsigned int imageID,
|
523
|
+
unsigned int maxIndices,
|
524
|
+
unsigned int version)
|
525
|
+
{
|
526
|
+
FILE *fp;
|
527
|
+
unsigned int arrayVersion;
|
528
|
+
bool newHeader;
|
529
|
+
unsigned int i;
|
530
|
+
OBJECT_ALPHA_NODE *thePattern;
|
531
|
+
|
532
|
+
/* ================
|
533
|
+
Create the file.
|
534
|
+
================ */
|
535
|
+
if (ObjectNetworkTerminalPointer(theEnv) == NULL)
|
536
|
+
{ return version; }
|
537
|
+
|
538
|
+
/* =================================
|
539
|
+
Dump the pattern node structures.
|
540
|
+
================================= */
|
541
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,fileID,version,false)) == NULL)
|
542
|
+
{ return 0; }
|
543
|
+
newHeader = true;
|
544
|
+
|
545
|
+
arrayVersion = 1;
|
546
|
+
i = 1;
|
547
|
+
|
548
|
+
thePattern = ObjectNetworkTerminalPointer(theEnv);
|
549
|
+
while (thePattern != NULL)
|
550
|
+
{
|
551
|
+
if (newHeader)
|
552
|
+
{
|
553
|
+
fprintf(fp,"OBJECT_ALPHA_NODE %s%u_%u[] = {\n",
|
554
|
+
ObjectANPrefix(),imageID,arrayVersion);
|
555
|
+
fprintf(headerFP,"extern OBJECT_ALPHA_NODE %s%u_%u[];\n",
|
556
|
+
ObjectANPrefix(),imageID,arrayVersion);
|
557
|
+
newHeader = false;
|
558
|
+
}
|
559
|
+
|
560
|
+
fprintf(fp,"{");
|
561
|
+
|
562
|
+
PatternNodeHeaderToCode(theEnv,fp,&thePattern->header,imageID,maxIndices);
|
563
|
+
|
564
|
+
fprintf(fp,",0L,");
|
565
|
+
PrintBitMapReference(theEnv,fp,thePattern->classbmp);
|
566
|
+
fprintf(fp,",");
|
567
|
+
PrintBitMapReference(theEnv,fp,thePattern->slotbmp);
|
568
|
+
fprintf(fp,",");
|
569
|
+
IntermediatePatternNodeReference(theEnv,thePattern->patternNode,fp,imageID,maxIndices);
|
570
|
+
fprintf(fp,",");
|
571
|
+
ObjectPatternNodeReference(theEnv,thePattern->nxtInGroup,fp,imageID,maxIndices);
|
572
|
+
fprintf(fp,",");
|
573
|
+
ObjectPatternNodeReference(theEnv,thePattern->nxtTerminal,fp,imageID,maxIndices);
|
574
|
+
fprintf(fp,",0L}");
|
575
|
+
|
576
|
+
i++;
|
577
|
+
thePattern = thePattern->nxtTerminal;
|
578
|
+
|
579
|
+
if ((i > maxIndices) || (thePattern == NULL))
|
580
|
+
{
|
581
|
+
fprintf(fp,"};\n");
|
582
|
+
GenClose(theEnv,fp);
|
583
|
+
i = 1;
|
584
|
+
version++;
|
585
|
+
arrayVersion++;
|
586
|
+
if (thePattern != NULL)
|
587
|
+
{
|
588
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,fileID,version,false)) == NULL)
|
589
|
+
{ return 0; }
|
590
|
+
newHeader = true;
|
591
|
+
}
|
592
|
+
}
|
593
|
+
else if (thePattern != NULL)
|
594
|
+
{ fprintf(fp,",\n"); }
|
595
|
+
}
|
596
|
+
|
597
|
+
return version;
|
598
|
+
}
|
599
|
+
|
600
|
+
/***********************************************************
|
601
|
+
NAME : ClassAlphaLinksToCode
|
602
|
+
DESCRIPTION : Writes out data structures for run-time
|
603
|
+
creation of class alpha link
|
604
|
+
INPUTS : 1) The base image output file name
|
605
|
+
2) The base image file id
|
606
|
+
3) A pointer to the header output file
|
607
|
+
4) The id of constructs-to-c image
|
608
|
+
5) The maximum number of indices
|
609
|
+
allowed in any single array
|
610
|
+
in the image
|
611
|
+
RETURNS : Next version file to open, 0 if error
|
612
|
+
SIDE EFFECTS : Class alpha links code written to files
|
613
|
+
NOTES : None
|
614
|
+
***********************************************************/
|
615
|
+
static unsigned ClassAlphaLinksToCode(
|
616
|
+
Environment *theEnv,
|
617
|
+
const char *fileName,
|
618
|
+
const char *pathName,
|
619
|
+
char *fileNameBuffer,
|
620
|
+
unsigned int fileID,
|
621
|
+
FILE *headerFP,
|
622
|
+
unsigned int imageID,
|
623
|
+
unsigned int maxIndices,
|
624
|
+
unsigned int version)
|
625
|
+
{
|
626
|
+
FILE *fp;
|
627
|
+
unsigned int arrayVersion;
|
628
|
+
bool newHeader;
|
629
|
+
unsigned int i;
|
630
|
+
Defmodule *theModule = NULL;
|
631
|
+
Defclass *theDefclass = NULL;
|
632
|
+
CLASS_ALPHA_LINK *theLink = NULL;
|
633
|
+
|
634
|
+
/* =================================
|
635
|
+
Dump the alpha link structures.
|
636
|
+
================================= */
|
637
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,fileID,version,false)) == NULL)
|
638
|
+
return(0);
|
639
|
+
newHeader = true;
|
640
|
+
|
641
|
+
arrayVersion = 1;
|
642
|
+
i = 1;
|
643
|
+
|
644
|
+
theLink = GetNextAlphaLink(theEnv,&theModule,&theDefclass,theLink);
|
645
|
+
while (theLink != NULL)
|
646
|
+
{
|
647
|
+
if (newHeader)
|
648
|
+
{
|
649
|
+
fprintf(fp,"CLASS_ALPHA_LINK %s%u_%u[] = {\n",
|
650
|
+
ObjectALPrefix(),imageID,arrayVersion);
|
651
|
+
fprintf(headerFP,"extern CLASS_ALPHA_LINK %s%u_%u[];\n",
|
652
|
+
ObjectALPrefix(),imageID,arrayVersion);
|
653
|
+
newHeader = false;
|
654
|
+
}
|
655
|
+
|
656
|
+
fprintf(fp,"{");
|
657
|
+
|
658
|
+
ObjectPatternNodeReference(theEnv,theLink->alphaNode,fp,imageID,maxIndices);
|
659
|
+
|
660
|
+
fprintf(fp,",");
|
661
|
+
|
662
|
+
ClassAlphaLinkReference(theEnv,theLink->next,fp,imageID,maxIndices);
|
663
|
+
|
664
|
+
fprintf(fp,"}");
|
665
|
+
|
666
|
+
theLink = GetNextAlphaLink(theEnv,&theModule,&theDefclass,theLink);
|
667
|
+
|
668
|
+
if ((i > maxIndices) || (theLink == NULL))
|
669
|
+
{
|
670
|
+
fprintf(fp,"};\n");
|
671
|
+
GenClose(theEnv,fp);
|
672
|
+
i = 1;
|
673
|
+
version++;
|
674
|
+
arrayVersion++;
|
675
|
+
if (theLink != NULL)
|
676
|
+
{
|
677
|
+
if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,fileID,version,false)) == NULL)
|
678
|
+
return(0);
|
679
|
+
newHeader = true;
|
680
|
+
}
|
681
|
+
}
|
682
|
+
else if (theLink != NULL)
|
683
|
+
{ fprintf(fp,",\n"); }
|
684
|
+
}
|
685
|
+
|
686
|
+
return(version);
|
687
|
+
}
|
688
|
+
|
689
|
+
/********************/
|
690
|
+
/* GetNextAlphaLink */
|
691
|
+
/********************/
|
692
|
+
static CLASS_ALPHA_LINK *GetNextAlphaLink(
|
693
|
+
Environment *theEnv,
|
694
|
+
Defmodule **theModule,
|
695
|
+
Defclass **theClass,
|
696
|
+
CLASS_ALPHA_LINK *theLink)
|
697
|
+
{
|
698
|
+
while (true)
|
699
|
+
{
|
700
|
+
if (theLink != NULL)
|
701
|
+
{
|
702
|
+
theLink = theLink->next;
|
703
|
+
|
704
|
+
if (theLink != NULL)
|
705
|
+
{ return theLink; }
|
706
|
+
}
|
707
|
+
else if (*theClass != NULL)
|
708
|
+
{
|
709
|
+
*theClass = GetNextDefclass(theEnv,*theClass);
|
710
|
+
if (*theClass != NULL)
|
711
|
+
{ theLink = (*theClass)->relevant_terminal_alpha_nodes; }
|
712
|
+
if (theLink != NULL)
|
713
|
+
{ return theLink; }
|
714
|
+
}
|
715
|
+
else
|
716
|
+
{
|
717
|
+
*theModule = GetNextDefmodule(theEnv,*theModule);
|
718
|
+
if (*theModule == NULL)
|
719
|
+
{ return NULL; }
|
720
|
+
SetCurrentModule(theEnv,*theModule);
|
721
|
+
*theClass = GetNextDefclass(theEnv,*theClass);
|
722
|
+
if (*theClass != NULL)
|
723
|
+
{
|
724
|
+
theLink = (*theClass)->relevant_terminal_alpha_nodes;
|
725
|
+
if (theLink != NULL)
|
726
|
+
{ return theLink; }
|
727
|
+
}
|
728
|
+
}
|
729
|
+
}
|
730
|
+
|
731
|
+
return NULL;
|
732
|
+
}
|
733
|
+
|
734
|
+
#endif
|