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
/*******************************************************/
/* "C" Language Integrated Production System */
/* */
/* CLIPS Version 6.40 02/20/20 */
/* */
/* */
/*******************************************************/
/*************************************************************/
/* Purpose: */
/* */
/* Principal Programmer(s): */
/* Brian L. Dantes */
/* */
/* Contributing Programmer(s): */
/* */
/* Revision History: */
/* */
/* 6.23: Changed name of variable log to logName */
/* because of Unix compiler warnings of shadowed */
/* definitions. */
/* */
/* 6.24: Removed IMPERATIVE_METHODS compilation flag. */
/* */
/* Renamed BOOLEAN macro type to intBool. */
/* */
/* 6.30: Removed conditional code for unsupported */
/* compilers/operating systems (IBM_MCW, */
/* MAC_MCW, and IBM_TBC). */
/* */
/* Changed integer type/precision. */
/* */
/* Added const qualifiers to remove C++ */
/* deprecation warnings. */
/* */
/* Converted API macros to function calls. */
/* */
/* Fixed linkage issue when DEBUGGING_FUNCTIONS */
/* is set to 0 and PROFILING_FUNCTIONS is set to */
/* 1. */
/* */
/* Fixed typing issue when OBJECT_SYSTEM */
/* compiler flag is set to 0. */
/* */
/* 6.40: Removed LOCALE definition. */
/* */
/* Pragma once and other inclusion changes. */
/* */
/* Added support for booleans with <stdbool.h>. */
/* */
/* Removed use of void pointers for specific */
/* data structures. */
/* */
/* UDF redesign. */
/* */
/*************************************************************/
#ifndef _H_genrcfun
#pragma once
#define _H_genrcfun
typedef struct defgenericModule DEFGENERIC_MODULE;
typedef struct restriction RESTRICTION;
typedef struct defmethod Defmethod;
typedef struct defgeneric Defgeneric;
#include <stdio.h>
#include "entities.h"
#include "conscomp.h"
#include "constrct.h"
#include "expressn.h"
#include "evaluatn.h"
#include "moduldef.h"
#include "symbol.h"
#define METHOD_NOT_FOUND USHRT_MAX
#define RESTRICTIONS_UNBOUNDED USHRT_MAX
struct defgenericModule
{
struct defmoduleItemHeader header;
};
struct restriction
{
void **types;
Expression *query;
unsigned short tcnt;
};
struct defmethod
{
ConstructHeader header;
unsigned short index;
unsigned busy;
unsigned short restrictionCount;
unsigned short minRestrictions;
unsigned short maxRestrictions;
unsigned short localVarCount;
unsigned system : 1;
unsigned trace : 1;
RESTRICTION *restrictions;
Expression *actions;
};
struct defgeneric
{
ConstructHeader header;
unsigned busy; // TBD bool?
bool trace;
Defmethod *methods;
unsigned short mcnt;
unsigned short new_index;
};
#define DEFGENERIC_DATA 27
struct defgenericData
{
Construct *DefgenericConstruct;
unsigned int DefgenericModuleIndex;
EntityRecord GenericEntityRecord;
#if DEBUGGING_FUNCTIONS
bool WatchGenerics;
bool WatchMethods;
#endif
Defgeneric *CurrentGeneric;
Defmethod *CurrentMethod;
UDFValue *GenericCurrentArgument;
#if (! RUN_TIME) && (! BLOAD_ONLY)
unsigned OldGenericBusySave;
#endif
#if CONSTRUCT_COMPILER && (! RUN_TIME)
struct CodeGeneratorItem *DefgenericCodeItem;
#endif
};
#define DefgenericData(theEnv) ((struct defgenericData *) GetEnvironmentData(theEnv,DEFGENERIC_DATA))
#define SaveBusyCount(gfunc) (DefgenericData(theEnv)->OldGenericBusySave = gfunc->busy)
#define RestoreBusyCount(gfunc) (gfunc->busy = DefgenericData(theEnv)->OldGenericBusySave)
#if ! RUN_TIME
bool ClearDefgenericsReady(Environment *,void *);
void *AllocateDefgenericModule(Environment *);
void FreeDefgenericModule(Environment *,void *);
#else
void DefgenericRunTimeInitialize(Environment *);
#endif
#if (! BLOAD_ONLY) && (! RUN_TIME)
bool ClearDefmethods(Environment *);
bool RemoveAllExplicitMethods(Environment *,Defgeneric *);
void RemoveDefgeneric(Environment *,Defgeneric *);
bool ClearDefgenerics(Environment *);
void MethodAlterError(Environment *,Defgeneric *);
void DeleteMethodInfo(Environment *,Defgeneric *,Defmethod *);
void DestroyMethodInfo(Environment *,Defgeneric *,Defmethod *);
bool MethodsExecuting(Defgeneric *);
#endif
#if ! OBJECT_SYSTEM
bool SubsumeType(long long,long long);
#endif
unsigned short FindMethodByIndex(Defgeneric *,unsigned short);
#if DEBUGGING_FUNCTIONS || PROFILING_FUNCTIONS
void PrintMethod(Environment *,Defmethod *,StringBuilder *);
#endif
#if DEBUGGING_FUNCTIONS
void PreviewGeneric(Environment *,UDFContext *,UDFValue *);
#endif
Defgeneric *CheckGenericExists(Environment *,const char *,const char *);
unsigned short CheckMethodExists(Environment *,const char *,Defgeneric *,unsigned short);
#if ! OBJECT_SYSTEM
const char *TypeName(Environment *,long long);
#endif
void PrintGenericName(Environment *,const char *,Defgeneric *);
#endif /* _H_genrcfun */