globle void PrintDefmoduleReference( void *theEnv, FILE *theFile, struct defmodule *theModule) { if (theModule == NULL) fprintf(theFile,"NULL"); else fprintf(theFile,"&%s%d_%ld[%ld]",DefmodulePrefix(),ConstructCompilerData(theEnv)->ImageID, (long) ((theModule->bsaveID / ConstructCompilerData(theEnv)->MaxIndices) + 1), (long) (theModule->bsaveID % ConstructCompilerData(theEnv)->MaxIndices)); }
void PrintIntegerReference( void *theEnv, FILE *theFile, struct integerHashNode *theInteger) { fprintf(theFile,"&I%d_%d[%d]", ConstructCompilerData(theEnv)->ImageID, (int) (theInteger->bucket / ConstructCompilerData(theEnv)->MaxIndices) + 1, (int) theInteger->bucket % ConstructCompilerData(theEnv)->MaxIndices); }
void PrintFloatReference( void *theEnv, FILE *theFile, struct floatHashNode *theFloat) { fprintf(theFile,"&F%d_%d[%d]", ConstructCompilerData(theEnv)->ImageID, (int) (theFloat->bucket / ConstructCompilerData(theEnv)->MaxIndices) + 1, (int) theFloat->bucket % ConstructCompilerData(theEnv)->MaxIndices); }
void PrintBitMapReference( void *theEnv, FILE *theFile, struct bitMapHashNode *theBitMap) { if (theBitMap == NULL) fprintf(theFile,"NULL"); else fprintf(theFile,"&B%d_%d[%d]", ConstructCompilerData(theEnv)->ImageID, (int) (theBitMap->bucket / ConstructCompilerData(theEnv)->MaxIndices) + 1, (int) theBitMap->bucket % ConstructCompilerData(theEnv)->MaxIndices); }
void PrintSymbolReference( void *theEnv, FILE *theFile, struct symbolHashNode *theSymbol) { if (theSymbol == NULL) fprintf(theFile,"NULL"); else fprintf(theFile,"&S%d_%d[%d]", ConstructCompilerData(theEnv)->ImageID, (int) (theSymbol->bucket / ConstructCompilerData(theEnv)->MaxIndices) + 1, (int) theSymbol->bucket % ConstructCompilerData(theEnv)->MaxIndices); }
static int SymbolHashNodesToCode( void *theEnv, EXEC_STATUS, char *fileName, char *pathName, char *fileNameBuffer, int version) { unsigned long i, j; struct symbolHashNode *hashPtr; int count; int numberOfEntries; struct symbolHashNode **symbolTable; int newHeader = TRUE; int arrayVersion = 1; FILE *fp; /*====================================*/ /* Count the total number of entries. */ /*====================================*/ symbolTable = GetSymbolTable(theEnv,execStatus); count = numberOfEntries = 0; for (i = 0; i < SYMBOL_HASH_SIZE; i++) { for (hashPtr = symbolTable[i]; hashPtr != NULL; hashPtr = hashPtr->next) { numberOfEntries++; } } if (numberOfEntries == 0) return(version); for (i = 1; i <= (unsigned long) (numberOfEntries / ConstructCompilerData(theEnv,execStatus)->MaxIndices) + 1 ; i++) { fprintf(ConstructCompilerData(theEnv,execStatus)->HeaderFP,"extern struct symbolHashNode S%d_%ld[];\n",ConstructCompilerData(theEnv,execStatus)->ImageID,i); } /*==================*/ /* Create the file. */ /*==================*/ if ((fp = NewCFile(theEnv,execStatus,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(-1); /*===================*/ /* List the entries. */ /*===================*/ j = 0; for (i = 0; i < SYMBOL_HASH_SIZE; i++) { for (hashPtr = symbolTable[i]; hashPtr != NULL; hashPtr = hashPtr->next) { if (newHeader) { fprintf(fp,"struct symbolHashNode S%d_%d[] = {\n",ConstructCompilerData(theEnv,execStatus)->ImageID,arrayVersion); newHeader = FALSE; } if (hashPtr->next == NULL) { fprintf(fp,"{NULL,"); } else { if ((j + 1) >= (unsigned long) ConstructCompilerData(theEnv,execStatus)->MaxIndices) { fprintf(fp,"{&S%d_%d[%d],",ConstructCompilerData(theEnv,execStatus)->ImageID,arrayVersion + 1,0); } else { fprintf(fp,"{&S%d_%d[%ld],",ConstructCompilerData(theEnv,execStatus)->ImageID,arrayVersion,j + 1); } } fprintf(fp,"%ld,0,1,0,0,%ld,",hashPtr->count + 1,i); PrintCString(fp,hashPtr->contents); count++; j++; if ((count == numberOfEntries) || (j >= (unsigned) ConstructCompilerData(theEnv,execStatus)->MaxIndices)) { fprintf(fp,"}};\n"); GenClose(theEnv,execStatus,fp); j = 0; arrayVersion++; version++; if (count < numberOfEntries) { if ((fp = NewCFile(theEnv,execStatus,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(0); newHeader = TRUE; } } else { fprintf(fp,"},\n"); } } } return(version); }
static int HashTablesToCode( void *theEnv, EXEC_STATUS, char *fileName, char *pathName, char *fileNameBuffer) { unsigned long i; FILE *fp; struct symbolHashNode **symbolTable; struct floatHashNode **floatTable; struct integerHashNode **integerTable; struct bitMapHashNode **bitMapTable; /*======================================*/ /* Write the code for the symbol table. */ /*======================================*/ symbolTable = GetSymbolTable(theEnv,execStatus); if ((fp = NewCFile(theEnv,execStatus,fileName,pathName,fileNameBuffer,1,1,FALSE)) == NULL) return(0); fprintf(ConstructCompilerData(theEnv,execStatus)->HeaderFP,"extern struct symbolHashNode *sht%d[];\n",ConstructCompilerData(theEnv,execStatus)->ImageID); fprintf(fp,"struct symbolHashNode *sht%d[%ld] = {\n",ConstructCompilerData(theEnv,execStatus)->ImageID,SYMBOL_HASH_SIZE); for (i = 0; i < SYMBOL_HASH_SIZE; i++) { PrintSymbolReference(theEnv,execStatus,fp,symbolTable[i]); if (i + 1 != SYMBOL_HASH_SIZE) fprintf(fp,",\n"); } fprintf(fp,"};\n"); GenClose(theEnv,execStatus,fp); /*=====================================*/ /* Write the code for the float table. */ /*=====================================*/ floatTable = GetFloatTable(theEnv,execStatus); if ((fp = NewCFile(theEnv,execStatus,fileName,pathName,fileNameBuffer,1,2,FALSE)) == NULL) return(0); fprintf(ConstructCompilerData(theEnv,execStatus)->HeaderFP,"extern struct floatHashNode *fht%d[];\n",ConstructCompilerData(theEnv,execStatus)->ImageID); fprintf(fp,"struct floatHashNode *fht%d[%d] = {\n",ConstructCompilerData(theEnv,execStatus)->ImageID,FLOAT_HASH_SIZE); for (i = 0; i < FLOAT_HASH_SIZE; i++) { if (floatTable[i] == NULL) { fprintf(fp,"NULL"); } else PrintFloatReference(theEnv,execStatus,fp,floatTable[i]); if (i + 1 != FLOAT_HASH_SIZE) fprintf(fp,",\n"); } fprintf(fp,"};\n"); GenClose(theEnv,execStatus,fp); /*=======================================*/ /* Write the code for the integer table. */ /*=======================================*/ integerTable = GetIntegerTable(theEnv,execStatus); if ((fp = NewCFile(theEnv,execStatus,fileName,pathName,fileNameBuffer,1,3,FALSE)) == NULL) return(0); fprintf(ConstructCompilerData(theEnv,execStatus)->HeaderFP,"extern struct integerHashNode *iht%d[];\n",ConstructCompilerData(theEnv,execStatus)->ImageID); fprintf(fp,"struct integerHashNode *iht%d[%d] = {\n",ConstructCompilerData(theEnv,execStatus)->ImageID,INTEGER_HASH_SIZE); for (i = 0; i < INTEGER_HASH_SIZE; i++) { if (integerTable[i] == NULL) { fprintf(fp,"NULL"); } else PrintIntegerReference(theEnv,execStatus,fp,integerTable[i]); if (i + 1 != INTEGER_HASH_SIZE) fprintf(fp,",\n"); } fprintf(fp,"};\n"); GenClose(theEnv,execStatus,fp); /*======================================*/ /* Write the code for the bitmap table. */ /*======================================*/ bitMapTable = GetBitMapTable(theEnv,execStatus); if ((fp = NewCFile(theEnv,execStatus,fileName,pathName,fileNameBuffer,1,4,FALSE)) == NULL) return(0); fprintf(ConstructCompilerData(theEnv,execStatus)->HeaderFP,"extern struct bitMapHashNode *bmht%d[];\n",ConstructCompilerData(theEnv,execStatus)->ImageID); fprintf(fp,"struct bitMapHashNode *bmht%d[%d] = {\n",ConstructCompilerData(theEnv,execStatus)->ImageID,BITMAP_HASH_SIZE); for (i = 0; i < BITMAP_HASH_SIZE; i++) { PrintBitMapReference(theEnv,execStatus,fp,bitMapTable[i]); if (i + 1 != BITMAP_HASH_SIZE) fprintf(fp,",\n"); } fprintf(fp,"};\n"); GenClose(theEnv,execStatus,fp); return(1); }
static int BitMapValuesToCode( void *theEnv, EXEC_STATUS, char *fileName, char *pathName, char *fileNameBuffer, int version) { int i, j, k; unsigned l; struct bitMapHashNode *hashPtr; int count; int numberOfEntries; struct bitMapHashNode **bitMapTable; int newHeader = TRUE; int arrayVersion = 1; FILE *fp; unsigned long tmpLong; int longsReqd; /*====================================*/ /* Count the total number of entries. */ /*====================================*/ bitMapTable = GetBitMapTable(theEnv,execStatus); count = numberOfEntries = 0; for (i = 0; i < BITMAP_HASH_SIZE; i++) { for (hashPtr = bitMapTable[i]; hashPtr != NULL; hashPtr = hashPtr->next) { numberOfEntries += (int) (hashPtr->size / sizeof(unsigned long)); if ((hashPtr->size % sizeof(unsigned long)) != 0) { numberOfEntries++; } } } if (numberOfEntries == 0) return(version); for (i = 1; i <= (numberOfEntries / ConstructCompilerData(theEnv,execStatus)->MaxIndices) + 1 ; i++) { fprintf(ConstructCompilerData(theEnv,execStatus)->HeaderFP,"extern unsigned long L%d_%d[];\n",ConstructCompilerData(theEnv,execStatus)->ImageID,i); } /*==================*/ /* Create the file. */ /*==================*/ if ((fp = NewCFile(theEnv,execStatus,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(-1); /*===================*/ /* List the entries. */ /*===================*/ j = 0; for (i = 0; i < BITMAP_HASH_SIZE; i++) { for (hashPtr = bitMapTable[i]; hashPtr != NULL; hashPtr = hashPtr->next) { if (newHeader) { fprintf(fp,"unsigned long L%d_%d[] = {\n",ConstructCompilerData(theEnv,execStatus)->ImageID,arrayVersion); newHeader = FALSE; } longsReqd = (int) (hashPtr->size / sizeof(unsigned long)); if ((hashPtr->size % sizeof(unsigned long)) != 0) longsReqd++; for (k = 0 ; k < longsReqd ; k++) { if (k > 0) fprintf(fp,","); tmpLong = 0L; for (l = 0 ; ((l < sizeof(unsigned long)) && (((k * sizeof(unsigned long)) + l) < (size_t) hashPtr->size)) ; l++) ((char *) &tmpLong)[l] = hashPtr->contents[(k * sizeof(unsigned long)) + l]; fprintf(fp,"0x%lxL",tmpLong); } count += longsReqd; j += longsReqd; if ((count == numberOfEntries) || (j >= ConstructCompilerData(theEnv,execStatus)->MaxIndices)) { fprintf(fp,"};\n"); GenClose(theEnv,execStatus,fp); j = 0; arrayVersion++; version++; if (count < numberOfEntries) { if ((fp = NewCFile(theEnv,execStatus,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(0); newHeader = TRUE; } } else { fprintf(fp,",\n"); } } } return(version); }
static int BitMapHashNodesToCode( void *theEnv, EXEC_STATUS, char *fileName, char *pathName, char *fileNameBuffer, int version) { int i, j; struct bitMapHashNode *hashPtr; int count; int numberOfEntries; struct bitMapHashNode **bitMapTable; int newHeader = TRUE; int arrayVersion = 1; FILE *fp; int longsReqdPartition = 1,longsReqdPartitionCount = 0; /*====================================*/ /* Count the total number of entries. */ /*====================================*/ bitMapTable = GetBitMapTable(theEnv,execStatus); count = numberOfEntries = 0; for (i = 0; i < BITMAP_HASH_SIZE; i++) { for (hashPtr = bitMapTable[i]; hashPtr != NULL; hashPtr = hashPtr->next) { numberOfEntries++; } } if (numberOfEntries == 0) return(version); for (i = 1; i <= (numberOfEntries / ConstructCompilerData(theEnv,execStatus)->MaxIndices) + 1 ; i++) { fprintf(ConstructCompilerData(theEnv,execStatus)->HeaderFP,"extern struct bitMapHashNode B%d_%d[];\n",ConstructCompilerData(theEnv,execStatus)->ImageID,i); } /*==================*/ /* Create the file. */ /*==================*/ if ((fp = NewCFile(theEnv,execStatus,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(-1); /*===================*/ /* List the entries. */ /*===================*/ j = 0; for (i = 0; i < BITMAP_HASH_SIZE; i++) { for (hashPtr = bitMapTable[i]; hashPtr != NULL; hashPtr = hashPtr->next) { if (newHeader) { fprintf(fp,"struct bitMapHashNode B%d_%d[] = {\n",ConstructCompilerData(theEnv,execStatus)->ImageID,arrayVersion); newHeader = FALSE; } if (hashPtr->next == NULL) { fprintf(fp,"{NULL,"); } else { if ((j + 1) >= ConstructCompilerData(theEnv,execStatus)->MaxIndices) { fprintf(fp,"{&B%d_%d[%d],",ConstructCompilerData(theEnv,execStatus)->ImageID,arrayVersion + 1,0); } else { fprintf(fp,"{&B%d_%d[%d],",ConstructCompilerData(theEnv,execStatus)->ImageID,arrayVersion,j + 1); } } fprintf(fp,"%ld,0,1,0,0,%d,(char *) &L%d_%d[%d],%d", hashPtr->count + 1,i, ConstructCompilerData(theEnv,execStatus)->ImageID,longsReqdPartition,longsReqdPartitionCount, hashPtr->size); longsReqdPartitionCount += (int) (hashPtr->size / sizeof(unsigned long)); if ((hashPtr->size % sizeof(unsigned long)) != 0) longsReqdPartitionCount++; if (longsReqdPartitionCount >= ConstructCompilerData(theEnv,execStatus)->MaxIndices) { longsReqdPartitionCount = 0; longsReqdPartition++; } count++; j++; if ((count == numberOfEntries) || (j >= ConstructCompilerData(theEnv,execStatus)->MaxIndices)) { fprintf(fp,"}};\n"); GenClose(theEnv,execStatus,fp); j = 0; arrayVersion++; version++; if (count < numberOfEntries) { if ((fp = NewCFile(theEnv,execStatus,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(0); newHeader = TRUE; } } else { fprintf(fp,"},\n"); } } } return(version); }
static int IntegerHashNodesToCode( void *theEnv, const char *fileName, const char *pathName, char *fileNameBuffer, int version) { int i, j; struct integerHashNode *hashPtr; int count; int numberOfEntries; struct integerHashNode **integerTable; bool newHeader = true; FILE *fp; int arrayVersion = 1; /*====================================*/ /* Count the total number of entries. */ /*====================================*/ integerTable = GetIntegerTable(theEnv); count = numberOfEntries = 0; for (i = 0; i < INTEGER_HASH_SIZE; i++) { for (hashPtr = integerTable[i]; hashPtr != NULL; hashPtr = hashPtr->next) { numberOfEntries++; } } if (numberOfEntries == 0) return(version); for (i = 1; i <= (numberOfEntries / ConstructCompilerData(theEnv)->MaxIndices) + 1 ; i++) { fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern struct integerHashNode I%d_%d[];\n",ConstructCompilerData(theEnv)->ImageID,i); } /*==================*/ /* Create the file. */ /*==================*/ if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,false)) == NULL) return(-1); /*===================*/ /* List the entries. */ /*===================*/ j = 0; for (i = 0; i < INTEGER_HASH_SIZE; i++) { for (hashPtr = integerTable[i]; hashPtr != NULL; hashPtr = hashPtr->next) { if (newHeader) { fprintf(fp,"struct integerHashNode I%d_%d[] = {\n",ConstructCompilerData(theEnv)->ImageID,arrayVersion); newHeader = false; } if (hashPtr->next == NULL) { fprintf(fp,"{NULL,"); } else { if ((j + 1) >= ConstructCompilerData(theEnv)->MaxIndices) { fprintf(fp,"{&I%d_%d[%d],",ConstructCompilerData(theEnv)->ImageID,arrayVersion + 1,0); } else { fprintf(fp,"{&I%d_%d[%d],",ConstructCompilerData(theEnv)->ImageID,arrayVersion,j + 1); } } fprintf(fp,"%ld,1,0,0,%d,",hashPtr->count + 1,i); fprintf(fp,"%lldLL",hashPtr->contents); count++; j++; if ((count == numberOfEntries) || (j >= ConstructCompilerData(theEnv)->MaxIndices)) { fprintf(fp,"}};\n"); GenClose(theEnv,fp); j = 0; version++; arrayVersion++; if (count < numberOfEntries) { if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,false)) == NULL) return(0); newHeader = true; } } else { fprintf(fp,"},\n"); } } } return(version); }