/**************************************************************** NAME : TypeToCode DESCRIPTION : Writes out a single type's data to the file INPUTS : 1) The output file 2) The compile image id 3) The type RETURNS : Nothing useful SIDE EFFECTS : Type data written NOTES : None ***************************************************************/ static void TypeToCode( FILE *theFile, int imageID, void *theType, int maxIndices) { #if OBJECT_SYSTEM fprintf(theFile,"VS "); PrintClassReference(theFile,(DEFCLASS *) theType,imageID,maxIndices); #else PrintIntegerReference(theFile,(INTEGER_HN *) theType); #endif }
/**************************************************************** NAME : TypeToCode DESCRIPTION : Writes out a single type's data to the file INPUTS : 1) The output file 2) The compile image id 3) The type RETURNS : Nothing useful SIDE EFFECTS : Type data written NOTES : None ***************************************************************/ static void TypeToCode( void *theEnv, FILE *theFile, int imageID, void *theType, int maxIndices) { #if OBJECT_SYSTEM fprintf(theFile,"VS "); PrintClassReference(theEnv,theFile,(DEFCLASS *) theType,imageID,maxIndices); #else #if MAC_XCD #pragma unused(imageID) #pragma unused(maxIndices) #endif PrintIntegerReference(theEnv,theFile,(INTEGER_HN *) theType); #endif }
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 void DumpExpression( struct expr *exprPtr) { while (exprPtr != NULL) { fprintf(ExpressionFP,"{"); fprintf(ExpressionFP,"%d,",exprPtr->type); fprintf(ExpressionFP,"VS "); switch (exprPtr->type) { case FCALL: PrintFunctionReference(ExpressionFP,(struct FunctionDefinition *) exprPtr->value); break; case INTEGER: PrintIntegerReference(ExpressionFP,(INTEGER_HN *) exprPtr->value); break; case FLOAT: PrintFloatReference(ExpressionFP,(FLOAT_HN *) exprPtr->value); break; case PCALL: #if DEFFUNCTION_CONSTRUCT PrintDeffunctionReference(ExpressionFP,(DEFFUNCTION *) exprPtr->value, ImageID,MaxIndices); #else fprintf(ExpressionFP,"NULL"); #endif break; case GCALL: #if DEFGENERIC_CONSTRUCT PrintGenericFunctionReference(ExpressionFP,(DEFGENERIC *) exprPtr->value, ImageID,MaxIndices); #else fprintf(ExpressionFP,"NULL"); #endif break; case DEFTEMPLATE_PTR: #if DEFTEMPLATE_CONSTRUCT DeftemplateCConstructReference(ExpressionFP,exprPtr->value,ImageID,MaxIndices); #else fprintf(ExpressionFP,"NULL"); #endif break; case DEFGLOBAL_PTR: #if DEFGLOBAL_CONSTRUCT DefglobalCConstructReference(ExpressionFP,exprPtr->value,ImageID,MaxIndices); #else fprintf(ExpressionFP,"NULL"); #endif break; case DEFCLASS_PTR: #if OBJECT_SYSTEM PrintClassReference(ExpressionFP,(DEFCLASS *) exprPtr->value,ImageID,MaxIndices); #else fprintf(ExpressionFP,"NULL"); #endif break; case FACT_ADDRESS: #if DEFTEMPLATE_CONSTRUCT fprintf(ExpressionFP,"&DummyFact"); #else fprintf(ExpressionFP,"NULL"); #endif break; case INSTANCE_ADDRESS: #if OBJECT_SYSTEM fprintf(ExpressionFP,"&DummyInstance"); #else fprintf(ExpressionFP,"NULL"); #endif break; case STRING: case SYMBOL: case INSTANCE_NAME: case GBL_VARIABLE: PrintSymbolReference(ExpressionFP,(SYMBOL_HN *) exprPtr->value); break; case RVOID: fprintf(ExpressionFP,"NULL"); break; default: if (PrimitivesArray[exprPtr->type] == NULL) { fprintf(ExpressionFP,"NULL"); } else if (PrimitivesArray[exprPtr->type]->bitMap) { PrintBitMapReference(ExpressionFP,(BITMAP_HN *) exprPtr->value); } else { fprintf(ExpressionFP,"NULL"); } break; } fprintf(ExpressionFP,","); ExpressionCount++; if (exprPtr->argList == NULL) { fprintf(ExpressionFP,"NULL,"); } else { fprintf(ExpressionFP,"&E%d_%d[%ld],",ImageID,ExpressionVersion, ExpressionCount); } if (exprPtr->nextArg == NULL) { fprintf(ExpressionFP,"NULL}"); } else { fprintf(ExpressionFP,"&E%d_%d[%ld]}",ImageID,ExpressionVersion, ExpressionCount + ExpressionSize(exprPtr->argList)); } if (exprPtr->argList != NULL) { fprintf(ExpressionFP,",\n"); DumpExpression(exprPtr->argList); } exprPtr = exprPtr->nextArg; if (exprPtr != NULL) fprintf(ExpressionFP,",\n"); } }
static int HashTablesToCode( char *fileName) { int i; FILE *fp; struct symbolHashNode **symbolTable; struct floatHashNode **floatTable; struct integerHashNode **integerTable; struct bitMapHashNode **bitMapTable; #if FUZZY_DEFTEMPLATES struct fuzzyValueHashNode **fuzzyValueTable; #endif /*======================================*/ /* Write the code for the symbol table. */ /*======================================*/ symbolTable = GetSymbolTable(); if ((fp = NewCFile(fileName,1,1,FALSE)) == NULL) return(0); fprintf(HeaderFP,"extern struct symbolHashNode *sht%d[];\n",ImageID); fprintf(fp,"struct symbolHashNode *sht%d[%d] = {\n",ImageID,SYMBOL_HASH_SIZE); for (i = 0; i < SYMBOL_HASH_SIZE; i++) { PrintSymbolReference(fp,symbolTable[i]); if (i + 1 != SYMBOL_HASH_SIZE) fprintf(fp,",\n"); } fprintf(fp,"};\n"); fclose(fp); /*=====================================*/ /* Write the code for the float table. */ /*=====================================*/ floatTable = GetFloatTable(); if ((fp = NewCFile(fileName,1,2,FALSE)) == NULL) return(0); fprintf(HeaderFP,"extern struct floatHashNode *fht%d[];\n",ImageID); fprintf(fp,"struct floatHashNode *fht%d[%d] = {\n",ImageID,FLOAT_HASH_SIZE); for (i = 0; i < FLOAT_HASH_SIZE; i++) { if (floatTable[i] == NULL) { fprintf(fp,"NULL"); } else PrintFloatReference(fp,floatTable[i]); if (i + 1 != FLOAT_HASH_SIZE) fprintf(fp,",\n"); } fprintf(fp,"};\n"); fclose(fp); /*=======================================*/ /* Write the code for the integer table. */ /*=======================================*/ integerTable = GetIntegerTable(); if ((fp = NewCFile(fileName,1,3,FALSE)) == NULL) return(0); fprintf(HeaderFP,"extern struct integerHashNode *iht%d[];\n",ImageID); fprintf(fp,"struct integerHashNode *iht%d[%d] = {\n",ImageID,INTEGER_HASH_SIZE); for (i = 0; i < INTEGER_HASH_SIZE; i++) { if (integerTable[i] == NULL) { fprintf(fp,"NULL"); } else PrintIntegerReference(fp,integerTable[i]); if (i + 1 != INTEGER_HASH_SIZE) fprintf(fp,",\n"); } fprintf(fp,"};\n"); fclose(fp); /*======================================*/ /* Write the code for the bitmap table. */ /*======================================*/ bitMapTable = GetBitMapTable(); if ((fp = NewCFile(fileName,1,4,FALSE)) == NULL) return(0); fprintf(HeaderFP,"extern struct bitMapHashNode *bmht%d[];\n",ImageID); fprintf(fp,"struct bitMapHashNode *bmht%d[%d] = {\n",ImageID,BITMAP_HASH_SIZE); for (i = 0; i < BITMAP_HASH_SIZE; i++) { PrintBitMapReference(fp,bitMapTable[i]); if (i + 1 != BITMAP_HASH_SIZE) fprintf(fp,",\n"); } fprintf(fp,"};\n"); fclose(fp); #if FUZZY_DEFTEMPLATES /*=============================*/ /* Dump the fuzzy value table. */ /*=============================*/ fuzzyValueTable = GetFuzzyValueTable(); if ((fp = NewCFile(fileName,1,5,FALSE)) == NULL) return(0); fprintf(HeaderFP,"extern struct fuzzyValueHashNode *fvht%d[];\n",ImageID); fprintf(fp,"struct fuzzyValueHashNode *fvht%d[%d] = {\n",ImageID,FUZZY_VALUE_HASH_SIZE); for (i = 0; i < FUZZY_VALUE_HASH_SIZE; i++) { PrintFuzzyValueReference(fp,fuzzyValueTable[i]); if (i + 1 != FUZZY_VALUE_HASH_SIZE) fprintf(fp,",\n"); } fprintf(fp,"};\n"); fclose(fp); #endif /* FUZZY_DEFTEMPLATES */ return(1); }