1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
/*******************************************************/
/* "C" Language Integrated Production System */
/* */
/* CLIPS Version 6.40 02/20/20 */
/* */
/* OBJECT SYSTEM DEFINITIONS */
/*******************************************************/
/*************************************************************/
/* Purpose: */
/* */
/* Principal Programmer(s): */
/* Brian L. Dantes */
/* */
/* Contributing Programmer(s): */
/* */
/* */
/* Revision History: */
/* */
/* 6.30: Changed integer type/precision. */
/* */
/* Changed garbage collection algorithm. */
/* */
/* 6.31: Optimization for marking relevant alpha nodes */
/* in the object pattern network. */
/* */
/* 6.40: Pragma once and other inclusion changes. */
/* */
/* Removed use of void pointers for specific */
/* data structures. */
/* */
/*************************************************************/
#ifndef _H_object
#pragma once
#define _H_object
typedef struct defclassModule DEFCLASS_MODULE;
typedef struct defclass Defclass;
typedef struct packedClassLinks PACKED_CLASS_LINKS;
typedef struct classLink CLASS_LINK;
typedef struct slotName SLOT_NAME;
typedef struct slotDescriptor SlotDescriptor;
typedef struct defmessageHandler DefmessageHandler;
typedef struct instanceSlot InstanceSlot;
typedef struct instanceBuilder InstanceBuilder;
typedef struct instanceModifier InstanceModifier;
/* Maximum # of simultaneous class hierarchy traversals
should be a multiple of BITS_PER_BYTE and less than MAX_INT */
#define MAX_TRAVERSALS 256
#define TRAVERSAL_BYTES 32 /* (MAX_TRAVERSALS / BITS_PER_BYTE) */
#define VALUE_REQUIRED 0
#define VALUE_PROHIBITED 1
#define VALUE_NOT_REQUIRED 2
#include "entities.h"
#include "constrct.h"
#include "constrnt.h"
#include "moduldef.h"
#include "evaluatn.h"
#include "expressn.h"
#include "multifld.h"
#include "symbol.h"
#include "match.h"
#if DEFRULE_CONSTRUCT
#include "objrtmch.h"
#endif
struct packedClassLinks
{
unsigned long classCount;
Defclass **classArray;
};
struct defclassModule
{
struct defmoduleItemHeader header;
};
struct defclass
{
ConstructHeader header;
unsigned installed : 1;
unsigned system : 1;
unsigned abstract : 1;
unsigned reactive : 1;
unsigned traceInstances : 1;
unsigned traceSlots : 1;
unsigned short id;
unsigned busy;
unsigned hashTableIndex;
PACKED_CLASS_LINKS directSuperclasses;
PACKED_CLASS_LINKS directSubclasses;
PACKED_CLASS_LINKS allSuperclasses;
SlotDescriptor *slots;
SlotDescriptor **instanceTemplate;
unsigned *slotNameMap;
unsigned short slotCount;
unsigned short localInstanceSlotCount;
unsigned short instanceSlotCount;
unsigned short maxSlotNameID;
Instance *instanceList;
Instance *instanceListBottom;
DefmessageHandler *handlers;
unsigned *handlerOrderMap;
unsigned short handlerCount;
Defclass *nxtHash;
CLIPSBitMap *scopeMap;
/*
* Links this defclass to each of the terminal alpha nodes which could be
* affected by a modification to an instance of it. This saves having to
* iterate through every single terminal alpha for every single modification
* to an instance of a defclass.
*/
#if DEFRULE_CONSTRUCT && OBJECT_SYSTEM
CLASS_ALPHA_LINK *relevant_terminal_alpha_nodes;
#endif
char traversalRecord[TRAVERSAL_BYTES];
};
struct classLink
{
Defclass *cls;
struct classLink *nxt;
};
struct slotName
{
unsigned hashTableIndex;
unsigned use;
unsigned short id;
CLIPSLexeme *name;
CLIPSLexeme *putHandlerName;
struct slotName *nxt;
unsigned long bsaveIndex;
};
struct instanceSlot
{
SlotDescriptor *desc;
unsigned valueRequired : 1;
unsigned override : 1;
unsigned short type;
union
{
void *value;
TypeHeader *header;
CLIPSLexeme *lexemeValue;
CLIPSFloat *floatValue;
CLIPSInteger *integerValue;
CLIPSVoid *voidValue;
Fact *factValue;
Instance *instanceValue;
Multifield *multifieldValue;
CLIPSExternalAddress *externalAddressValue;
};
};
struct slotDescriptor
{
unsigned shared : 1;
unsigned multiple : 1;
unsigned composite : 1;
unsigned noInherit : 1;
unsigned noWrite : 1;
unsigned initializeOnly : 1;
unsigned dynamicDefault : 1;
unsigned defaultSpecified : 1;
unsigned noDefault : 1;
unsigned reactive : 1;
unsigned publicVisibility : 1;
unsigned createReadAccessor : 1;
unsigned createWriteAccessor : 1;
unsigned overrideMessageSpecified : 1;
Defclass *cls;
SLOT_NAME *slotName;
CLIPSLexeme *overrideMessage;
void *defaultValue;
CONSTRAINT_RECORD *constraint;
unsigned sharedCount;
unsigned long bsaveIndex;
InstanceSlot sharedValue;
};
struct instance
{
union
{
struct patternEntity patternHeader;
TypeHeader header;
};
void *partialMatchList;
InstanceSlot *basisSlots;
unsigned installed : 1;
unsigned garbage : 1;
unsigned initSlotsCalled : 1;
unsigned initializeInProgress : 1;
unsigned reteSynchronized : 1;
CLIPSLexeme *name;
unsigned hashTableIndex;
unsigned busy;
Defclass *cls;
Instance *prvClass,*nxtClass,
*prvHash,*nxtHash,
*prvList,*nxtList;
InstanceSlot **slotAddresses,
*slots;
};
struct defmessageHandler
{
ConstructHeader header;
unsigned system : 1;
unsigned type : 2;
unsigned mark : 1;
unsigned trace : 1;
unsigned busy;
Defclass *cls;
unsigned short minParams;
unsigned short maxParams;
unsigned short localVarCount;
Expression *actions;
};
struct instanceBuilder
{
Environment *ibEnv;
Defclass *ibDefclass;
CLIPSValue *ibValueArray;
};
struct instanceModifier
{
Environment *imEnv;
Instance *imOldInstance;
CLIPSValue *imValueArray;
char *changeMap;
};
#endif /* _H_object */