1    /*******************************************************/
2    /*      "C" Language Integrated Production System      */
3    /*                                                     */
4    /*             CLIPS Version 6.30  08/16/14            */
5    /*                                                     */
6    /*        FACT RETE FUNCTION GENERATION HEADER FILE    */
7    /*******************************************************/
8 
9 /*************************************************************/
10 /* Purpose:                                                  */
11 /*                                                           */
12 /* Principal Programmer(s):                                  */
13 /*      Gary D. Riley                                        */
14 /*                                                           */
15 /* Contributing Programmer(s):                               */
16 /*                                                           */
17 /* Revision History:                                         */
18 /*                                                           */
19 /*      6.30: Support for performance optimizations.         */
20 /*                                                           */
21 /*            Increased maximum values for pattern/slot      */
22 /*            indices.                                       */
23 /*                                                           */
24 /*************************************************************/
25 
26 #ifndef _H_factgen
27 
28 #define _H_factgen
29 
30 #ifndef _H_reorder
31 #include "reorder.h"
32 #endif
33 
34 #ifdef LOCALE
35 #undef LOCALE
36 #endif
37 
38 #ifdef _FACTGEN_SOURCE_
39 #define LOCALE
40 #else
41 #define LOCALE extern
42 #endif
43 
44 /**********************************************************/
45 /* factGetVarPN1Call: This structure is used to store the */
46 /*   arguments to the most general extraction routine for */
47 /*   retrieving a variable from the fact pattern network. */
48 /**********************************************************/
49 struct factGetVarPN1Call
50   {
51    unsigned int factAddress : 1;
52    unsigned int allFields : 1;
53    unsigned short whichField;
54    unsigned short whichSlot;
55   };
56 
57 /***********************************************************/
58 /* factGetVarPN2Call: This structure is used to store the  */
59 /*   arguments to the most specific extraction routine for */
60 /*   retrieving a variable from the fact pattern network.  */
61 /*   It is used for retrieving the single value stored in  */
62 /*   a single field slot (the slot index can be used to    */
63 /*   directly to retrieve the value from the fact array).  */
64 /***********************************************************/
65 struct factGetVarPN2Call
66   {
67    unsigned short whichSlot;
68   };
69 
70 /**********************************************************/
71 /* factGetVarPN3Call:  */
72 /**********************************************************/
73 struct factGetVarPN3Call
74   {
75    unsigned int fromBeginning : 1;
76    unsigned int fromEnd : 1;
77    unsigned short beginOffset;
78    unsigned short endOffset;
79    unsigned short whichSlot;
80   };
81 
82 /**************************************************************/
83 /* factConstantPN1Call: Used for testing for a constant value */
84 /*   in the fact pattern network. Compare the value of a      */
85 /*   single field slot to a constant.                         */
86 /**************************************************************/
87 struct factConstantPN1Call
88   {
89    unsigned int testForEquality : 1;
90    unsigned short whichSlot;
91   };
92 
93 /******************************************************************/
94 /* factConstantPN2Call: Used for testing for a constant value in  */
95 /*   the fact pattern network. Compare the value of a multifield  */
96 /*   slot to a constant (where the value retrieved for comparison */
97 /*   from the slot contains no multifields before or only one     */
98 /*   multifield before and none after).                           */
99 /******************************************************************/
100 struct factConstantPN2Call
101   {
102    unsigned int testForEquality : 1;
103    unsigned int fromBeginning : 1;
104    unsigned short offset;
105    unsigned short whichSlot;
106   };
107 
108 /**********************************************************/
109 /* factGetVarJN1Call: This structure is used to store the */
110 /*   arguments to the most general extraction routine for */
111 /*   retrieving a fact variable from the join network.    */
112 /**********************************************************/
113 struct factGetVarJN1Call
114   {
115    unsigned int factAddress : 1;
116    unsigned int allFields : 1;
117    unsigned int lhs : 1;
118    unsigned int rhs : 1;
119    unsigned short whichPattern;
120    unsigned short whichSlot;
121    unsigned short whichField;
122   };
123 
124 /**********************************************************/
125 /* factGetVarJN2Call:  */
126 /**********************************************************/
127 struct factGetVarJN2Call
128   {
129    unsigned int lhs : 1;
130    unsigned int rhs : 1;
131    unsigned short whichPattern;
132    unsigned short whichSlot;
133   };
134 
135 /**********************************************************/
136 /* factGetVarJN3Call:  */
137 /**********************************************************/
138 struct factGetVarJN3Call
139   {
140    unsigned int fromBeginning : 1;
141    unsigned int fromEnd : 1;
142    unsigned int lhs : 1;
143    unsigned int rhs : 1;
144    unsigned short beginOffset;
145    unsigned short endOffset;
146    unsigned short whichPattern;
147    unsigned short whichSlot;
148   };
149 
150 /**********************************************************/
151 /* factCompVarsPN1Call:  */
152 /**********************************************************/
153 struct factCompVarsPN1Call
154   {
155    unsigned int pass : 1;
156    unsigned int fail : 1;
157    unsigned short field1;
158    unsigned short field2;
159   };
160 
161 /**********************************************************/
162 /* factCompVarsJN1Call:  */
163 /**********************************************************/
164 struct factCompVarsJN1Call
165   {
166    unsigned int pass : 1;
167    unsigned int fail : 1;
168    unsigned int p1lhs: 1;
169    unsigned int p1rhs: 1;
170    unsigned int p2lhs: 1;
171    unsigned int p2rhs: 1;
172    unsigned short pattern1;
173    unsigned short pattern2;
174    unsigned short slot1;
175    unsigned short slot2;
176   };
177 
178 /**********************************************************/
179 /* factCompVarsJN2Call:  */
180 /**********************************************************/
181 struct factCompVarsJN2Call
182   {
183    unsigned int pass : 1;
184    unsigned int fail : 1;
185    unsigned int p1lhs: 1;
186    unsigned int p1rhs: 1;
187    unsigned int p2lhs: 1;
188    unsigned int p2rhs: 1;
189    unsigned int fromBeginning1 : 1;
190    unsigned int fromBeginning2 : 1;
191    unsigned short offset1;
192    unsigned short offset2;
193    unsigned short pattern1;
194    unsigned short pattern2;
195    unsigned short slot1;
196    unsigned short slot2;
197   };
198 
199 /**********************************************************/
200 /* factCheckLengthPNCall: This structure is used to store */
201 /*   the  arguments to the routine for determining if the */
202 /*   length of a multifield slot is equal or greater than */
203 /*   a specified value.                                   */
204 /**********************************************************/
205 
206 struct factCheckLengthPNCall
207   {
208     unsigned int exactly : 1;
209     unsigned short minLength;
210     unsigned short whichSlot;
211   };
212 
213 /****************************************/
214 /* GLOBAL EXTERNAL FUNCTION DEFINITIONS */
215 /****************************************/
216 
217    LOCALE void                       InitializeFactReteFunctions(void *);
218    LOCALE struct expr               *FactPNVariableComparison(void *,struct lhsParseNode *,
219                                                               struct lhsParseNode *);
220    LOCALE struct expr               *FactJNVariableComparison(void *,struct lhsParseNode *,
221                                                               struct lhsParseNode *,int);
222    LOCALE void                       FactReplaceGetvar(void *,struct expr *,struct lhsParseNode *,int);
223    LOCALE void                       FactReplaceGetfield(void *,struct expr *,struct lhsParseNode *);
224    LOCALE struct expr               *FactGenPNConstant(void *,struct lhsParseNode *);
225    LOCALE struct expr               *FactGenGetfield(void *,struct lhsParseNode *);
226    LOCALE struct expr               *FactGenGetvar(void *,struct lhsParseNode *,int);
227    LOCALE struct expr               *FactGenCheckLength(void *,struct lhsParseNode *);
228    LOCALE struct expr               *FactGenCheckZeroLength(void *,unsigned);
229 
230 #endif /* _H_factgen */
231