Beispiel #1
0
globle void AtomicValuesToCode(
    char *fileName)
{
    int version;

    SetAtomicValueIndices(TRUE);

    HashTablesToCode(fileName);

#if FUZZY_DEFTEMPLATES
    /* would have been easier to change if HashTablesToCode returned
       the next free version to use
    */
    version = SymbolHashNodesToCode(fileName,6);
#else
    version = SymbolHashNodesToCode(fileName,5);
#endif
    version = FloatHashNodesToCode(fileName,version);
    version = IntegerHashNodesToCode(fileName,version);
    version = BitMapHashNodesToCode(fileName,version);

#if FUZZY_DEFTEMPLATES
    version = BitMapValuesToCode(fileName,version);
    version = FuzzyValueHashNodesToCode(fileName,version);
    version = FuzzyValuesToCode(fileName,version);
    version = FuzzyValueArraysToCode(fileName,version);
#else
    BitMapValuesToCode(fileName,version);
#endif
}
Beispiel #2
0
void AtomicValuesToCode(
  void *theEnv,
  const char *fileName,
  const char *pathName,
  char *fileNameBuffer)
  {
   int version; // TBD Necessary?

   SetAtomicValueIndices(theEnv,true);

   HashTablesToCode(theEnv,fileName,pathName,fileNameBuffer);

   version = SymbolHashNodesToCode(theEnv,fileName,pathName,fileNameBuffer,5);
   version = FloatHashNodesToCode(theEnv,fileName,pathName,fileNameBuffer,version);
   version = IntegerHashNodesToCode(theEnv,fileName,pathName,fileNameBuffer,version);
   version = BitMapHashNodesToCode(theEnv,fileName,pathName,fileNameBuffer,version);
   BitMapValuesToCode(theEnv,fileName,pathName,fileNameBuffer,version);
  }
Beispiel #3
0
globle void AtomicValuesToCode(
  void *theEnv,
  EXEC_STATUS,
  char *fileName,
  char *pathName,
  char *fileNameBuffer)
  {
   int version;

   SetAtomicValueIndices(theEnv,execStatus,TRUE);

   HashTablesToCode(theEnv,execStatus,fileName,pathName,fileNameBuffer);

   version = SymbolHashNodesToCode(theEnv,execStatus,fileName,pathName,fileNameBuffer,5);
   version = FloatHashNodesToCode(theEnv,execStatus,fileName,pathName,fileNameBuffer,version);
   version = IntegerHashNodesToCode(theEnv,execStatus,fileName,pathName,fileNameBuffer,version);
   version = BitMapHashNodesToCode(theEnv,execStatus,fileName,pathName,fileNameBuffer,version);
   BitMapValuesToCode(theEnv,execStatus,fileName,pathName,fileNameBuffer,version);
  }
Beispiel #4
0
globle intBool EnvBsave(
    void *theEnv,
    EXEC_STATUS,
    char *fileName)
{
    FILE *fp;
    struct BinaryItem *biPtr;
    char constructBuffer[CONSTRUCT_HEADER_SIZE];
    long saveExpressionCount;

    /*===================================*/
    /* A bsave can't occur when a binary */
    /* image is already loaded.          */
    /*===================================*/

    if (Bloaded(theEnv,execStatus))
    {
        PrintErrorID(theEnv,execStatus,"BSAVE",1,FALSE);
        EnvPrintRouter(theEnv,execStatus,WERROR,
                       "Cannot perform a binary save while a binary load is in effect.\n");
        return(0);
    }

    /*================*/
    /* Open the file. */
    /*================*/

    if ((fp = GenOpen(theEnv,execStatus,fileName,"wb")) == NULL)
    {
        OpenErrorMessage(theEnv,execStatus,"bsave",fileName);
        return(0);
    }

    /*==============================*/
    /* Remember the current module. */
    /*==============================*/

    SaveCurrentModule(theEnv,execStatus);

    /*==================================*/
    /* Write binary header to the file. */
    /*==================================*/

    WriteBinaryHeader(theEnv,execStatus,fp);

    /*===========================================*/
    /* Initialize count variables, index values, */
    /* and determine some of the data structures */
    /* which need to be saved.                   */
    /*===========================================*/

    ExpressionData(theEnv,execStatus)->ExpressionCount = 0;
    InitializeFunctionNeededFlags(theEnv,execStatus);
    InitAtomicValueNeededFlags(theEnv,execStatus);
    FindHashedExpressions(theEnv,execStatus);
    FindNeededItems(theEnv,execStatus);
    SetAtomicValueIndices(theEnv,execStatus,FALSE);

    /*===============================*/
    /* Save the functions and atoms. */
    /*===============================*/

    WriteNeededFunctions(theEnv,execStatus,fp);
    WriteNeededAtomicValues(theEnv,execStatus,fp);

    /*=========================================*/
    /* Write out the number of expression data */
    /* structures in the binary image.         */
    /*=========================================*/

    GenWrite((void *) &ExpressionData(theEnv,execStatus)->ExpressionCount,(unsigned long) sizeof(unsigned long),fp);

    /*===========================================*/
    /* Save the numbers indicating the amount of */
    /* memory needed to bload the constructs.    */
    /*===========================================*/

    for (biPtr = BsaveData(theEnv,execStatus)->ListOfBinaryItems;
            biPtr != NULL;
            biPtr = biPtr->next)
    {
        if (biPtr->bsaveStorageFunction != NULL)
        {
            genstrncpy(constructBuffer,biPtr->name,CONSTRUCT_HEADER_SIZE);
            GenWrite(constructBuffer,(unsigned long) CONSTRUCT_HEADER_SIZE,fp);
            (*biPtr->bsaveStorageFunction)(theEnv,execStatus,fp);
        }
    }

    /*====================================*/
    /* Write a binary footer to the file. */
    /*====================================*/

    WriteBinaryFooter(theEnv,execStatus,fp);

    /*===================*/
    /* Save expressions. */
    /*===================*/

    ExpressionData(theEnv,execStatus)->ExpressionCount = 0;
    BsaveHashedExpressions(theEnv,execStatus,fp);
    saveExpressionCount = ExpressionData(theEnv,execStatus)->ExpressionCount;
    BsaveConstructExpressions(theEnv,execStatus,fp);
    ExpressionData(theEnv,execStatus)->ExpressionCount = saveExpressionCount;

    /*===================*/
    /* Save constraints. */
    /*===================*/

    WriteNeededConstraints(theEnv,execStatus,fp);

    /*==================*/
    /* Save constructs. */
    /*==================*/

    for (biPtr = BsaveData(theEnv,execStatus)->ListOfBinaryItems;
            biPtr != NULL;
            biPtr = biPtr->next)
    {
        if (biPtr->bsaveFunction != NULL)
        {
            genstrncpy(constructBuffer,biPtr->name,CONSTRUCT_HEADER_SIZE);
            GenWrite(constructBuffer,(unsigned long) CONSTRUCT_HEADER_SIZE,fp);
            (*biPtr->bsaveFunction)(theEnv,execStatus,fp);
        }
    }

    /*===================================*/
    /* Save a binary footer to the file. */
    /*===================================*/

    WriteBinaryFooter(theEnv,execStatus,fp);

    /*===========*/
    /* Clean up. */
    /*===========*/

    RestoreAtomicValueBuckets(theEnv,execStatus);

    /*=================*/
    /* Close the file. */
    /*=================*/

    GenClose(theEnv,execStatus,fp);

    /*=============================*/
    /* Restore the current module. */
    /*=============================*/

    RestoreCurrentModule(theEnv,execStatus);

    /*========================================*/
    /* Return TRUE to indicate success. */
    /*========================================*/

    return(TRUE);
}