00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef _H_ruledef
00039 #define _H_ruledef
00040
00041 #define GetDisjunctIndex(r) ((struct constructHeader *) r)->bsaveID
00042
00043 struct defrule;
00044 struct defruleModule;
00045
00046 #ifndef _H_conscomp
00047 #include "conscomp.h"
00048 #endif
00049 #ifndef _H_symbol
00050 #include "symbol.h"
00051 #endif
00052 #ifndef _H_expressn
00053 #include "expressn.h"
00054 #endif
00055 #ifndef _H_evaluatn
00056 #include "evaluatn.h"
00057 #endif
00058 #ifndef _H_constrct
00059 #include "constrct.h"
00060 #endif
00061 #ifndef _H_moduldef
00062 #include "moduldef.h"
00063 #endif
00064 #ifndef _H_constrnt
00065 #include "constrnt.h"
00066 #endif
00067 #ifndef _H_cstrccom
00068 #include "cstrccom.h"
00069 #endif
00070 #ifndef _H_agenda
00071 #include "agenda.h"
00072 #endif
00073 #ifndef _H_network
00074 #include "network.h"
00075 #endif
00076
00077 struct defrule
00078 {
00079 struct constructHeader header;
00080 int salience;
00081 int localVarCnt;
00082 unsigned int complexity : 11;
00083 unsigned int afterBreakpoint : 1;
00084 unsigned int watchActivation : 1;
00085 unsigned int watchFiring : 1;
00086 unsigned int autoFocus : 1;
00087 unsigned int executing : 1;
00088 struct expr *dynamicSalience;
00089 struct expr *actions;
00090 struct joinNode *logicalJoin;
00091 struct joinNode *lastJoin;
00092 struct defrule *disjunct;
00093 };
00094
00095 struct defruleModule
00096 {
00097 struct defmoduleItemHeader header;
00098 struct salienceGroup *groupings;
00099 struct activation *agenda;
00100 };
00101
00102 #ifndef ALPHA_MEMORY_HASH_SIZE
00103 #define ALPHA_MEMORY_HASH_SIZE 63559L
00104 #endif
00105
00106 #define DEFRULE_DATA 16
00107
00108 struct defruleData
00109 {
00110 struct construct *DefruleConstruct;
00111 int DefruleModuleIndex;
00112 long long CurrentEntityTimeTag;
00113 struct alphaMemoryHash **AlphaMemoryTable;
00114 intBool BetaMemoryResizingFlag;
00115 struct joinLink *RightPrimeJoins;
00116 struct joinLink *LeftPrimeJoins;
00117
00118 #if DEBUGGING_FUNCTIONS
00119 unsigned WatchRules;
00120 int DeletedRuleDebugFlags;
00121 #endif
00122 #if DEVELOPER && (! RUN_TIME) && (! BLOAD_ONLY)
00123 unsigned WatchRuleAnalysis;
00124 #endif
00125 #if CONSTRUCT_COMPILER && (! RUN_TIME)
00126 struct CodeGeneratorItem *DefruleCodeItem;
00127 #endif
00128 };
00129
00130 #define EnvGetDefruleName(theEnv,x) GetConstructNameString((struct constructHeader *) x)
00131 #define EnvGetDefrulePPForm(theEnv,x) GetConstructPPForm(theEnv,(struct constructHeader *) x)
00132 #define EnvDefruleModule(theEnv,x) GetConstructModuleName((struct constructHeader *) x)
00133
00134 #define DefruleData(theEnv) ((struct defruleData *) GetEnvironmentData(theEnv,DEFRULE_DATA))
00135
00136 #define GetPreviousJoin(theJoin) \
00137 (((theJoin)->joinFromTheRight) ? \
00138 ((struct joinNode *) (theJoin)->rightSideEntryStructure) : \
00139 ((theJoin)->lastLevel))
00140 #define GetPatternForJoin(theJoin) \
00141 (((theJoin)->joinFromTheRight) ? \
00142 NULL : \
00143 ((theJoin)->rightSideEntryStructure))
00144
00145 #ifdef LOCALE
00146 #undef LOCALE
00147 #endif
00148
00149 #ifdef _RULEDEF_SOURCE_
00150 #define LOCALE
00151 #else
00152 #define LOCALE extern
00153 #endif
00154
00155 #define DefruleModule(x) GetConstructModuleName((struct constructHeader *) x)
00156 #define FindDefrule(a) EnvFindDefrule(GetCurrentEnvironment(),a)
00157 #define GetDefruleName(x) GetConstructNameString((struct constructHeader *) x)
00158 #define GetDefrulePPForm(x) GetConstructPPForm(GetCurrentEnvironment(),(struct constructHeader *) x)
00159 #define GetNextDefrule(a) EnvGetNextDefrule(GetCurrentEnvironment(),a)
00160 #define IsDefruleDeletable(a) EnvIsDefruleDeletable(GetCurrentEnvironment(),a)
00161
00162 LOCALE void InitializeDefrules(void *);
00163 LOCALE void *EnvFindDefrule(void *,char *);
00164 LOCALE void *EnvGetNextDefrule(void *,void *);
00165 LOCALE struct defruleModule *GetDefruleModuleItem(void *,struct defmodule *);
00166 LOCALE intBool EnvIsDefruleDeletable(void *,void *);
00167 #if RUN_TIME
00168 LOCALE void DefruleRunTimeInitialize(void *,struct joinLink *,struct joinLink *);
00169 #endif
00170 #if RUN_TIME || BLOAD_ONLY || BLOAD || BLOAD_AND_BSAVE
00171 LOCALE void AddBetaMemoriesToJoin(void *,struct joinNode *);
00172 #endif
00173
00174 #endif
00175
00176