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 #ifndef _H_symbol
00030 #define _H_symbol
00031
00032 #ifdef LOCALE
00033 #undef LOCALE
00034 #endif
00035
00036 #ifdef _SYMBOL_SOURCE_
00037 #define LOCALE
00038 #else
00039 #define LOCALE extern
00040 #endif
00041
00042 #include <stdlib.h>
00043
00044 #ifndef SYMBOL_HASH_SIZE
00045 #define SYMBOL_HASH_SIZE 63559L
00046 #endif
00047
00048 #ifndef FLOAT_HASH_SIZE
00049 #define FLOAT_HASH_SIZE 8191
00050 #endif
00051
00052 #ifndef INTEGER_HASH_SIZE
00053 #define INTEGER_HASH_SIZE 8191
00054 #endif
00055
00056 #ifndef BITMAP_HASH_SIZE
00057 #define BITMAP_HASH_SIZE 8191
00058 #endif
00059
00060 #ifndef EXTERNAL_ADDRESS_HASH_SIZE
00061 #define EXTERNAL_ADDRESS_HASH_SIZE 8191
00062 #endif
00063
00064
00065
00066
00067 struct symbolHashNode
00068 {
00069 struct symbolHashNode *next;
00070 long count;
00071 int depth;
00072 unsigned int permanent : 1;
00073 unsigned int markedEphemeral : 1;
00074 unsigned int neededSymbol : 1;
00075 unsigned int bucket : 29;
00076 char *contents;
00077 };
00078
00079
00080
00081
00082 struct floatHashNode
00083 {
00084 struct floatHashNode *next;
00085 long count;
00086 int depth;
00087 unsigned int permanent : 1;
00088 unsigned int markedEphemeral : 1;
00089 unsigned int neededFloat : 1;
00090 unsigned int bucket : 29;
00091 double contents;
00092 };
00093
00094
00095
00096
00097 struct integerHashNode
00098 {
00099 struct integerHashNode *next;
00100 long count;
00101 int depth;
00102 unsigned int permanent : 1;
00103 unsigned int markedEphemeral : 1;
00104 unsigned int neededInteger : 1;
00105 unsigned int bucket : 29;
00106 long long contents;
00107 };
00108
00109
00110
00111
00112 struct bitMapHashNode
00113 {
00114 struct bitMapHashNode *next;
00115 long count;
00116 int depth;
00117 unsigned int permanent : 1;
00118 unsigned int markedEphemeral : 1;
00119 unsigned int neededBitMap : 1;
00120 unsigned int bucket : 29;
00121 char *contents;
00122 unsigned short size;
00123 };
00124
00125
00126
00127
00128 struct externalAddressHashNode
00129 {
00130 struct externalAddressHashNode *next;
00131 long count;
00132 int depth;
00133 unsigned int permanent : 1;
00134 unsigned int markedEphemeral : 1;
00135 unsigned int neededPointer : 1;
00136 unsigned int bucket : 29;
00137 void *externalAddress;
00138 unsigned short type;
00139 };
00140
00141
00142
00143
00144 struct genericHashNode
00145 {
00146 struct genericHashNode *next;
00147 long count;
00148 int depth;
00149 unsigned int permanent : 1;
00150 unsigned int markedEphemeral : 1;
00151 unsigned int needed : 1;
00152 unsigned int bucket : 29;
00153 };
00154
00155 typedef struct symbolHashNode SYMBOL_HN;
00156 typedef struct floatHashNode FLOAT_HN;
00157 typedef struct integerHashNode INTEGER_HN;
00158 typedef struct bitMapHashNode BITMAP_HN;
00159 typedef struct externalAddressHashNode EXTERNAL_ADDRESS_HN;
00160 typedef struct genericHashNode GENERIC_HN;
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 struct ephemeron
00174 {
00175 GENERIC_HN *associatedValue;
00176 struct ephemeron *next;
00177 };
00178
00179
00180
00181
00182 struct symbolMatch
00183 {
00184 struct symbolHashNode *match;
00185 struct symbolMatch *next;
00186 };
00187
00188 #define ValueToString(target) (((struct symbolHashNode *) (target))->contents)
00189 #define ValueToDouble(target) (((struct floatHashNode *) (target))->contents)
00190 #define ValueToLong(target) (((struct integerHashNode *) (target))->contents)
00191 #define ValueToInteger(target) ((int) (((struct integerHashNode *) (target))->contents))
00192 #define ValueToBitMap(target) ((void *) ((struct bitMapHashNode *) (target))->contents)
00193 #define ValueToExternalAddress(target) ((void *) ((struct externalAddressHashNode *) (target))->externalAddress)
00194
00195 #define EnvValueToString(theEnv,target) (((struct symbolHashNode *) (target))->contents)
00196 #define EnvValueToDouble(theEnv,target) (((struct floatHashNode *) (target))->contents)
00197 #define EnvValueToLong(theEnv,target) (((struct integerHashNode *) (target))->contents)
00198 #define EnvValueToInteger(theEnv,target) ((int) (((struct integerHashNode *) (target))->contents))
00199 #define EnvValueToBitMap(theEnv,target) ((void *) ((struct bitMapHashNode *) (target))->contents)
00200 #define EnvValueToExternalAddress(theEnv,target) ((void *) ((struct externalAddressHashNode *) (target))->externalAddress)
00201
00202 #define IncrementSymbolCount(theValue) (((SYMBOL_HN *) theValue)->count++)
00203 #define IncrementFloatCount(theValue) (((FLOAT_HN *) theValue)->count++)
00204 #define IncrementIntegerCount(theValue) (((INTEGER_HN *) theValue)->count++)
00205 #define IncrementBitMapCount(theValue) (((BITMAP_HN *) theValue)->count++)
00206 #define IncrementExternalAddressCount(theValue) (((EXTERNAL_ADDRESS_HN *) theValue)->count++)
00207
00208
00209
00210
00211
00212 #define SYMBOL_DATA 49
00213
00214 struct symbolData
00215 {
00216 void *TrueSymbolHN;
00217 void *FalseSymbolHN;
00218 void *PositiveInfinity;
00219 void *NegativeInfinity;
00220 void *Zero;
00221 SYMBOL_HN **SymbolTable;
00222 FLOAT_HN **FloatTable;
00223 INTEGER_HN **IntegerTable;
00224 BITMAP_HN **BitMapTable;
00225 EXTERNAL_ADDRESS_HN **ExternalAddressTable;
00226 struct ephemeron *EphemeralSymbolList;
00227 struct ephemeron *EphemeralFloatList;
00228 struct ephemeron *EphemeralIntegerList;
00229 struct ephemeron *EphemeralBitMapList;
00230 struct ephemeron *EphemeralExternalAddressList;
00231 #if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE || BLOAD_INSTANCES || BSAVE_INSTANCES
00232 long NumberOfSymbols;
00233 long NumberOfFloats;
00234 long NumberOfIntegers;
00235 long NumberOfBitMaps;
00236 long NumberOfExternalAddresses;
00237 SYMBOL_HN **SymbolArray;
00238 struct floatHashNode **FloatArray;
00239 INTEGER_HN **IntegerArray;
00240 BITMAP_HN **BitMapArray;
00241 EXTERNAL_ADDRESS_HN **ExternalAddressArray;
00242 #endif
00243 };
00244
00245 #define SymbolData(theEnv) ((struct symbolData *) GetEnvironmentData(theEnv,SYMBOL_DATA))
00246 #define EnvFalseSymbol(theEnv) SymbolData(theEnv)->FalseSymbolHN
00247 #define EnvTrueSymbol(theEnv) SymbolData(theEnv)->TrueSymbolHN
00248
00249 #define FalseSymbol() SymbolData(GetCurrentEnvironment())->FalseSymbolHN
00250 #define TrueSymbol() SymbolData(GetCurrentEnvironment())->TrueSymbolHN
00251 #define AddSymbol(a) EnvAddSymbol(GetCurrentEnvironment(),a)
00252 #define AddLong(a) EnvAddLong(GetCurrentEnvironment(),a)
00253 #define AddDouble(a) EnvAddDouble(GetCurrentEnvironment(),a)
00254
00255 LOCALE void InitializeAtomTables(void *,struct symbolHashNode **,struct floatHashNode **,
00256 struct integerHashNode **,struct bitMapHashNode **,
00257 struct externalAddressHashNode **);
00258 LOCALE void *EnvAddSymbol(void *,char *);
00259 LOCALE SYMBOL_HN *FindSymbolHN(void *,char *);
00260 LOCALE void *EnvAddDouble(void *,double);
00261 LOCALE void *EnvAddLong(void *,long long);
00262 LOCALE void *EnvAddBitMap(void *,void *,unsigned);
00263 LOCALE void *EnvAddExternalAddress(void *,void *,unsigned);
00264 LOCALE INTEGER_HN *FindLongHN(void *,long long);
00265 LOCALE unsigned long HashSymbol(char *,unsigned long);
00266 LOCALE unsigned long HashFloat(double,unsigned long);
00267 LOCALE unsigned long HashInteger(long long,unsigned long);
00268 LOCALE unsigned long HashBitMap(char *,unsigned long,unsigned);
00269 LOCALE unsigned long HashExternalAddress(void *,unsigned long);
00270 LOCALE void DecrementSymbolCount(void *,struct symbolHashNode *);
00271 LOCALE void DecrementFloatCount(void *,struct floatHashNode *);
00272 LOCALE void DecrementIntegerCount(void *,struct integerHashNode *);
00273 LOCALE void DecrementBitMapCount(void *,struct bitMapHashNode *);
00274 LOCALE void DecrementExternalAddressCount(void *,struct externalAddressHashNode *);
00275 LOCALE void RemoveEphemeralAtoms(void *);
00276 LOCALE struct symbolHashNode **GetSymbolTable(void *);
00277 LOCALE void SetSymbolTable(void *,struct symbolHashNode **);
00278 LOCALE struct floatHashNode **GetFloatTable(void *);
00279 LOCALE void SetFloatTable(void *,struct floatHashNode **);
00280 LOCALE struct integerHashNode **GetIntegerTable(void *);
00281 LOCALE void SetIntegerTable(void *,struct integerHashNode **);
00282 LOCALE struct bitMapHashNode **GetBitMapTable(void *);
00283 LOCALE void SetBitMapTable(void *,struct bitMapHashNode **);
00284 LOCALE struct externalAddressHashNode
00285 **GetExternalAddressTable(void *);
00286 LOCALE void SetExternalAddressTable(void *,struct externalAddressHashNode **);
00287 LOCALE void RefreshSpecialSymbols(void *);
00288 LOCALE struct symbolMatch *FindSymbolMatches(void *,char *,unsigned *,size_t *);
00289 LOCALE void ReturnSymbolMatches(void *,struct symbolMatch *);
00290 LOCALE SYMBOL_HN *GetNextSymbolMatch(void *,char *,size_t,SYMBOL_HN *,int,size_t *);
00291 LOCALE void ClearBitString(void *,unsigned);
00292 LOCALE void SetAtomicValueIndices(void *,int);
00293 LOCALE void RestoreAtomicValueBuckets(void *);
00294
00295 #endif
00296
00297
00298