1 /*******************************************************/ 2 /* "C" Language Integrated Production System */ 3 /* */ 4 /* CLIPS Version 6.30 08/16/14 */ 5 /* */ 6 /* EXPRESSION HEADER FILE */ 7 /*******************************************************/ 8 9 /*************************************************************/ 10 /* Purpose: Contains routines for creating, deleting, */ 11 /* compacting, installing, and hashing expressions. */ 12 /* */ 13 /* Principal Programmer(s): */ 14 /* Gary D. Riley */ 15 /* */ 16 /* Contributing Programmer(s): */ 17 /* Brian L. Dantes */ 18 /* */ 19 /* Revision History: */ 20 /* */ 21 /* 6.24: Renamed BOOLEAN macro type to intBool. */ 22 /* */ 23 /* 6.30: Removed conditional code for unsupported */ 24 /* compilers/operating systems (IBM_MCW and */ 25 /* MAC_MCW). */ 26 /* */ 27 /* Changed integer type/precision. */ 28 /* */ 29 /* Changed expression hashing value. */ 30 /* */ 31 /*************************************************************/ 32 33 #ifndef _H_expressn 34 35 #define _H_expressn 36 37 struct expr; 38 struct exprHashNode; 39 40 #ifndef _H_exprnops 41 #include "exprnops.h" 42 #endif 43 44 /******************************/ 45 /* Expression Data Structures */ 46 /******************************/ 47 48 struct expr 49 { 50 unsigned short type; 51 void *value; 52 struct expr *argList; 53 struct expr *nextArg; 54 }; 55 56 #define arg_list argList 57 #define next_arg nextArg 58 59 typedef struct expr EXPRESSION; 60 61 typedef struct exprHashNode 62 { 63 unsigned hashval; 64 unsigned count; 65 struct expr *exp; 66 struct exprHashNode *next; 67 long bsaveID; 68 } EXPRESSION_HN; 69 70 #define EXPRESSION_HASH_SIZE 503 71 72 /*************************/ 73 /* Type and Value Macros */ 74 /*************************/ 75 76 #define GetType(target) ((target).type) 77 #define GetpType(target) ((target)->type) 78 #define SetType(target,val) ((target).type = (unsigned short) (val)) 79 #define SetpType(target,val) ((target)->type = (unsigned short) (val)) 80 #define GetValue(target) ((target).value) 81 #define GetpValue(target) ((target)->value) 82 #define SetValue(target,val) ((target).value = (void *) (val)) 83 #define SetpValue(target,val) ((target)->value = (void *) (val)) 84 85 #define EnvGetType(theEnv,target) ((target).type) 86 #define EnvGetpType(theEnv,target) ((target)->type) 87 #define EnvSetType(theEnv,target,val) ((target).type = (unsigned short) (val)) 88 #define EnvSetpType(theEnv,target,val) ((target)->type = (unsigned short) (val)) 89 #define EnvGetValue(theEnv,target) ((target).value) 90 #define EnvGetpValue(theEnv,target) ((target)->value) 91 #define EnvSetValue(theEnv,target,val) ((target).value = (void *) (val)) 92 #define EnvSetpValue(theEnv,target,val) ((target)->value = (void *) (val)) 93 94 /********************/ 95 /* ENVIRONMENT DATA */ 96 /********************/ 97 98 #ifndef _H_exprnpsr 99 #include "exprnpsr.h" 100 #endif 101 102 #define EXPRESSION_DATA 45 103 104 struct expressionData 105 { 106 void *PTR_AND; 107 void *PTR_OR; 108 void *PTR_EQ; 109 void *PTR_NEQ; 110 void *PTR_NOT; 111 EXPRESSION_HN **ExpressionHashTable; 112 #if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) 113 long NumberOfExpressions; 114 struct expr *ExpressionArray; 115 long int ExpressionCount; 116 #endif 117 #if (! RUN_TIME) 118 SAVED_CONTEXTS *svContexts; 119 int ReturnContext; 120 int BreakContext; 121 #endif 122 intBool SequenceOpMode; 123 }; 124 125 #define ExpressionData(theEnv) ((struct expressionData *) GetEnvironmentData(theEnv,EXPRESSION_DATA)) 126 127 /********************/ 128 /* Global Functions */ 129 /********************/ 130 131 #ifdef LOCALE 132 #undef LOCALE 133 #endif 134 135 #ifdef _EXPRESSN_SOURCE_ 136 #define LOCALE 137 #else 138 #define LOCALE extern 139 #endif 140 141 LOCALE void ReturnExpression(void *,struct expr *); 142 LOCALE void ExpressionInstall(void *,struct expr *); 143 LOCALE void ExpressionDeinstall(void *,struct expr *); 144 LOCALE struct expr *PackExpression(void *,struct expr *); 145 LOCALE void ReturnPackedExpression(void *,struct expr *); 146 LOCALE void InitExpressionData(void *); 147 LOCALE void InitExpressionPointers(void *); 148 #if (! BLOAD_ONLY) && (! RUN_TIME) 149 LOCALE EXPRESSION *AddHashedExpression(void *,EXPRESSION *); 150 #endif 151 #if (! RUN_TIME) 152 LOCALE void RemoveHashedExpression(void *,EXPRESSION *); 153 #endif 154 #if BLOAD_AND_BSAVE || BLOAD_ONLY || BLOAD || CONSTRUCT_COMPILER 155 LOCALE long HashedExpressionIndex(void *,EXPRESSION *); 156 #endif 157 158 #endif 159 160 161 162 163